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 2 commits
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
25 changes: 25 additions & 0 deletions portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ 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
} else if msgType == "reaction" || msgType == "encrypted reaction" {
if evt.Message.GetEncReactionMessage() != nil {
decryptedReaction, err := source.Client.DecryptReaction(evt)
Expand Down Expand Up @@ -2275,6 +2276,30 @@ func (portal *Portal) SetReply(msgID string, content *event.MessageEventContent,
content.RelatesTo.InReplyTo.UnstableRoomID = targetPortal.MXID
}
}()

if !portal.bridge.Config.Bridge.CrossRoomReplies && !replyTo.Chat.IsEmpty() && replyTo.Chat != key.JID {
if replyTo.Chat.Server == types.GroupServer {
key = database.NewPortalKey(replyTo.Chat, types.EmptyJID)
} else if replyTo.Chat == types.StatusBroadcastJID {
key = database.NewPortalKey(replyTo.Chat, key.Receiver)
}
if key != portal.Key {
targetPortal = portal.bridge.GetExistingPortalByJID(key)
if targetPortal == nil {
return false
}
}
message := portal.bridge.DB.Message.GetByJID(key, replyTo.MessageID)
if message != nil || !message.IsFakeMXID() {
egalvis39 marked this conversation as resolved.
Show resolved Hide resolved
evt, _ := targetPortal.MainIntent().GetEvent(targetPortal.MXID, message.MXID)
_ = evt.Content.ParseRaw(evt.Type)
content.EnsureHasHTML()
content.FormattedBody = evt.GenerateReplyFallbackHTML() + content.FormattedBody
content.Body = evt.GenerateReplyFallbackText() + content.Body
egalvis39 marked this conversation as resolved.
Show resolved Hide resolved
return true
}
}

if portal.bridge.Config.Bridge.CrossRoomReplies && !replyTo.Chat.IsEmpty() && replyTo.Chat != key.JID {
if replyTo.Chat.Server == types.GroupServer {
key = database.NewPortalKey(replyTo.Chat, types.EmptyJID)
Expand Down