fix: sync correct collectible username projection
This commit is contained in:
parent
8356989e01
commit
9041abd3d3
42 changed files with 601 additions and 758 deletions
|
|
@ -346,16 +346,12 @@ func applyUsernamesFromRegistry(users []tg.UserClass, chats []tg.ChatClass, byPe
|
|||
continue
|
||||
}
|
||||
if vector := tgUsernamesFromRegistry(list, u.Username); len(vector) > 0 {
|
||||
// Layer 228 defines username as the main active username, not as a
|
||||
// legacy alternative to usernames. TDesktop seeds its local search
|
||||
// index from this scalar before consuming the complete vector, so
|
||||
// both fields must be projected together.
|
||||
if primary := domain.ActiveUsername(list); primary != "" {
|
||||
u.SetUsername(primary)
|
||||
} else {
|
||||
u.Flags.Unset(3)
|
||||
u.Username = ""
|
||||
}
|
||||
// Official clients treat the legacy scalar and the complete vector as
|
||||
// alternative representations. TDLib rejects a User carrying both and
|
||||
// discards the complete username set, while TDesktop and DrKLO derive
|
||||
// the primary username from the first active vector entry.
|
||||
u.Flags.Unset(3)
|
||||
u.Username = ""
|
||||
u.SetUsernames(vector)
|
||||
}
|
||||
}
|
||||
|
|
@ -372,12 +368,8 @@ func applyUsernamesFromRegistry(users []tg.UserClass, chats []tg.ChatClass, byPe
|
|||
// when unset, which is exactly the fallback tgUsernamesFromRegistry wants.
|
||||
scalar, _ := ch.GetUsername()
|
||||
if vector := tgUsernamesFromRegistry(list, scalar); len(vector) > 0 {
|
||||
if primary := domain.ActiveUsername(list); primary != "" {
|
||||
ch.SetUsername(primary)
|
||||
} else {
|
||||
ch.Flags.Unset(6)
|
||||
ch.Username = ""
|
||||
}
|
||||
ch.Flags.Unset(6)
|
||||
ch.Username = ""
|
||||
ch.SetUsernames(vector)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue