From 8089468e83322362562f8effe741d7ee0c42e4fc Mon Sep 17 00:00:00 2001 From: Samuel Hawksby-Robinson Date: Fri, 10 Jul 2020 13:54:08 +0100 Subject: [PATCH] Added emoji reaction JSON RPC un/marshalling --- protocol/message.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/protocol/message.go b/protocol/message.go index b6f363bc2..bf9b0646e 100644 --- a/protocol/message.go +++ b/protocol/message.go @@ -122,6 +122,14 @@ func (m *Message) MarshalJSON() ([]byte, error) { Hash string `json:"hash"` Pack int32 `json:"pack"` } + type EmojiReactionAlias struct { + MessageId string `json:"message_id"` + Type int32 `json:"type"` + } + type EmojiReactionRetractionAlias struct { + EmojiReactionId string `json:"emoji_reaction_id"` + } + item := struct { ID string `json:"id"` WhisperTimestamp uint64 `json:"whisperTimestamp"` @@ -206,8 +214,14 @@ func (m *Message) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &aux); err != nil { return err } - if aux.ContentType == protobuf.ChatMessage_STICKER { + + switch aux.ContentType { + case protobuf.ChatMessage_STICKER: m.Payload = &protobuf.ChatMessage_Sticker{Sticker: aux.Sticker} + case protobuf.ChatMessage_EMOJI_REACTION: + m.Payload = &protobuf.ChatMessage_EmojiReaction{EmojiReaction: aux.EmojiReaction} + case protobuf.ChatMessage_EMOJI_REACTION_RETRACTION: + m.Payload = &protobuf.ChatMessage_EmojiReactionRetraction{EmojiReactionRetraction: aux.EmojiReactionRetraction} } if aux.ContentType == protobuf.ChatMessage_AUDIO { m.Payload = &protobuf.ChatMessage_Audio{