Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for WhatsApp status replies #661

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,10 @@ func getMessageType(waMsg *waProto.Message) string {
switch {
case waMsg == nil:
return "ignore"
case waMsg.Conversation != nil, waMsg.ExtendedTextMessage != nil:
case waMsg.Conversation != nil:
return "text"
case waMsg.ExtendedTextMessage != nil:
return "post_reply"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExtendedTextMessage is just a text message with additional metadata, not a status reply specifically. Any text message that includes a reply, a link preview, mentions, or is a disappearing message, will be an extended text message

case waMsg.ImageMessage != nil:
return fmt.Sprintf("image %s", waMsg.GetImageMessage().GetMimetype())
case waMsg.StickerMessage != nil:
Expand Down Expand Up @@ -985,6 +987,19 @@ func (portal *Portal) handleMessage(source *User, evt *events.Message, historica
if len(eventID) != 0 {
portal.finishHandling(existingMsg, &evt.Info, eventID, intent.UserID, dbMsgType, galleryPart, converted.Error)
}

egalvis39 marked this conversation as resolved.
Show resolved Hide resolved
// post_reply message is a WhatsApp status reply
if msgType == "post_reply" {
converted_quoted_message := portal.convertMessage(intent, source, &evt.Info, evt.Message.GetExtendedTextMessage().GetContextInfo().GetQuotedMessage(), false)
if converted_quoted_message == nil {
portal.log.Warnfln("Failed to convert post_reply message")
return
}
_, err := portal.sendMessage(converted_quoted_message.Intent, converted_quoted_message.Type, converted_quoted_message.Content, converted_quoted_message.Extra, evt.Info.Timestamp.UnixMilli())
egalvis39 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
portal.log.Errorfln("Failed to send %s to Matrix: %v", msgID, err)
}
}
} else if msgType == "reaction" || msgType == "encrypted reaction" {
if evt.Message.GetEncReactionMessage() != nil {
decryptedReaction, err := source.Client.DecryptReaction(evt)
Expand Down