--- a/bridgev2/ghost.go +++ b/bridgev2/ghost.go @@ -151,6 +151,10 @@ ExtraProfile database.ExtraProfile ExtraUpdates ExtraUpdater[*Ghost] + + // Xessenger (QA-289): ForGhost, when set, picks the profile UpdateInfo applies to the ghost in place of this + // one, from what the ghost holds before any of it is changed; nil keeps this one. + ForGhost func(ctx context.Context, ghost *Ghost) *UserInfo } func (ghost *Ghost) prepareName(name string) bool { @@ -337,6 +341,11 @@ } func (ghost *Ghost) UpdateInfo(ctx context.Context, info *UserInfo) { + if info.ForGhost != nil { + if picked := info.ForGhost(ctx, ghost); picked != nil { + info = picked + } + } oldName := ghost.Name oldAvatar := ghost.AvatarMXC @@ -375,6 +384,20 @@ } } +// ResendName sends the ghost's name to the Matrix side again when it has not taken it, as the ghost holds it +// then, holding the sync lock as UpdateInfo's push does. It changes nothing of the ghost but what the push +// marks, as a push of the name alone. Xessenger (QA-289): a profile that leaves a ghost's name as it is still +// has the name that did not go sent again, as UpdateInfo sends it with a profile that gives the name. +func (ghost *Ghost) ResendName(ctx context.Context) bool { + ghost.syncLock.Lock() + defer ghost.syncLock.Unlock() + if ghost.NameSet || ghost.Name == "" { + return false + } + ghost.pushProfileChanges(ctx, true, false, false) + return true +} + func (ghost *Ghost) pushProfileChanges(ctx context.Context, nameChanged, avatarChanged, contactInfoChanged bool) { if !nameChanged && !avatarChanged && !contactInfoChanged { return