mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-11-05 22:38:54 +01:00
Fix editing relaybot messages
This commit is contained in:
parent
1ab3d76db4
commit
51c18ec78b
1 changed files with 9 additions and 8 deletions
17
portal.go
17
portal.go
|
@ -3811,6 +3811,14 @@ func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, ev
|
||||||
return nil, sender, nil, fmt.Errorf("%w %T", errUnexpectedParsedContentType, evt.Content.Parsed)
|
return nil, sender, nil, fmt.Errorf("%w %T", errUnexpectedParsedContentType, evt.Content.Parsed)
|
||||||
}
|
}
|
||||||
extraMeta := &extraConvertMeta{}
|
extraMeta := &extraConvertMeta{}
|
||||||
|
isRelay := false
|
||||||
|
if !sender.IsLoggedIn() || (portal.IsPrivateChat() && sender.JID.User != portal.Key.Receiver.User) {
|
||||||
|
if !portal.HasRelaybot() {
|
||||||
|
return nil, sender, extraMeta, errUserNotLoggedIn
|
||||||
|
}
|
||||||
|
sender = portal.GetRelayUser()
|
||||||
|
isRelay = true
|
||||||
|
}
|
||||||
var editRootMsg *database.Message
|
var editRootMsg *database.Message
|
||||||
if editEventID := content.RelatesTo.GetReplaceID(); editEventID != "" {
|
if editEventID := content.RelatesTo.GetReplaceID(); editEventID != "" {
|
||||||
editRootMsg = portal.bridge.DB.Message.GetByMXID(editEventID)
|
editRootMsg = portal.bridge.DB.Message.GetByMXID(editEventID)
|
||||||
|
@ -3825,14 +3833,7 @@ func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, ev
|
||||||
|
|
||||||
msg := &waProto.Message{}
|
msg := &waProto.Message{}
|
||||||
ctxInfo := portal.generateContextInfo(content.RelatesTo)
|
ctxInfo := portal.generateContextInfo(content.RelatesTo)
|
||||||
relaybotFormatted := false
|
relaybotFormatted := isRelay && portal.addRelaybotFormat(sender, content)
|
||||||
if !sender.IsLoggedIn() || (portal.IsPrivateChat() && sender.JID.User != portal.Key.Receiver.User) {
|
|
||||||
if !portal.HasRelaybot() {
|
|
||||||
return nil, sender, extraMeta, errUserNotLoggedIn
|
|
||||||
}
|
|
||||||
relaybotFormatted = portal.addRelaybotFormat(sender, content)
|
|
||||||
sender = portal.GetRelayUser()
|
|
||||||
}
|
|
||||||
if evt.Type == event.EventSticker {
|
if evt.Type == event.EventSticker {
|
||||||
if relaybotFormatted {
|
if relaybotFormatted {
|
||||||
// Stickers can't have captions, so force relaybot stickers to be images
|
// Stickers can't have captions, so force relaybot stickers to be images
|
||||||
|
|
Loading…
Reference in a new issue