bridgev2: check that avatar mxc is set before ignoring update
Some checks failed
Go / Lint (latest) (push) Has been cancelled
Go / Build (old, libolm) (push) Has been cancelled
Go / Build (latest, libolm) (push) Has been cancelled
Go / Build (old, goolm) (push) Has been cancelled
Go / Build (latest, goolm) (push) Has been cancelled

This commit is contained in:
Tulir Asokan 2025-08-07 12:08:25 +03:00
commit 90e3427ac5
2 changed files with 4 additions and 4 deletions

View file

@ -158,7 +158,7 @@ func (ghost *Ghost) UpdateName(ctx context.Context, name string) bool {
}
func (ghost *Ghost) UpdateAvatar(ctx context.Context, avatar *Avatar) bool {
if ghost.AvatarID == avatar.ID && ghost.AvatarSet {
if ghost.AvatarID == avatar.ID && (avatar.Remove || ghost.AvatarMXC != "") && ghost.AvatarSet {
return false
}
ghost.AvatarID = avatar.ID
@ -168,7 +168,7 @@ func (ghost *Ghost) UpdateAvatar(ctx context.Context, avatar *Avatar) bool {
ghost.AvatarSet = false
zerolog.Ctx(ctx).Err(err).Msg("Failed to reupload avatar")
return true
} else if newHash == ghost.AvatarHash && ghost.AvatarSet {
} else if newHash == ghost.AvatarHash && ghost.AvatarMXC != "" && ghost.AvatarSet {
return true
}
ghost.AvatarHash = newHash

View file

@ -3533,7 +3533,7 @@ func (portal *Portal) updateTopic(ctx context.Context, topic string, sender Matr
}
func (portal *Portal) updateAvatar(ctx context.Context, avatar *Avatar, sender MatrixAPI, ts time.Time) bool {
if portal.AvatarID == avatar.ID && (portal.AvatarSet || portal.MXID == "") {
if portal.AvatarID == avatar.ID && (avatar.Remove || portal.AvatarMXC != "") && (portal.AvatarSet || portal.MXID == "") {
return false
}
portal.AvatarID = avatar.ID
@ -3549,7 +3549,7 @@ func (portal *Portal) updateAvatar(ctx context.Context, avatar *Avatar, sender M
portal.AvatarSet = false
zerolog.Ctx(ctx).Err(err).Msg("Failed to reupload room avatar")
return true
} else if newHash == portal.AvatarHash && portal.AvatarSet {
} else if newHash == portal.AvatarHash && portal.AvatarMXC != "" && portal.AvatarSet {
return true
}
portal.AvatarMXC = newMXC