Sync puppets when they send a message

Fixes #30, Fixes #34
This commit is contained in:
Gary Kramlich
2022-04-27 13:48:36 -05:00
parent 8ce5af2fb5
commit fc51c6e94e
2 changed files with 6 additions and 1 deletions

View File

@@ -418,7 +418,9 @@ func (p *Portal) handleDiscordMessageCreate(user *User, msg *discordgo.Message)
return
}
intent := p.bridge.GetPuppetByID(msg.Author.ID).IntentFor(p)
puppet := p.bridge.GetPuppetByID(msg.Author.ID)
puppet.SyncContact(user)
intent := puppet.IntentFor(p)
if msg.Content != "" {
content := &event.MessageEventContent{

View File

@@ -164,7 +164,10 @@ func (p *Puppet) CustomIntent() *appservice.IntentAPI {
func (p *Puppet) updatePortalMeta(meta func(portal *Portal)) {
for _, portal := range p.bridge.GetAllPortalsByID(p.ID) {
// Get room create lock to prevent races between receiving contact info and room creation.
portal.roomCreateLock.Lock()
meta(portal)
portal.roomCreateLock.Unlock()
}
}