Added basic EmojiReaction handler
This commit is contained in:
parent
eb562122b6
commit
9a775619cd
|
@ -669,3 +669,26 @@ func (m *MessageHandler) messageExists(messageID string, existingMessagesMap map
|
|||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (m *MessageHandler) HandleEmojiReaction(state *ReceivedMessageState, message protobuf.EmojiReaction) error {
|
||||
logger := m.logger.With(zap.String("site", "HandleEmojiReaction"))
|
||||
// TODO change this to chat id directly from the protobuf once it is updated
|
||||
contact := state.CurrentMessageState.Contact
|
||||
chat, ok := state.AllChats[contact.ID]
|
||||
if !ok {
|
||||
chat = OneToOneFromPublicKey(state.CurrentMessageState.PublicKey, state.Timesource)
|
||||
// We don't want to show the chat to the user
|
||||
chat.Active = false
|
||||
}
|
||||
|
||||
logger.Info("Handling emoji reaction")
|
||||
|
||||
if chat.LastClockValue < message.Clock {
|
||||
chat.LastClockValue = message.Clock
|
||||
}
|
||||
|
||||
state.ModifiedChats[chat.ID] = true
|
||||
state.AllChats[chat.ID] = chat
|
||||
|
||||
return nil
|
||||
}
|
|
@ -2056,7 +2056,19 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
|
|||
}
|
||||
// We continue in any case, no changes to messenger
|
||||
continue
|
||||
case protobuf.EmojiReaction:
|
||||
err = m.handler.HandleEmojiReaction(messageState, msg.ParsedMessage.(protobuf.EmojiReaction))
|
||||
if err != nil {
|
||||
logger.Warn("failed to handle EmojiReaction", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
|
||||
case protobuf.EmojiReactionRetraction:
|
||||
err = m.handler.HandleEmojiReactionRetraction(messageState, msg.ParsedMessage.(protobuf.EmojiReactionRetraction))
|
||||
if err != nil {
|
||||
logger.Warn("failed to handle EmojiReactionRetraction", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
default:
|
||||
// Check if is an encrypted PushNotificationRegistration
|
||||
if msg.Type == protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION {
|
||||
|
@ -3291,7 +3303,6 @@ func (m *Messenger) SendEmojiReaction(ctx context.Context, chatID, messageID str
|
|||
}
|
||||
|
||||
func (m *Messenger) SendEmojiReactionRetraction(ctx context.Context, emojiReactionID string) (*MessengerResponse, error) {
|
||||
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
|
|
Loading…
Reference in New Issue