Basic Group: Fix API errors (#3845)
This commit is contained in:
parent
ef1afd2379
commit
e26250071d
@ -39,6 +39,12 @@ import localDb from '../localDb';
|
||||
|
||||
const CHANNEL_ID_MIN_LENGTH = 11; // Example: -1000000000
|
||||
|
||||
function checkIfChannelId(id: string) {
|
||||
// HOTFIX New group id range starts with -4
|
||||
if (id.length === CHANNEL_ID_MIN_LENGTH && id.startsWith('-4')) return false;
|
||||
return id.length >= CHANNEL_ID_MIN_LENGTH;
|
||||
}
|
||||
|
||||
export function getEntityTypeById(chatOrUserId: string) {
|
||||
if (typeof chatOrUserId === 'number') {
|
||||
return getEntityTypeByDeprecatedId(chatOrUserId);
|
||||
@ -46,7 +52,7 @@ export function getEntityTypeById(chatOrUserId: string) {
|
||||
|
||||
if (!chatOrUserId.startsWith('-')) {
|
||||
return 'user';
|
||||
} else if (chatOrUserId.length >= CHANNEL_ID_MIN_LENGTH) {
|
||||
} else if (checkIfChannelId(chatOrUserId)) {
|
||||
return 'channel';
|
||||
} else {
|
||||
return 'chat';
|
||||
|
||||
@ -261,13 +261,8 @@ export function filterUsersByName(
|
||||
});
|
||||
}
|
||||
|
||||
export function getUserIdDividend(userId: string) {
|
||||
// Workaround for old-fashioned IDs stored locally
|
||||
if (typeof userId === 'number') {
|
||||
return Math.abs(userId);
|
||||
}
|
||||
|
||||
return Math.abs(Number(userId));
|
||||
export function getUserIdDividend(peerId: string) {
|
||||
return Math.abs(Number(peerId));
|
||||
}
|
||||
|
||||
// https://github.com/telegramdesktop/tdesktop/blob/371510cfe23b0bd226de8c076bc49248fbe40c26/Telegram/SourceFiles/data/data_peer.cpp#L53
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user