fix: sync correct collectible username projection

This commit is contained in:
iamxvbaba 2026-08-02 19:32:18 +08:00
parent 8356989e01
commit 9041abd3d3
42 changed files with 601 additions and 758 deletions

View file

@ -0,0 +1,25 @@
package rpc
import (
"context"
"github.com/iamxvbaba/td/tg"
"telesrv/internal/domain"
)
// tgSelfUserWithUsernames is the narrow single-object projection used by
// authorization results and self-profile updates. Those constructors already
// carry a complete User, so it must include the username registry without
// querying unrelated story or bot-verification read models.
//
// When a collectible registry vector exists, applyUsernamesToPeerObjects clears
// the legacy scalar username. Official clients treat the scalar and vector as
// alternative representations; emitting both makes TDLib reject the username
// set as malformed.
func (r *Router) tgSelfUserWithUsernames(ctx context.Context, u domain.User) *tg.User {
self := r.tgSelfUser(u)
users := []tg.UserClass{self}
r.applyUsernamesToPeerObjects(ctx, users, nil)
return self
}