Make sure puppet has displayname set when sending message

This commit is contained in:
Tulir Asokan 2021-06-15 12:34:55 +03:00
parent d4b7595b6e
commit b5c3e8abcb
2 changed files with 7 additions and 4 deletions

View file

@ -364,7 +364,9 @@ func (portal *Portal) getMessageIntent(user *User, info whatsapp.MessageInfo) *a
return nil
}
}
return portal.bridge.GetPuppetByJID(info.SenderJid).IntentFor(portal)
puppet := portal.bridge.GetPuppetByJID(info.SenderJid)
puppet.SyncContactIfNecessary(user)
return puppet.IntentFor(portal)
}
func (portal *Portal) startHandling(source *User, info whatsapp.MessageInfo, msgType string) *appservice.IntentAPI {
@ -1405,7 +1407,7 @@ func (portal *Portal) HandleStubMessage(source *User, message whatsapp.StubMessa
case waProto.WebMessageInfo_GROUP_CHANGE_RESTRICT:
eventID = portal.RestrictMetadataChanges(message.FirstParam == "on")
case waProto.WebMessageInfo_GROUP_PARTICIPANT_ADD, waProto.WebMessageInfo_GROUP_PARTICIPANT_INVITE, waProto.WebMessageInfo_BROADCAST_ADD:
eventID = portal.HandleWhatsAppInvite(senderJID, intent, message.Params)
eventID = portal.HandleWhatsAppInvite(source, senderJID, intent, message.Params)
case waProto.WebMessageInfo_GROUP_PARTICIPANT_REMOVE, waProto.WebMessageInfo_GROUP_PARTICIPANT_LEAVE, waProto.WebMessageInfo_BROADCAST_REMOVE:
portal.HandleWhatsAppKick(source, senderJID, message.Params)
case waProto.WebMessageInfo_GROUP_PARTICIPANT_PROMOTE:
@ -1601,7 +1603,7 @@ func (portal *Portal) HandleWhatsAppKick(source *User, senderJID string, jids []
}
}
func (portal *Portal) HandleWhatsAppInvite(senderJID string, intent *appservice.IntentAPI, jids []string) (evtID id.EventID) {
func (portal *Portal) HandleWhatsAppInvite(source *User, senderJID string, intent *appservice.IntentAPI, jids []string) (evtID id.EventID) {
if intent == nil {
intent = portal.MainIntent()
if senderJID != "unknown" {
@ -1611,6 +1613,7 @@ func (portal *Portal) HandleWhatsAppInvite(senderJID string, intent *appservice.
}
for _, jid := range jids {
puppet := portal.bridge.GetPuppetByJID(jid)
puppet.SyncContactIfNecessary(source)
content := event.Content{
Parsed: event.MemberEventContent{
Membership: "invite",

View file

@ -1370,7 +1370,7 @@ func (user *User) HandleChatUpdate(cmd whatsapp.ChatUpdate) {
case whatsapp.ChatActionRemove:
go portal.HandleWhatsAppKick(nil, cmd.Data.SenderJID, cmd.Data.UserChange.JIDs)
case whatsapp.ChatActionAdd:
go portal.HandleWhatsAppInvite(cmd.Data.SenderJID, nil, cmd.Data.UserChange.JIDs)
go portal.HandleWhatsAppInvite(user, cmd.Data.SenderJID, nil, cmd.Data.UserChange.JIDs)
case whatsapp.ChatActionIntroduce:
if cmd.Data.SenderJID != "unknown" {
go portal.Sync(user, whatsapp.Contact{JID: portal.Key.JID})