chatinfo: only clear avatar after fetching profile with no avatar

This commit is contained in:
Tulir Asokan 2025-01-19 13:58:03 +02:00
parent 8cdc01f21d
commit 030c83c197
2 changed files with 10 additions and 6 deletions

View file

@ -102,6 +102,11 @@ func (s *SignalClient) contactToUserInfo(contact *types.Recipient) *bridgev2.Use
return contact.ContactAvatar.Image, nil
},
}
} else if contact.Profile.AvatarPath == "clear" {
ui.Avatar = &bridgev2.Avatar{
ID: "",
Remove: true,
}
} else if contact.Profile.AvatarPath != "" {
ui.Avatar = &bridgev2.Avatar{
ID: makeAvatarPathID(contact.Profile.AvatarPath),
@ -109,11 +114,6 @@ func (s *SignalClient) contactToUserInfo(contact *types.Recipient) *bridgev2.Use
return s.Client.DownloadUserAvatar(ctx, contact.Profile.AvatarPath, contact.Profile.Key)
},
}
} else {
ui.Avatar = &bridgev2.Avatar{
ID: "",
Remove: true,
}
}
return ui
}

View file

@ -243,7 +243,11 @@ func (cli *Client) fetchProfileWithRequestAndKey(ctx context.Context, signalID u
}
}
// TODO store other metadata fields?
profile.AvatarPath = profileResponse.Avatar
if profileResponse.Avatar == "" {
profile.AvatarPath = "clear"
} else {
profile.AvatarPath = profileResponse.Avatar
}
profile.Credential = profileResponse.Credential
profile.Key = *profileKey