Added emoji reaction JSON RPC un/marshalling

This commit is contained in:
Samuel Hawksby-Robinson 2020-07-10 13:54:08 +01:00 committed by Andrea Maria Piana
parent 39bd6d479a
commit 8089468e83
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
1 changed files with 15 additions and 1 deletions

View File

@ -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{