Skip to content

Commit

Permalink
Unwrap view-once v2 extension and lottie sticker messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jun 19, 2024
1 parent 8ebe981 commit 329c233
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 8 additions & 0 deletions send.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
16 changes: 14 additions & 2 deletions types/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 329c233

Please sign in to comment.