Skip to content

Commit

Permalink
Fix contact avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed May 31, 2024
1 parent 6304b6b commit c5a7cca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ func (portal *Portal) handleSignalDataMessage(source *User, sender *Puppet, msg
Uint64("msg_ts", msg.GetTimestamp()).
Logger().WithContext(context.TODO())
// Always update sender info when we receive a message from them, there's caching inside the function
sender.UpdateInfo(genericCtx, source)
sender.UpdateInfo(genericCtx, source, nil)
// Handle earlier missed group changes here.
if msg.GetGroupV2() != nil {
requiredRevision := msg.GetGroupV2().GetRevision()
Expand Down Expand Up @@ -1800,7 +1800,7 @@ func (portal *Portal) CreateMatrixRoom(ctx context.Context, user *User, groupRev
if portal.IsPrivateChat() {
dmPuppet = portal.GetDMPuppet()
if dmPuppet != nil {
dmPuppet.UpdateInfo(ctx, user)
dmPuppet.UpdateInfo(ctx, user, nil)
portal.UpdateDMInfo(ctx, false)
} else {
portal.UpdatePNIDMInfo(ctx, user)
Expand Down Expand Up @@ -1900,7 +1900,7 @@ func (portal *Portal) PostReIDUpdate(ctx context.Context, user *User) {
if err != nil {
zerolog.Ctx(ctx).Err(err).Msg("Failed to update ghost power level after portal re-ID")
}
portal.GetDMPuppet().UpdateInfo(ctx, user)
portal.GetDMPuppet().UpdateInfo(ctx, user, nil)
portal.UpdateDMInfo(ctx, true)
if !portal.Encrypted {
_, _ = portal.bridge.Bot.LeaveRoom(ctx, portal.MXID)
Expand Down Expand Up @@ -2298,7 +2298,7 @@ func (portal *Portal) SyncParticipants(ctx context.Context, source *User, info *
log.Warn().Stringer("signal_user_id", member.ACI).Msg("Couldn't get puppet for group member")
continue
}
puppet.UpdateInfo(ctx, source)
puppet.UpdateInfo(ctx, source, nil)
intent := puppet.IntentFor(portal)
if member.ACI != source.SignalID && portal.MXID != "" {
userIDs[intent.UserID] = ((int)(member.Role) >> 1) * 50
Expand Down
5 changes: 4 additions & 1 deletion puppet.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (puppet *Puppet) GetAvatarURL() id.ContentURI {
return puppet.AvatarURL
}

func (puppet *Puppet) UpdateInfo(ctx context.Context, source *User) {
func (puppet *Puppet) UpdateInfo(ctx context.Context, source *User, contactAvatar *types.ContactAvatar) {
log := zerolog.Ctx(ctx).With().
Str("function", "Puppet.UpdateInfo").
Stringer("signal_user_id", puppet.SignalID).
Expand All @@ -252,6 +252,9 @@ func (puppet *Puppet) UpdateInfo(ctx context.Context, source *User) {
Msg("Ignoring outdated contact info")
return
}
if contactAvatar != nil {
info.ContactAvatar = *contactAvatar
}

log.Trace().Msg("Updating puppet info")

Expand Down
2 changes: 1 addition & 1 deletion user.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ func (user *User) handleContactList(evt *events.ContactList) {
if puppet == nil {
continue
}
puppet.UpdateInfo(ctx, user)
puppet.UpdateInfo(ctx, user, &contact.ContactAvatar)
}
}

Expand Down

0 comments on commit c5a7cca

Please sign in to comment.