mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-05-28 16:53:46 +02:00
Never return nil in IntentFor(). Fixes #379
This commit is contained in:
parent
de9977b7d2
commit
ea045160a2
|
@ -391,15 +391,10 @@ func (portal *Portal) backfill(source *User, messages []*waProto.WebMessageInfo)
|
|||
continue
|
||||
}
|
||||
puppet := portal.getMessagePuppet(source, info)
|
||||
var intent *appservice.IntentAPI
|
||||
if portal.Key.JID == puppet.JID {
|
||||
intent := puppet.IntentFor(portal)
|
||||
if intent.IsCustomPuppet && !portal.bridge.Config.Bridge.HistorySync.DoublePuppetBackfill {
|
||||
intent = puppet.DefaultIntent()
|
||||
} else {
|
||||
intent = puppet.IntentFor(portal)
|
||||
if intent.IsCustomPuppet && !portal.bridge.Config.Bridge.HistorySync.DoublePuppetBackfill {
|
||||
intent = puppet.DefaultIntent()
|
||||
addMember(puppet)
|
||||
}
|
||||
addMember(puppet)
|
||||
}
|
||||
converted := portal.convertMessage(intent, source, info, webMsg.GetMessage())
|
||||
if converted == nil {
|
||||
|
|
12
portal.go
12
portal.go
|
@ -339,6 +339,10 @@ func (portal *Portal) handleUndecryptableMessage(source *User, evt *events.Undec
|
|||
return
|
||||
}
|
||||
intent := portal.getMessageIntent(source, &evt.Info)
|
||||
if !intent.IsCustomPuppet && portal.IsPrivateChat() && evt.Info.Sender.User == portal.Key.Receiver.User {
|
||||
portal.log.Debugfln("Not handling %s (undecryptable): user doesn't have double puppeting enabled", evt.Info.ID)
|
||||
return
|
||||
}
|
||||
content := undecryptableMessageContent
|
||||
resp, err := portal.sendMessage(intent, event.EventMessage, &content, nil, evt.Info.Timestamp.UnixMilli())
|
||||
if err != nil {
|
||||
|
@ -356,6 +360,10 @@ func (portal *Portal) handleFakeMessage(msg fakeMessage) {
|
|||
return
|
||||
}
|
||||
intent := portal.bridge.GetPuppetByJID(msg.Sender).IntentFor(portal)
|
||||
if !intent.IsCustomPuppet && portal.IsPrivateChat() && msg.Sender.User == portal.Key.Receiver.User {
|
||||
portal.log.Debugfln("Not handling %s (fake): user doesn't have double puppeting enabled", msg.ID)
|
||||
return
|
||||
}
|
||||
resp, err := portal.sendMessage(intent, event.EventMessage, &event.MessageEventContent{
|
||||
MsgType: event.MsgText,
|
||||
Body: msg.Text,
|
||||
|
@ -397,6 +405,10 @@ func (portal *Portal) handleMessage(source *User, evt *events.Message) {
|
|||
}
|
||||
|
||||
intent := portal.getMessageIntent(source, &evt.Info)
|
||||
if !intent.IsCustomPuppet && portal.IsPrivateChat() && evt.Info.Sender.User == portal.Key.Receiver.User {
|
||||
portal.log.Debugfln("Not handling %s (%s): user doesn't have double puppeting enabled", msgID, msgType)
|
||||
return
|
||||
}
|
||||
converted := portal.convertMessage(intent, source, &evt.Info, evt.Message)
|
||||
if converted != nil {
|
||||
var eventID id.EventID
|
||||
|
|
|
@ -167,7 +167,7 @@ type Puppet struct {
|
|||
}
|
||||
|
||||
func (puppet *Puppet) IntentFor(portal *Portal) *appservice.IntentAPI {
|
||||
if (!portal.IsPrivateChat() && puppet.customIntent == nil) || portal.Key.JID == puppet.JID {
|
||||
if puppet.customIntent == nil || portal.Key.JID == puppet.JID {
|
||||
return puppet.DefaultIntent()
|
||||
}
|
||||
return puppet.customIntent
|
||||
|
|
Loading…
Reference in a new issue