mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-14 09:23:51 +01:00
Make sure puppet has displayname set when sending message
This commit is contained in:
parent
d4b7595b6e
commit
b5c3e8abcb
2 changed files with 7 additions and 4 deletions
|
@ -364,7 +364,9 @@ func (portal *Portal) getMessageIntent(user *User, info whatsapp.MessageInfo) *a
|
||||||
return nil
|
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 {
|
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:
|
case waProto.WebMessageInfo_GROUP_CHANGE_RESTRICT:
|
||||||
eventID = portal.RestrictMetadataChanges(message.FirstParam == "on")
|
eventID = portal.RestrictMetadataChanges(message.FirstParam == "on")
|
||||||
case waProto.WebMessageInfo_GROUP_PARTICIPANT_ADD, waProto.WebMessageInfo_GROUP_PARTICIPANT_INVITE, waProto.WebMessageInfo_BROADCAST_ADD:
|
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:
|
case waProto.WebMessageInfo_GROUP_PARTICIPANT_REMOVE, waProto.WebMessageInfo_GROUP_PARTICIPANT_LEAVE, waProto.WebMessageInfo_BROADCAST_REMOVE:
|
||||||
portal.HandleWhatsAppKick(source, senderJID, message.Params)
|
portal.HandleWhatsAppKick(source, senderJID, message.Params)
|
||||||
case waProto.WebMessageInfo_GROUP_PARTICIPANT_PROMOTE:
|
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 {
|
if intent == nil {
|
||||||
intent = portal.MainIntent()
|
intent = portal.MainIntent()
|
||||||
if senderJID != "unknown" {
|
if senderJID != "unknown" {
|
||||||
|
@ -1611,6 +1613,7 @@ func (portal *Portal) HandleWhatsAppInvite(senderJID string, intent *appservice.
|
||||||
}
|
}
|
||||||
for _, jid := range jids {
|
for _, jid := range jids {
|
||||||
puppet := portal.bridge.GetPuppetByJID(jid)
|
puppet := portal.bridge.GetPuppetByJID(jid)
|
||||||
|
puppet.SyncContactIfNecessary(source)
|
||||||
content := event.Content{
|
content := event.Content{
|
||||||
Parsed: event.MemberEventContent{
|
Parsed: event.MemberEventContent{
|
||||||
Membership: "invite",
|
Membership: "invite",
|
||||||
|
|
2
user.go
2
user.go
|
@ -1370,7 +1370,7 @@ func (user *User) HandleChatUpdate(cmd whatsapp.ChatUpdate) {
|
||||||
case whatsapp.ChatActionRemove:
|
case whatsapp.ChatActionRemove:
|
||||||
go portal.HandleWhatsAppKick(nil, cmd.Data.SenderJID, cmd.Data.UserChange.JIDs)
|
go portal.HandleWhatsAppKick(nil, cmd.Data.SenderJID, cmd.Data.UserChange.JIDs)
|
||||||
case whatsapp.ChatActionAdd:
|
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:
|
case whatsapp.ChatActionIntroduce:
|
||||||
if cmd.Data.SenderJID != "unknown" {
|
if cmd.Data.SenderJID != "unknown" {
|
||||||
go portal.Sync(user, whatsapp.Contact{JID: portal.Key.JID})
|
go portal.Sync(user, whatsapp.Contact{JID: portal.Key.JID})
|
||||||
|
|
Loading…
Reference in a new issue