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