ApiPeer: Calculate hasUsername based on all usernames (#6275)
This commit is contained in:
parent
73d5804a2c
commit
1a94405798
@ -63,9 +63,9 @@ function buildApiChatFieldsFromPeerEntity(
|
||||
const hasVideoAvatar = 'photo' in peerEntity && peerEntity.photo && 'hasVideo' in peerEntity.photo
|
||||
&& peerEntity.photo.hasVideo;
|
||||
const avatarPhotoId = ('photo' in peerEntity) && peerEntity.photo ? buildAvatarPhotoId(peerEntity.photo) : undefined;
|
||||
const hasUsername = Boolean('username' in peerEntity && peerEntity.username);
|
||||
|
||||
const usernames = buildApiUsernames(peerEntity);
|
||||
const hasUsername = usernames?.some((username) => username.isActive);
|
||||
|
||||
// Chat and channel shared fields
|
||||
const isCallActive = 'callActive' in peerEntity && peerEntity.callActive;
|
||||
|
||||
@ -101,12 +101,13 @@ export function buildApiUser(mtpUser: GramJs.TypeUser): ApiUser | undefined {
|
||||
const {
|
||||
id, firstName, lastName, fake, scam, support, closeFriend, storiesUnavailable, storiesMaxId,
|
||||
bot, botActiveUsers, botVerificationIcon, botInlinePlaceholder, botAttachMenu, botCanEdit,
|
||||
sendPaidMessagesStars, username, profileColor,
|
||||
sendPaidMessagesStars, profileColor,
|
||||
} = mtpUser;
|
||||
const hasVideoAvatar = mtpUser.photo instanceof GramJs.UserProfilePhoto ? Boolean(mtpUser.photo.hasVideo) : undefined;
|
||||
const avatarPhotoId = mtpUser.photo && buildAvatarPhotoId(mtpUser.photo);
|
||||
const userType = buildApiUserType(mtpUser);
|
||||
const usernames = buildApiUsernames(mtpUser);
|
||||
const hasUsername = usernames?.some((username) => username.isActive);
|
||||
const emojiStatus = mtpUser.emojiStatus ? buildApiEmojiStatus(mtpUser.emojiStatus) : undefined;
|
||||
|
||||
return {
|
||||
@ -125,8 +126,8 @@ export function buildApiUser(mtpUser: GramJs.TypeUser): ApiUser | undefined {
|
||||
hasMainMiniApp: Boolean(mtpUser.botHasMainApp),
|
||||
canEditBot: botCanEdit,
|
||||
...(userType === 'userTypeBot' && { canBeInvitedToGroup: !mtpUser.botNochats }),
|
||||
...(usernames && { usernames }),
|
||||
hasUsername: Boolean(username),
|
||||
usernames,
|
||||
hasUsername,
|
||||
phoneNumber: mtpUser.phone || '',
|
||||
noStatus: !mtpUser.status,
|
||||
...(mtpUser.accessHash && { accessHash: String(mtpUser.accessHash) }),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user