Fix clearing avatars if contact ID is cleared
This commit is contained in:
parent
72d2fc8615
commit
dad3dbc7e5
1 changed files with 10 additions and 6 deletions
10
puppet.go
10
puppet.go
|
@ -186,16 +186,20 @@ func (puppet *Puppet) DefaultIntent() *appservice.IntentAPI {
|
|||
const MinAvatarUpdateInterval = 24 * time.Hour
|
||||
|
||||
func (puppet *Puppet) UpdateAvatar(ctx context.Context, source *User) bool {
|
||||
if (puppet.AvatarSet && time.Since(puppet.AvatarUpdateTS) < MinAvatarUpdateInterval) || puppet.ContactID == "" {
|
||||
if (puppet.AvatarSet && time.Since(puppet.AvatarUpdateTS) < MinAvatarUpdateInterval) || (puppet.ContactID == "" && puppet.AvatarMXC.IsEmpty()) {
|
||||
return false
|
||||
}
|
||||
resp, err := source.Client.GetParticipantThumbnail(puppet.ID)
|
||||
var resp *gmproto.GetThumbnailResponse
|
||||
var err error
|
||||
if puppet.ContactID != "" {
|
||||
resp, err = source.Client.GetParticipantThumbnail(puppet.ID)
|
||||
if err != nil {
|
||||
puppet.log.Err(err).Msg("Failed to get avatar thumbnail")
|
||||
return false
|
||||
}
|
||||
}
|
||||
puppet.AvatarUpdateTS = time.Now()
|
||||
if len(resp.Thumbnail) == 0 {
|
||||
if resp == nil || len(resp.Thumbnail) == 0 {
|
||||
if puppet.AvatarHash == [32]byte{} && puppet.AvatarMXC.IsEmpty() && puppet.AvatarSet {
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue