Add more logs for avatar syncing
This commit is contained in:
parent
89b9f46301
commit
765dc618e6
1 changed files with 8 additions and 2 deletions
10
puppet.go
10
puppet.go
|
@ -196,19 +196,20 @@ func (puppet *Puppet) UpdateAvatar(ctx context.Context, source *User) bool {
|
||||||
}
|
}
|
||||||
puppet.AvatarUpdateTS = time.Now()
|
puppet.AvatarUpdateTS = time.Now()
|
||||||
if len(resp.Thumbnail) == 0 {
|
if len(resp.Thumbnail) == 0 {
|
||||||
if puppet.AvatarHash == [32]byte{} && puppet.AvatarMXC.IsEmpty() {
|
if puppet.AvatarHash == [32]byte{} && puppet.AvatarMXC.IsEmpty() && puppet.AvatarSet {
|
||||||
puppet.AvatarSet = true
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
puppet.AvatarHash = [32]byte{}
|
puppet.AvatarHash = [32]byte{}
|
||||||
puppet.AvatarMXC = id.ContentURI{}
|
puppet.AvatarMXC = id.ContentURI{}
|
||||||
puppet.AvatarSet = false
|
puppet.AvatarSet = false
|
||||||
|
puppet.log.Debug().Msg("Clearing user avatar")
|
||||||
} else {
|
} else {
|
||||||
thumbData := resp.Thumbnail[0].GetData()
|
thumbData := resp.Thumbnail[0].GetData()
|
||||||
hash := sha256.Sum256(thumbData.GetImageBuffer())
|
hash := sha256.Sum256(thumbData.GetImageBuffer())
|
||||||
if hash == puppet.AvatarHash && puppet.AvatarSet {
|
if hash == puppet.AvatarHash && puppet.AvatarSet {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
puppet.log.Debug().Hex("avatar_hash", hash[:]).Msg("Uploading new user avatar")
|
||||||
puppet.AvatarHash = hash
|
puppet.AvatarHash = hash
|
||||||
puppet.AvatarSet = false
|
puppet.AvatarSet = false
|
||||||
avatarBytes := thumbData.GetImageBuffer()
|
avatarBytes := thumbData.GetImageBuffer()
|
||||||
|
@ -220,6 +221,10 @@ func (puppet *Puppet) UpdateAvatar(ctx context.Context, source *User) bool {
|
||||||
puppet.log.Err(err).Msg("Failed to upload avatar")
|
puppet.log.Err(err).Msg("Failed to upload avatar")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
puppet.log.Debug().
|
||||||
|
Hex("avatar_hash", hash[:]).
|
||||||
|
Stringer("mxc", uploadResp.ContentURI).
|
||||||
|
Msg("Uploaded new user avatar")
|
||||||
puppet.AvatarMXC = uploadResp.ContentURI
|
puppet.AvatarMXC = uploadResp.ContentURI
|
||||||
}
|
}
|
||||||
err = puppet.DefaultIntent().SetAvatarURL(ctx, puppet.AvatarMXC)
|
err = puppet.DefaultIntent().SetAvatarURL(ctx, puppet.AvatarMXC)
|
||||||
|
@ -227,6 +232,7 @@ func (puppet *Puppet) UpdateAvatar(ctx context.Context, source *User) bool {
|
||||||
puppet.log.Err(err).Msg("Failed to set avatar")
|
puppet.log.Err(err).Msg("Failed to set avatar")
|
||||||
} else {
|
} else {
|
||||||
puppet.AvatarSet = true
|
puppet.AvatarSet = true
|
||||||
|
puppet.log.Debug().Stringer("mxc", puppet.AvatarMXC).Msg("Updated avatar")
|
||||||
}
|
}
|
||||||
go puppet.updatePortalAvatar(ctx)
|
go puppet.updatePortalAvatar(ctx)
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in a new issue