mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-06-15 01:18:31 +02:00
Merge bf78f58d2a
into f8a22aab06
This commit is contained in:
commit
ee1fa5633f
18
portal.go
18
portal.go
|
@ -2282,16 +2282,20 @@ func (portal *Portal) SetReply(msgID string, content *event.MessageEventContent,
|
|||
Logger()
|
||||
key := portal.Key
|
||||
targetPortal := portal
|
||||
reply_format := ""
|
||||
defer func() {
|
||||
if content.RelatesTo != nil && content.RelatesTo.InReplyTo != nil && targetPortal != portal {
|
||||
content.RelatesTo.InReplyTo.UnstableRoomID = targetPortal.MXID
|
||||
}
|
||||
}()
|
||||
if portal.bridge.Config.Bridge.CrossRoomReplies && !replyTo.Chat.IsEmpty() && replyTo.Chat != key.JID {
|
||||
|
||||
if !replyTo.Chat.IsEmpty() && replyTo.Chat != portal.Key.JID {
|
||||
if replyTo.Chat.Server == types.GroupServer {
|
||||
key = database.NewPortalKey(replyTo.Chat, types.EmptyJID)
|
||||
reply_format = "Replying to <a href='%s'>[a message]</a> in a group : %s"
|
||||
} else if replyTo.Chat == types.StatusBroadcastJID {
|
||||
key = database.NewPortalKey(replyTo.Chat, key.Receiver)
|
||||
key = database.NewPortalKey(replyTo.Chat, portal.Key.Receiver)
|
||||
reply_format = "Replying to <a href='%s'>[a status]</a> : %s"
|
||||
}
|
||||
if key != portal.Key {
|
||||
targetPortal = portal.bridge.GetExistingPortalByJID(key)
|
||||
|
@ -2300,8 +2304,16 @@ func (portal *Portal) SetReply(msgID string, content *event.MessageEventContent,
|
|||
}
|
||||
}
|
||||
}
|
||||
message := portal.bridge.DB.Message.GetByJID(key, replyTo.MessageID)
|
||||
message := portal.bridge.DB.Message.GetByJID(portal.Key, replyTo.MessageID)
|
||||
if message == nil || message.IsFakeMXID() {
|
||||
if portal != targetPortal && !portal.bridge.Config.Bridge.CrossRoomReplies {
|
||||
message := portal.bridge.DB.Message.GetByJID(key, replyTo.MessageID)
|
||||
link := targetPortal.MXID.EventURI(message.MXID, portal.bridge.Config.Homeserver.Domain).MatrixToURL()
|
||||
content.EnsureHasHTML()
|
||||
content.FormattedBody = fmt.Sprintf(reply_format, link, content.FormattedBody)
|
||||
content.Body = fmt.Sprintf(reply_format, link, content.Body)
|
||||
return true
|
||||
}
|
||||
if isHungryBackfill {
|
||||
content.RelatesTo = (&event.RelatesTo{}).SetReplyTo(targetPortal.deterministicEventID(replyTo.Sender, replyTo.MessageID, ""))
|
||||
portal.addReplyMention(content, replyTo.Sender, "")
|
||||
|
|
Loading…
Reference in a new issue