Removed original iteration

This commit is contained in:
Samuel Hawksby-Robinson 2020-07-20 22:36:03 +01:00 committed by Andrea Maria Piana
parent 2d9db29f31
commit ae1e6db883
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
3 changed files with 6 additions and 45 deletions

View File

@ -122,13 +122,6 @@ func (m *Message) MarshalJSON() ([]byte, error) {
Hash string `json:"hash"` Hash string `json:"hash"`
Pack int32 `json:"pack"` 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 { item := struct {
ID string `json:"id"` ID string `json:"id"`
@ -215,13 +208,8 @@ func (m *Message) UnmarshalJSON(data []byte) error {
return err return err
} }
switch aux.ContentType { if aux.ContentType == protobuf.ChatMessage_STICKER {
case protobuf.ChatMessage_STICKER:
m.Payload = &protobuf.ChatMessage_Sticker{Sticker: aux.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 { if aux.ContentType == protobuf.ChatMessage_AUDIO {
m.Payload = &protobuf.ChatMessage_Audio{ m.Payload = &protobuf.ChatMessage_Audio{

View File

@ -204,33 +204,6 @@ func ValidateReceivedChatMessage(message *protobuf.ChatMessage, whisperTimestamp
if image.Type == protobuf.ImageMessage_UNKNOWN_IMAGE_TYPE { if image.Type == protobuf.ImageMessage_UNKNOWN_IMAGE_TYPE {
return errors.New("image type unknown") 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 { if message.ContentType == protobuf.ChatMessage_AUDIO {

View File

@ -87,11 +87,11 @@ type RawResponse struct {
} }
type MessengerResponse struct { type MessengerResponse struct {
Chats []*Chat `json:"chats,omitempty"` Chats []*Chat `json:"chats,omitempty"`
Messages []*Message `json:"messages,omitempty"` Messages []*Message `json:"messages,omitempty"`
Contacts []*Contact `json:"contacts,omitempty"` Contacts []*Contact `json:"contacts,omitempty"`
Installations []*multidevice.Installation `json:"installations,omitempty"` Installations []*multidevice.Installation `json:"installations,omitempty"`
EmojiReactions []*EmojiReaction `json:"emoji_reactions"` EmojiReactions []*EmojiReaction `json:"emoji_reactions,omitempty"`
} }
func (m *MessengerResponse) IsEmpty() bool { func (m *MessengerResponse) IsEmpty() bool {