From ae1e6db883a0863fce7964cfc8cc7d83554fcd05 Mon Sep 17 00:00:00 2001 From: Samuel Hawksby-Robinson Date: Mon, 20 Jul 2020 22:36:03 +0100 Subject: [PATCH] Removed original iteration --- protocol/message.go | 14 +------------- protocol/message_validator.go | 27 --------------------------- protocol/messenger.go | 10 +++++----- 3 files changed, 6 insertions(+), 45 deletions(-) diff --git a/protocol/message.go b/protocol/message.go index d76643889..6f68a57a2 100644 --- a/protocol/message.go +++ b/protocol/message.go @@ -122,13 +122,6 @@ 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"` @@ -215,13 +208,8 @@ func (m *Message) UnmarshalJSON(data []byte) error { return err } - switch aux.ContentType { - case protobuf.ChatMessage_STICKER: + if aux.ContentType == 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{ diff --git a/protocol/message_validator.go b/protocol/message_validator.go index 39dc11313..031445a83 100644 --- a/protocol/message_validator.go +++ b/protocol/message_validator.go @@ -204,33 +204,6 @@ func ValidateReceivedChatMessage(message *protobuf.ChatMessage, whisperTimestamp if image.Type == protobuf.ImageMessage_UNKNOWN_IMAGE_TYPE { return errors.New("image type unknown") } - - case protobuf.ChatMessage_EMOJI_REACTION: - if message.Payload == nil { - return errors.New("no emoji reaction data") - } - emojiR := message.GetEmojiReaction() - if emojiR == nil { - return errors.New("no emoji reaction data") - } - if len(emojiR.MessageId) == 0 { - return errors.New("emoji reaction no target message id") - } - if emojiR.Type == protobuf.EmojiReaction_UNKNOWN_EMOJI_REACTION_TYPE { - return errors.New("emoji reaction type unknown") - } - - case protobuf.ChatMessage_EMOJI_REACTION_RETRACTION: - if message.Payload == nil { - return errors.New("no emoji reaction retraction data") - } - emojiRR := message.GetEmojiReactionRetraction() - if emojiRR == nil { - return errors.New("no emoji reaction retraction data") - } - if len(emojiRR.EmojiReactionId) == 0 { - return errors.New("emoji reaction retraction no target emoji reaction id") - } } if message.ContentType == protobuf.ChatMessage_AUDIO { diff --git a/protocol/messenger.go b/protocol/messenger.go index 26ecb219d..beb97412f 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -87,11 +87,11 @@ type RawResponse struct { } type MessengerResponse struct { - Chats []*Chat `json:"chats,omitempty"` - Messages []*Message `json:"messages,omitempty"` - Contacts []*Contact `json:"contacts,omitempty"` - Installations []*multidevice.Installation `json:"installations,omitempty"` - EmojiReactions []*EmojiReaction `json:"emoji_reactions"` + Chats []*Chat `json:"chats,omitempty"` + Messages []*Message `json:"messages,omitempty"` + Contacts []*Contact `json:"contacts,omitempty"` + Installations []*multidevice.Installation `json:"installations,omitempty"` + EmojiReactions []*EmojiReaction `json:"emoji_reactions,omitempty"` } func (m *MessengerResponse) IsEmpty() bool {