forked from MirrorHub/mautrix-whatsapp
parent
51c18ec78b
commit
8a75e762d5
1 changed files with 5 additions and 4 deletions
|
@ -3510,13 +3510,13 @@ type MediaUpload struct {
|
||||||
FileLength int
|
FileLength int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (portal *Portal) addRelaybotFormat(sender *User, content *event.MessageEventContent) bool {
|
func (portal *Portal) addRelaybotFormat(userID id.UserID, content *event.MessageEventContent) bool {
|
||||||
member := portal.MainIntent().Member(portal.MXID, sender.MXID)
|
member := portal.MainIntent().Member(portal.MXID, userID)
|
||||||
if member == nil {
|
if member == nil {
|
||||||
member = &event.MemberEventContent{}
|
member = &event.MemberEventContent{}
|
||||||
}
|
}
|
||||||
content.EnsureHasHTML()
|
content.EnsureHasHTML()
|
||||||
data, err := portal.bridge.Config.Bridge.Relay.FormatMessage(content, sender.MXID, *member)
|
data, err := portal.bridge.Config.Bridge.Relay.FormatMessage(content, userID, *member)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
portal.log.Errorln("Failed to apply relaybot format:", err)
|
portal.log.Errorln("Failed to apply relaybot format:", err)
|
||||||
}
|
}
|
||||||
|
@ -3811,6 +3811,7 @@ 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{}
|
||||||
|
realSenderMXID := sender.MXID
|
||||||
isRelay := false
|
isRelay := false
|
||||||
if !sender.IsLoggedIn() || (portal.IsPrivateChat() && sender.JID.User != portal.Key.Receiver.User) {
|
if !sender.IsLoggedIn() || (portal.IsPrivateChat() && sender.JID.User != portal.Key.Receiver.User) {
|
||||||
if !portal.HasRelaybot() {
|
if !portal.HasRelaybot() {
|
||||||
|
@ -3833,7 +3834,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 := isRelay && portal.addRelaybotFormat(sender, content)
|
relaybotFormatted := isRelay && portal.addRelaybotFormat(realSenderMXID, content)
|
||||||
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