Fix support for - in invite links; Small refactoring
This commit is contained in:
parent
196419be32
commit
a6d0f5a220
@ -109,39 +109,36 @@ function buildApiChatRestrictions(peerEntity: GramJs.TypeUser | GramJs.TypeChat)
|
||||
};
|
||||
}
|
||||
|
||||
if (peerEntity instanceof GramJs.User) {
|
||||
const restrictions = {};
|
||||
|
||||
if ('restricted' in peerEntity) {
|
||||
const restrictionReason = peerEntity.restricted
|
||||
? buildApiChatRestrictionReason(peerEntity.restrictionReason)
|
||||
: undefined;
|
||||
|
||||
if (restrictionReason === undefined) {
|
||||
return {
|
||||
isRestricted: false,
|
||||
};
|
||||
if (restrictionReason) {
|
||||
Object.assign(restrictions, {
|
||||
isRestricted: true,
|
||||
restrictionReason,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
isRestricted: peerEntity.restricted,
|
||||
restrictionReason,
|
||||
};
|
||||
} else if (peerEntity instanceof GramJs.Chat) {
|
||||
return {
|
||||
if (peerEntity instanceof GramJs.Chat) {
|
||||
Object.assign(restrictions, {
|
||||
isNotJoined: peerEntity.left,
|
||||
isRestricted: peerEntity.kicked,
|
||||
};
|
||||
} else if (peerEntity instanceof GramJs.Channel) {
|
||||
const isRestricted = peerEntity.restricted
|
||||
&& peerEntity.restrictionReason
|
||||
&& peerEntity.restrictionReason.some((reason) => reason.platform === 'all');
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
if (peerEntity instanceof GramJs.Channel) {
|
||||
Object.assign(restrictions, {
|
||||
// `left` is weirdly set to `true` on all channels never joined before
|
||||
isNotJoined: peerEntity.left,
|
||||
isRestricted,
|
||||
restrictionReason: buildApiChatRestrictionReason(peerEntity.restrictionReason),
|
||||
};
|
||||
});
|
||||
}
|
||||
return {};
|
||||
|
||||
return restrictions;
|
||||
}
|
||||
|
||||
function buildApiChatMigrationInfo(peerEntity: GramJs.TypeChat): {
|
||||
|
||||
@ -116,7 +116,7 @@ export const CONTENT_TYPES_FOR_QUICK_UPLOAD = 'image/png,image/gif,image/jpeg,vi
|
||||
// eslint-disable-next-line max-len
|
||||
export const RE_LINK_TEMPLATE = '((ftp|https?):\\/\\/)?((www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6})\\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)';
|
||||
export const RE_TME_LINK = /^(?:https?:\/\/)?(?:t\.me\/)([\d\w_]+)(?:\/([\d]+))?$/gm;
|
||||
export const RE_TME_INVITE_LINK = /^(?:https?:\/\/)?(?:t\.me\/joinchat\/)([\d\w_]+)?$/gm;
|
||||
export const RE_TME_INVITE_LINK = /^(?:https?:\/\/)?(?:t\.me\/joinchat\/)([\d\w_-]+)?$/gm;
|
||||
|
||||
// MTProto constants
|
||||
export const SERVICE_NOTIFICATIONS_USER_ID = 777000;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user