From 329c2336a6f1ad17da5575a1722b2582483d0b79 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 20 Jun 2024 00:02:40 +0300 Subject: [PATCH] Unwrap view-once v2 extension and lottie sticker messages --- send.go | 8 ++++++++ types/events/events.go | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/send.go b/send.go index cbc26958..9c2a3a18 100644 --- a/send.go +++ b/send.go @@ -649,6 +649,10 @@ func getTypeFromMessage(msg *waProto.Message) string { return getTypeFromMessage(msg.ViewOnceMessage.Message) case msg.ViewOnceMessageV2 != nil: return getTypeFromMessage(msg.ViewOnceMessageV2.Message) + case msg.ViewOnceMessageV2Extension != nil: + return getTypeFromMessage(msg.ViewOnceMessageV2Extension.Message) + case msg.LottieStickerMessage != nil: + return getTypeFromMessage(msg.LottieStickerMessage.Message) case msg.EphemeralMessage != nil: return getTypeFromMessage(msg.EphemeralMessage.Message) case msg.DocumentWithCaptionMessage != nil: @@ -672,6 +676,10 @@ func getMediaTypeFromMessage(msg *waProto.Message) string { return getMediaTypeFromMessage(msg.ViewOnceMessage.Message) case msg.ViewOnceMessageV2 != nil: return getMediaTypeFromMessage(msg.ViewOnceMessageV2.Message) + case msg.ViewOnceMessageV2Extension != nil: + return getMediaTypeFromMessage(msg.ViewOnceMessageV2Extension.Message) + case msg.LottieStickerMessage != nil: + return getMediaTypeFromMessage(msg.LottieStickerMessage.Message) case msg.EphemeralMessage != nil: return getMediaTypeFromMessage(msg.EphemeralMessage.Message) case msg.DocumentWithCaptionMessage != nil: diff --git a/types/events/events.go b/types/events/events.go index 2d028ceb..7467ad6f 100644 --- a/types/events/events.go +++ b/types/events/events.go @@ -269,9 +269,11 @@ type Message struct { Message *waProto.Message // The actual message struct IsEphemeral bool // True if the message was unwrapped from an EphemeralMessage - IsViewOnce bool // True if the message was unwrapped from a ViewOnceMessage or ViewOnceMessageV2 - IsViewOnceV2 bool // True if the message was unwrapped from a ViewOnceMessage + IsViewOnce bool // True if the message was unwrapped from a ViewOnceMessage, ViewOnceMessageV2 or ViewOnceMessageV2Extension + IsViewOnceV2 bool // True if the message was unwrapped from a ViewOnceMessageV2 or ViewOnceMessageV2Extension + IsViewOnceV2Extension bool // True if the message was unwrapped from a ViewOnceMessageV2Extension IsDocumentWithCaption bool // True if the message was unwrapped from a DocumentWithCaptionMessage + IsLottieSticker bool // True if the message was unwrapped from a LottieStickerMessage IsEdit bool // True if the message was unwrapped from an EditedMessage // If this event was parsed from a WebMessageInfo (i.e. from a history sync or unavailable message request), the source data is here. @@ -322,6 +324,16 @@ func (evt *Message) UnwrapRaw() *Message { evt.IsViewOnce = true evt.IsViewOnceV2 = true } + if evt.Message.GetViewOnceMessageV2Extension().GetMessage() != nil { + evt.Message = evt.Message.GetViewOnceMessageV2Extension().GetMessage() + evt.IsViewOnce = true + evt.IsViewOnceV2 = true + evt.IsViewOnceV2Extension = true + } + if evt.Message.GetLottieStickerMessage().GetMessage() != nil { + evt.Message = evt.Message.GetLottieStickerMessage().GetMessage() + evt.IsLottieSticker = true + } if evt.Message.GetDocumentWithCaptionMessage().GetMessage() != nil { evt.Message = evt.Message.GetDocumentWithCaptionMessage().GetMessage() evt.IsDocumentWithCaption = true