Read marks date

Sponsor information
Layer 155
This commit is contained in:
Eduard Kuzmenko 2023-03-09 18:33:07 +04:00
parent df25877d0c
commit b2035b00e1
16 changed files with 377 additions and 125 deletions

View File

@ -19,7 +19,7 @@ import findUpClassName from '../../helpers/dom/findUpClassName';
import cancelEvent from '../../helpers/dom/cancelEvent'; import cancelEvent from '../../helpers/dom/cancelEvent';
import {attachClickEvent, simulateClickEvent} from '../../helpers/dom/clickEvent'; import {attachClickEvent, simulateClickEvent} from '../../helpers/dom/clickEvent';
import isSelectionEmpty from '../../helpers/dom/isSelectionEmpty'; import isSelectionEmpty from '../../helpers/dom/isSelectionEmpty';
import {Message, Poll, Chat as MTChat, MessageMedia, AvailableReaction, MessageEntity, InputStickerSet, StickerSet, Document, Reaction, Photo} from '../../layer'; import {Message, Poll, Chat as MTChat, MessageMedia, AvailableReaction, MessageEntity, InputStickerSet, StickerSet, Document, Reaction, Photo, SponsoredMessage} from '../../layer';
import PopupReportMessages from '../popups/reportMessages'; import PopupReportMessages from '../popups/reportMessages';
import assumeType from '../../helpers/assumeType'; import assumeType from '../../helpers/assumeType';
import PopupSponsored from '../popups/sponsored'; import PopupSponsored from '../popups/sponsored';
@ -50,8 +50,16 @@ import canSaveMessageMedia from '../../lib/appManagers/utils/messages/canSaveMes
import getAlbumText from '../../lib/appManagers/utils/messages/getAlbumText'; import getAlbumText from '../../lib/appManagers/utils/messages/getAlbumText';
import PopupElement from '../popups'; import PopupElement from '../popups';
type ChatContextMenuButton = ButtonMenuItemOptions & {
verify: () => boolean | Promise<boolean>,
notDirect?: () => boolean,
withSelection?: true,
isSponsored?: true,
localName?: 'views' | 'emojis' | 'sponsorInfo' | 'sponsorAdditionalInfo'
};
export default class ChatContextMenu { export default class ChatContextMenu {
private buttons: (ButtonMenuItemOptions & {verify: () => boolean | Promise<boolean>, notDirect?: () => boolean, withSelection?: true, isSponsored?: true, localName?: 'views' | 'emojis'})[]; private buttons: ChatContextMenuButton[];
private element: HTMLElement; private element: HTMLElement;
private isSelectable: boolean; private isSelectable: boolean;
@ -66,6 +74,7 @@ export default class ChatContextMenu {
private peerId: PeerId; private peerId: PeerId;
private mid: number; private mid: number;
private message: Message.message | Message.messageService; private message: Message.message | Message.messageService;
private sponsoredMessage: SponsoredMessage;
private noForwards: boolean; private noForwards: boolean;
private reactionsMenu: ChatReactionsMenu; private reactionsMenu: ChatReactionsMenu;
@ -166,6 +175,8 @@ export default class ChatContextMenu {
); );
this.isUsernameTarget = this.target.tagName === 'A' && this.target.classList.contains('mention'); this.isUsernameTarget = this.target.tagName === 'A' && this.target.classList.contains('mention');
this.sponsoredMessage = isSponsored ? (bubble as any).message.sponsoredMessage : undefined;
const mids = await this.chat.getMidsByMid(mid); const mids = await this.chat.getMidsByMid(mid);
// * если открыть контекстное меню для альбома не по бабблу, и последний элемент не выбран, чтобы показать остальные пункты // * если открыть контекстное меню для альбома не по бабблу, и последний элемент не выбран, чтобы показать остальные пункты
if(this.chat.selection.isSelecting && !contentWrapper) { if(this.chat.selection.isSelecting && !contentWrapper) {
@ -281,26 +292,24 @@ export default class ChatContextMenu {
} }
private async filterButtons(buttons: ChatContextMenu['buttons']) { private async filterButtons(buttons: ChatContextMenu['buttons']) {
if(this.isSponsored) { return filterAsync(buttons, async(button) => {
return buttons.filter((button) => { let good: boolean;
return button.isSponsored;
});
} else {
return filterAsync(buttons, async(button) => {
let good: boolean;
// if((appImManager.chatSelection.isSelecting && !button.withSelection) || (button.withSelection && !appImManager.chatSelection.isSelecting)) { if((this.isSponsored && !button.isSponsored) || (!this.isSponsored && button.isSponsored)) {
if(this.chat.selection.isSelecting && !button.withSelection) { return false;
good = false; }
} else {
good = this.isOverBubble || IS_TOUCH_SUPPORTED || true ?
await button.verify() :
button.notDirect && await button.verify() && button.notDirect();
}
return !!good; // if((appImManager.chatSelection.isSelecting && !button.withSelection) || (button.withSelection && !appImManager.chatSelection.isSelecting)) {
}); if(this.chat.selection.isSelecting && !button.withSelection) {
} good = false;
} else {
good = this.isOverBubble || IS_TOUCH_SUPPORTED || true ?
await button.verify() :
button.notDirect && await button.verify() && button.notDirect();
}
return !!good;
});
} }
private setButtons() { private setButtons() {
@ -512,7 +521,7 @@ export default class ChatContextMenu {
withSelection: true withSelection: true
}, { }, {
onClick: () => { onClick: () => {
if(this.viewerPeerId) { if(this.viewerPeerId && false) {
this.chat.appImManager.setInnerPeer({ this.chat.appImManager.setInnerPeer({
peerId: this.viewerPeerId peerId: this.viewerPeerId
}); });
@ -543,7 +552,13 @@ export default class ChatContextMenu {
onClick: () => { onClick: () => {
PopupElement.createPopup(PopupSponsored); PopupElement.createPopup(PopupSponsored);
}, },
verify: () => false, verify: () => this.isSponsored,
isSponsored: true
}, {
icon: 'copy',
text: 'Copy',
onClick: () => copyTextToClipboard(this.sponsoredMessage.message),
verify: () => this.isSponsored,
isSponsored: true isSponsored: true
}, { }, {
// icon: 'smile', // icon: 'smile',
@ -556,6 +571,20 @@ export default class ChatContextMenu {
verify: () => !!this.getUniqueCustomEmojisFromMessage().length, verify: () => !!this.getUniqueCustomEmojisFromMessage().length,
notDirect: () => true, notDirect: () => true,
localName: 'emojis' localName: 'emojis'
}, {
regularText: this.sponsoredMessage?.sponsor_info,
separator: true,
multiline: true,
onClick: () => copyTextToClipboard(this.sponsoredMessage.sponsor_info),
verify: () => !!this.sponsoredMessage.sponsor_info,
isSponsored: true
}, {
regularText: this.sponsoredMessage?.additional_info,
separator: true,
multiline: true,
onClick: () => copyTextToClipboard(this.sponsoredMessage.additional_info),
verify: () => !!this.sponsoredMessage.additional_info,
isSponsored: true
}]; }];
} }
@ -682,9 +711,7 @@ export default class ChatContextMenu {
return; return;
} }
if(fakeText) { fakeText?.remove();
fakeText.remove();
}
const reactions = result.combined; const reactions = result.combined;
const reactedLength = participantsCount === undefined ? const reactedLength = participantsCount === undefined ?
@ -703,7 +730,7 @@ export default class ChatContextMenu {
dialog: false dialog: false
}).element; }).element;
if(!isViewingReactions || result.readParticipants.length <= 1) { if(!isViewingReactions || result.readParticipantDates.length <= 1) {
this.viewerPeerId = reactions[0].peerId; this.viewerPeerId = reactions[0].peerId;
} }
} else if(isViewingReactions) { } else if(isViewingReactions) {

View File

@ -111,7 +111,6 @@ import {MARKDOWN_ENTITIES} from '../../lib/richTextProcessor';
import IMAGE_MIME_TYPES_SUPPORTED from '../../environment/imageMimeTypesSupport'; import IMAGE_MIME_TYPES_SUPPORTED from '../../environment/imageMimeTypesSupport';
import VIDEO_MIME_TYPES_SUPPORTED from '../../environment/videoMimeTypesSupport'; import VIDEO_MIME_TYPES_SUPPORTED from '../../environment/videoMimeTypesSupport';
import {ChatRights} from '../../lib/appManagers/appChatsManager'; import {ChatRights} from '../../lib/appManagers/appChatsManager';
import PopupGiftPremium from '../popups/giftPremium';
const RECORD_MIN_TIME = 500; const RECORD_MIN_TIME = 500;
@ -649,7 +648,7 @@ export default class ChatInput {
icon: 'gift', icon: 'gift',
text: 'GiftPremium', text: 'GiftPremium',
onClick: () => this.chat.appImManager.giftPremium(this.chat.peerId), onClick: () => this.chat.appImManager.giftPremium(this.chat.peerId),
verify: () => this.chat.canGiftPremium() verify: async() => await this.chat.canGiftPremium() && (await this.managers.apiManager.getAppConfig()).premium_gift_attach_menu_icon
}, { }, {
icon: 'poll', icon: 'poll',
text: 'Poll', text: 'Poll',

View File

@ -18,6 +18,7 @@ import getUserStatusString from '../wrappers/getUserStatusString';
import {makeMediaSize} from '../../helpers/mediaSize'; import {makeMediaSize} from '../../helpers/mediaSize';
import wrapCustomEmoji from '../wrappers/customEmoji'; import wrapCustomEmoji from '../wrappers/customEmoji';
import SettingSection from '../settingSection'; import SettingSection from '../settingSection';
import {formatFullSentTime} from '../../helpers/date';
export default class PopupReactedList extends PopupElement { export default class PopupReactedList extends PopupElement {
constructor( constructor(
@ -139,7 +140,7 @@ export default class PopupReactedList extends PopupElement {
const result = await this.managers.appMessagesManager.getMessageReactionsListAndReadParticipants(message, undefined, reactionCount.reaction, nextOffset, skipReadParticipants, skipReactionsList); const result = await this.managers.appMessagesManager.getMessageReactionsListAndReadParticipants(message, undefined, reactionCount.reaction, nextOffset, skipReadParticipants, skipReactionsList);
nextOffset = result.nextOffset; nextOffset = result.nextOffset;
await Promise.all(result.combined.map(async({peerId, reaction}) => { await Promise.all(result.combined.map(async({peerId, reaction, date}) => {
const {dom} = appDialogsManager.addDialogNew({ const {dom} = appDialogsManager.addDialogNew({
peerId: peerId, peerId: peerId,
autonomous: true, autonomous: true,
@ -174,7 +175,19 @@ export default class PopupReactedList extends PopupElement {
dom.listEl.append(stickerContainer); dom.listEl.append(stickerContainer);
} }
replaceContent(dom.lastMessageSpan, getUserStatusString(await this.managers.appUsersManager.getUser(peerId.toUserId()))); if(date && message.pFlags.out) {
const c = document.createElement('span');
dom.lastMessageSpan.style.cssText = `display: flex !important; align-items: center;`;
const span = document.createElement('span');
span.classList.add(reaction ? 'tgico-reactions' : 'tgico-checks', 'reacted-list-checks');
const fragment = document.createDocumentFragment();
c.append(formatFullSentTime(date, false));
fragment.append(span, c);
replaceContent(dom.lastMessageSpan, fragment);
} else {
const user = await this.managers.appUsersManager.getUser(peerId.toUserId());
replaceContent(dom.lastMessageSpan, getUserStatusString(user));
}
})); }));
return !nextOffset; return !nextOffset;

View File

@ -87,9 +87,9 @@ export function formatFullSentTimeRaw(timestamp: number, options: {
return {dateEl, timeEl}; return {dateEl, timeEl};
} }
export function formatFullSentTime(timestamp: number) { export function formatFullSentTime(timestamp: number, capitalize = true) {
const {dateEl, timeEl} = formatFullSentTimeRaw(timestamp, { const {dateEl, timeEl} = formatFullSentTimeRaw(timestamp, {
capitalize: true capitalize
}); });
const fragment = document.createDocumentFragment(); const fragment = document.createDocumentFragment();

244
src/layer.d.ts vendored
View File

@ -1074,7 +1074,7 @@ export namespace MessageMedia {
/** /**
* @link https://core.telegram.org/type/MessageAction * @link https://core.telegram.org/type/MessageAction
*/ */
export type MessageAction = MessageAction.messageActionEmpty | MessageAction.messageActionChatCreate | MessageAction.messageActionChatEditTitle | MessageAction.messageActionChatEditPhoto | MessageAction.messageActionChatDeletePhoto | MessageAction.messageActionChatAddUser | MessageAction.messageActionChatDeleteUser | MessageAction.messageActionChatJoinedByLink | MessageAction.messageActionChannelCreate | MessageAction.messageActionChatMigrateTo | MessageAction.messageActionChannelMigrateFrom | MessageAction.messageActionPinMessage | MessageAction.messageActionHistoryClear | MessageAction.messageActionGameScore | MessageAction.messageActionPaymentSentMe | MessageAction.messageActionPaymentSent | MessageAction.messageActionPhoneCall | MessageAction.messageActionScreenshotTaken | MessageAction.messageActionCustomAction | MessageAction.messageActionBotAllowed | MessageAction.messageActionSecureValuesSentMe | MessageAction.messageActionSecureValuesSent | MessageAction.messageActionContactSignUp | MessageAction.messageActionGeoProximityReached | MessageAction.messageActionGroupCall | MessageAction.messageActionInviteToGroupCall | MessageAction.messageActionSetMessagesTTL | MessageAction.messageActionGroupCallScheduled | MessageAction.messageActionSetChatTheme | MessageAction.messageActionChatJoinedByRequest | MessageAction.messageActionWebViewDataSentMe | MessageAction.messageActionWebViewDataSent | MessageAction.messageActionGiftPremium | MessageAction.messageActionTopicCreate | MessageAction.messageActionTopicEdit | MessageAction.messageActionSuggestProfilePhoto | MessageAction.messageActionAttachMenuBotAllowed | MessageAction.messageActionRequestedPeer | MessageAction.messageActionDiscussionStarted | MessageAction.messageActionChatLeave | MessageAction.messageActionChannelDeletePhoto | MessageAction.messageActionChannelEditTitle | MessageAction.messageActionChannelEditPhoto | MessageAction.messageActionChannelEditVideo | MessageAction.messageActionChatEditVideo | MessageAction.messageActionChatAddUsers | MessageAction.messageActionChatJoined | MessageAction.messageActionChatReturn | MessageAction.messageActionChatJoinedYou | MessageAction.messageActionChatReturnYou; export type MessageAction = MessageAction.messageActionEmpty | MessageAction.messageActionChatCreate | MessageAction.messageActionChatEditTitle | MessageAction.messageActionChatEditPhoto | MessageAction.messageActionChatDeletePhoto | MessageAction.messageActionChatAddUser | MessageAction.messageActionChatDeleteUser | MessageAction.messageActionChatJoinedByLink | MessageAction.messageActionChannelCreate | MessageAction.messageActionChatMigrateTo | MessageAction.messageActionChannelMigrateFrom | MessageAction.messageActionPinMessage | MessageAction.messageActionHistoryClear | MessageAction.messageActionGameScore | MessageAction.messageActionPaymentSentMe | MessageAction.messageActionPaymentSent | MessageAction.messageActionPhoneCall | MessageAction.messageActionScreenshotTaken | MessageAction.messageActionCustomAction | MessageAction.messageActionBotAllowed | MessageAction.messageActionSecureValuesSentMe | MessageAction.messageActionSecureValuesSent | MessageAction.messageActionContactSignUp | MessageAction.messageActionGeoProximityReached | MessageAction.messageActionGroupCall | MessageAction.messageActionInviteToGroupCall | MessageAction.messageActionSetMessagesTTL | MessageAction.messageActionGroupCallScheduled | MessageAction.messageActionSetChatTheme | MessageAction.messageActionChatJoinedByRequest | MessageAction.messageActionWebViewDataSentMe | MessageAction.messageActionWebViewDataSent | MessageAction.messageActionGiftPremium | MessageAction.messageActionTopicCreate | MessageAction.messageActionTopicEdit | MessageAction.messageActionSuggestProfilePhoto | MessageAction.messageActionRequestedPeer | MessageAction.messageActionDiscussionStarted | MessageAction.messageActionChatLeave | MessageAction.messageActionChannelDeletePhoto | MessageAction.messageActionChannelEditTitle | MessageAction.messageActionChannelEditPhoto | MessageAction.messageActionChannelEditVideo | MessageAction.messageActionChatEditVideo | MessageAction.messageActionChatAddUsers | MessageAction.messageActionChatJoined | MessageAction.messageActionChatReturn | MessageAction.messageActionChatJoinedYou | MessageAction.messageActionChatReturnYou;
export namespace MessageAction { export namespace MessageAction {
export type messageActionEmpty = { export type messageActionEmpty = {
@ -1195,7 +1195,12 @@ export namespace MessageAction {
export type messageActionBotAllowed = { export type messageActionBotAllowed = {
_: 'messageActionBotAllowed', _: 'messageActionBotAllowed',
domain: string flags?: number,
pFlags: Partial<{
attach_menu?: true,
}>,
domain?: string,
app?: BotApp
}; };
export type messageActionSecureValuesSentMe = { export type messageActionSecureValuesSentMe = {
@ -1295,10 +1300,6 @@ export namespace MessageAction {
photo: Photo photo: Photo
}; };
export type messageActionAttachMenuBotAllowed = {
_: 'messageActionAttachMenuBotAllowed'
};
export type messageActionRequestedPeer = { export type messageActionRequestedPeer = {
_: 'messageActionRequestedPeer', _: 'messageActionRequestedPeer',
button_id: number, button_id: number,
@ -2102,7 +2103,7 @@ export namespace MessagesFilter {
/** /**
* @link https://core.telegram.org/type/Update * @link https://core.telegram.org/type/Update
*/ */
export type Update = Update.updateNewMessage | Update.updateMessageID | Update.updateDeleteMessages | Update.updateUserTyping | Update.updateChatUserTyping | Update.updateChatParticipants | Update.updateUserStatus | Update.updateUserName | Update.updateNewEncryptedMessage | Update.updateEncryptedChatTyping | Update.updateEncryption | Update.updateEncryptedMessagesRead | Update.updateChatParticipantAdd | Update.updateChatParticipantDelete | Update.updateDcOptions | Update.updateNotifySettings | Update.updateServiceNotification | Update.updatePrivacy | Update.updateUserPhone | Update.updateReadHistoryInbox | Update.updateReadHistoryOutbox | Update.updateWebPage | Update.updateReadMessagesContents | Update.updateChannelTooLong | Update.updateChannel | Update.updateNewChannelMessage | Update.updateReadChannelInbox | Update.updateDeleteChannelMessages | Update.updateChannelMessageViews | Update.updateChatParticipantAdmin | Update.updateNewStickerSet | Update.updateStickerSetsOrder | Update.updateStickerSets | Update.updateSavedGifs | Update.updateBotInlineQuery | Update.updateBotInlineSend | Update.updateEditChannelMessage | Update.updateBotCallbackQuery | Update.updateEditMessage | Update.updateInlineBotCallbackQuery | Update.updateReadChannelOutbox | Update.updateDraftMessage | Update.updateReadFeaturedStickers | Update.updateRecentStickers | Update.updateConfig | Update.updatePtsChanged | Update.updateChannelWebPage | Update.updateDialogPinned | Update.updatePinnedDialogs | Update.updateBotWebhookJSON | Update.updateBotWebhookJSONQuery | Update.updateBotShippingQuery | Update.updateBotPrecheckoutQuery | Update.updatePhoneCall | Update.updateLangPackTooLong | Update.updateLangPack | Update.updateFavedStickers | Update.updateChannelReadMessagesContents | Update.updateContactsReset | Update.updateChannelAvailableMessages | Update.updateDialogUnreadMark | Update.updateMessagePoll | Update.updateChatDefaultBannedRights | Update.updateFolderPeers | Update.updatePeerSettings | Update.updatePeerLocated | Update.updateNewScheduledMessage | Update.updateDeleteScheduledMessages | Update.updateTheme | Update.updateGeoLiveViewed | Update.updateLoginToken | Update.updateMessagePollVote | Update.updateDialogFilter | Update.updateDialogFilterOrder | Update.updateDialogFilters | Update.updatePhoneCallSignalingData | Update.updateChannelMessageForwards | Update.updateReadChannelDiscussionInbox | Update.updateReadChannelDiscussionOutbox | Update.updatePeerBlocked | Update.updateChannelUserTyping | Update.updatePinnedMessages | Update.updatePinnedChannelMessages | Update.updateChat | Update.updateGroupCallParticipants | Update.updateGroupCall | Update.updatePeerHistoryTTL | Update.updateChatParticipant | Update.updateChannelParticipant | Update.updateBotStopped | Update.updateGroupCallConnection | Update.updateBotCommands | Update.updatePendingJoinRequests | Update.updateBotChatInviteRequester | Update.updateMessageReactions | Update.updateAttachMenuBots | Update.updateWebViewResultSent | Update.updateBotMenuButton | Update.updateSavedRingtones | Update.updateTranscribedAudio | Update.updateReadFeaturedEmojiStickers | Update.updateUserEmojiStatus | Update.updateRecentEmojiStatuses | Update.updateRecentReactions | Update.updateMoveStickerSetToTop | Update.updateMessageExtendedMedia | Update.updateChannelPinnedTopic | Update.updateChannelPinnedTopics | Update.updateUser | Update.updateAutoSaveSettings | Update.updateNewDiscussionMessage | Update.updateDeleteDiscussionMessages | Update.updateChannelReload; export type Update = Update.updateNewMessage | Update.updateMessageID | Update.updateDeleteMessages | Update.updateUserTyping | Update.updateChatUserTyping | Update.updateChatParticipants | Update.updateUserStatus | Update.updateUserName | Update.updateNewEncryptedMessage | Update.updateEncryptedChatTyping | Update.updateEncryption | Update.updateEncryptedMessagesRead | Update.updateChatParticipantAdd | Update.updateChatParticipantDelete | Update.updateDcOptions | Update.updateNotifySettings | Update.updateServiceNotification | Update.updatePrivacy | Update.updateUserPhone | Update.updateReadHistoryInbox | Update.updateReadHistoryOutbox | Update.updateWebPage | Update.updateReadMessagesContents | Update.updateChannelTooLong | Update.updateChannel | Update.updateNewChannelMessage | Update.updateReadChannelInbox | Update.updateDeleteChannelMessages | Update.updateChannelMessageViews | Update.updateChatParticipantAdmin | Update.updateNewStickerSet | Update.updateStickerSetsOrder | Update.updateStickerSets | Update.updateSavedGifs | Update.updateBotInlineQuery | Update.updateBotInlineSend | Update.updateEditChannelMessage | Update.updateBotCallbackQuery | Update.updateEditMessage | Update.updateInlineBotCallbackQuery | Update.updateReadChannelOutbox | Update.updateDraftMessage | Update.updateReadFeaturedStickers | Update.updateRecentStickers | Update.updateConfig | Update.updatePtsChanged | Update.updateChannelWebPage | Update.updateDialogPinned | Update.updatePinnedDialogs | Update.updateBotWebhookJSON | Update.updateBotWebhookJSONQuery | Update.updateBotShippingQuery | Update.updateBotPrecheckoutQuery | Update.updatePhoneCall | Update.updateLangPackTooLong | Update.updateLangPack | Update.updateFavedStickers | Update.updateChannelReadMessagesContents | Update.updateContactsReset | Update.updateChannelAvailableMessages | Update.updateDialogUnreadMark | Update.updateMessagePoll | Update.updateChatDefaultBannedRights | Update.updateFolderPeers | Update.updatePeerSettings | Update.updatePeerLocated | Update.updateNewScheduledMessage | Update.updateDeleteScheduledMessages | Update.updateTheme | Update.updateGeoLiveViewed | Update.updateLoginToken | Update.updateMessagePollVote | Update.updateDialogFilter | Update.updateDialogFilterOrder | Update.updateDialogFilters | Update.updatePhoneCallSignalingData | Update.updateChannelMessageForwards | Update.updateReadChannelDiscussionInbox | Update.updateReadChannelDiscussionOutbox | Update.updatePeerBlocked | Update.updateChannelUserTyping | Update.updatePinnedMessages | Update.updatePinnedChannelMessages | Update.updateChat | Update.updateGroupCallParticipants | Update.updateGroupCall | Update.updatePeerHistoryTTL | Update.updateChatParticipant | Update.updateChannelParticipant | Update.updateBotStopped | Update.updateGroupCallConnection | Update.updateBotCommands | Update.updatePendingJoinRequests | Update.updateBotChatInviteRequester | Update.updateMessageReactions | Update.updateAttachMenuBots | Update.updateWebViewResultSent | Update.updateBotMenuButton | Update.updateSavedRingtones | Update.updateTranscribedAudio | Update.updateReadFeaturedEmojiStickers | Update.updateUserEmojiStatus | Update.updateRecentEmojiStatuses | Update.updateRecentReactions | Update.updateMoveStickerSetToTop | Update.updateMessageExtendedMedia | Update.updateChannelPinnedTopic | Update.updateChannelPinnedTopics | Update.updateUser | Update.updateAutoSaveSettings | Update.updateGroupInvitePrivacyForbidden | Update.updateNewDiscussionMessage | Update.updateDeleteDiscussionMessages | Update.updateChannelReload;
export namespace Update { export namespace Update {
export type updateNewMessage = { export type updateNewMessage = {
@ -2888,6 +2889,11 @@ export namespace Update {
_: 'updateAutoSaveSettings' _: 'updateAutoSaveSettings'
}; };
export type updateGroupInvitePrivacyForbidden = {
_: 'updateGroupInvitePrivacyForbidden',
user_id: string | number
};
export type updateNewDiscussionMessage = { export type updateNewDiscussionMessage = {
_: 'updateNewDiscussionMessage', _: 'updateNewDiscussionMessage',
message?: Message message?: Message
@ -3145,13 +3151,10 @@ export namespace Config {
_: 'config', _: 'config',
flags?: number, flags?: number,
pFlags: Partial<{ pFlags: Partial<{
phonecalls_enabled?: true,
default_p2p_contacts?: true, default_p2p_contacts?: true,
preload_featured_stickers?: true, preload_featured_stickers?: true,
ignore_phone_entities?: true,
revoke_pm_inbox?: true, revoke_pm_inbox?: true,
blocked_mode?: true, blocked_mode?: true,
pfs_enabled?: true,
force_try_ipv6?: true, force_try_ipv6?: true,
}>, }>,
date: number, date: number,
@ -3171,17 +3174,13 @@ export namespace Config {
notify_default_delay_ms: number, notify_default_delay_ms: number,
push_chat_period_ms: number, push_chat_period_ms: number,
push_chat_limit: number, push_chat_limit: number,
saved_gifs_limit: number,
edit_time_limit: number, edit_time_limit: number,
revoke_time_limit: number, revoke_time_limit: number,
revoke_pm_time_limit: number, revoke_pm_time_limit: number,
rating_e_decay: number, rating_e_decay: number,
stickers_recent_limit: number, stickers_recent_limit: number,
stickers_faved_limit: number,
channels_read_media_period: number, channels_read_media_period: number,
tmp_sessions?: number, tmp_sessions?: number,
pinned_dialogs_count_max: number,
pinned_infolder_count_max: number,
call_receive_timeout_ms: number, call_receive_timeout_ms: number,
call_ring_timeout_ms: number, call_ring_timeout_ms: number,
call_connect_timeout_ms: number, call_connect_timeout_ms: number,
@ -3198,7 +3197,8 @@ export namespace Config {
suggested_lang_code?: string, suggested_lang_code?: string,
lang_pack_version?: number, lang_pack_version?: number,
base_lang_pack_version?: number, base_lang_pack_version?: number,
reactions_default?: Reaction reactions_default?: Reaction,
autologin_token?: string
}; };
} }
@ -5231,6 +5231,7 @@ export namespace MessagesBotResults {
query_id: string | number, query_id: string | number,
next_offset?: string, next_offset?: string,
switch_pm?: InlineBotSwitchPM, switch_pm?: InlineBotSwitchPM,
switch_webview?: InlineBotWebView,
results: Array<BotInlineResult>, results: Array<BotInlineResult>,
cache_time: number, cache_time: number,
users: Array<User> users: Array<User>
@ -6462,7 +6463,8 @@ export namespace InputStickerSetItem {
flags?: number, flags?: number,
document: InputDocument, document: InputDocument,
emoji: string, emoji: string,
mask_coords?: MaskCoords mask_coords?: MaskCoords,
keywords?: string
}; };
} }
@ -9629,7 +9631,9 @@ export namespace SponsoredMessage {
channel_post?: number, channel_post?: number,
start_param?: string, start_param?: string,
message: string, message: string,
entities?: Array<MessageEntity> entities?: Array<MessageEntity>,
sponsor_info?: string,
additional_info?: string
}; };
} }
@ -9879,6 +9883,7 @@ export namespace MessagePeerReaction {
unread?: true, unread?: true,
}>, }>,
peer_id: Peer, peer_id: Peer,
date: number,
reaction: Reaction reaction: Reaction
}; };
} }
@ -10264,19 +10269,6 @@ export namespace PaymentFormMethod {
}; };
} }
/**
* @link https://core.telegram.org/type/bots.PremiumGiftsOptions
*/
export type BotsPremiumGiftsOptions = BotsPremiumGiftsOptions.botsPremiumGiftsOptions;
export namespace BotsPremiumGiftsOptions {
export type botsPremiumGiftsOptions = {
_: 'bots.premiumGiftsOptions',
name: string,
gifts: Array<PremiumGiftOption>
};
}
/** /**
* @link https://core.telegram.org/type/EmojiStatus * @link https://core.telegram.org/type/EmojiStatus
*/ */
@ -10773,6 +10765,121 @@ export namespace AccountAutoSaveSettings {
}; };
} }
/**
* @link https://core.telegram.org/type/help.AppConfig
*/
export type HelpAppConfig = HelpAppConfig.helpAppConfigNotModified | HelpAppConfig.helpAppConfig;
export namespace HelpAppConfig {
export type helpAppConfigNotModified = {
_: 'help.appConfigNotModified'
};
export type helpAppConfig = {
_: 'help.appConfig',
hash: number,
config: JSONValue
};
}
/**
* @link https://core.telegram.org/type/InputBotApp
*/
export type InputBotApp = InputBotApp.inputBotAppID | InputBotApp.inputBotAppShortName;
export namespace InputBotApp {
export type inputBotAppID = {
_: 'inputBotAppID',
id: string | number,
access_hash: string | number
};
export type inputBotAppShortName = {
_: 'inputBotAppShortName',
bot_id: InputUser,
short_name: string
};
}
/**
* @link https://core.telegram.org/type/BotApp
*/
export type BotApp = BotApp.botAppNotModified | BotApp.botApp;
export namespace BotApp {
export type botAppNotModified = {
_: 'botAppNotModified'
};
export type botApp = {
_: 'botApp',
flags?: number,
id: string | number,
access_hash: string | number,
short_name: string,
title: string,
description: string,
photo: Photo,
document?: Document,
hash: string | number
};
}
/**
* @link https://core.telegram.org/type/messages.BotApp
*/
export type MessagesBotApp = MessagesBotApp.messagesBotApp;
export namespace MessagesBotApp {
export type messagesBotApp = {
_: 'messages.botApp',
flags?: number,
pFlags: Partial<{
inactive?: true,
request_write_access?: true,
}>,
app: BotApp
};
}
/**
* @link https://core.telegram.org/type/AppWebViewResult
*/
export type AppWebViewResult = AppWebViewResult.appWebViewResultUrl;
export namespace AppWebViewResult {
export type appWebViewResultUrl = {
_: 'appWebViewResultUrl',
url: string
};
}
/**
* @link https://core.telegram.org/type/InlineBotWebView
*/
export type InlineBotWebView = InlineBotWebView.inlineBotWebView;
export namespace InlineBotWebView {
export type inlineBotWebView = {
_: 'inlineBotWebView',
text: string,
url: string
};
}
/**
* @link https://core.telegram.org/type/ReadParticipantDate
*/
export type ReadParticipantDate = ReadParticipantDate.readParticipantDate;
export namespace ReadParticipantDate {
export type readParticipantDate = {
_: 'readParticipantDate',
user_id: string | number,
date: number
};
}
export interface ConstructorDeclMap { export interface ConstructorDeclMap {
'error': Error.error, 'error': Error.error,
'inputPeerEmpty': InputPeer.inputPeerEmpty, 'inputPeerEmpty': InputPeer.inputPeerEmpty,
@ -11779,7 +11886,6 @@ export interface ConstructorDeclMap {
'privacyKeyVoiceMessages': PrivacyKey.privacyKeyVoiceMessages, 'privacyKeyVoiceMessages': PrivacyKey.privacyKeyVoiceMessages,
'paymentFormMethod': PaymentFormMethod.paymentFormMethod, 'paymentFormMethod': PaymentFormMethod.paymentFormMethod,
'inputWebFileAudioAlbumThumbLocation': InputWebFileLocation.inputWebFileAudioAlbumThumbLocation, 'inputWebFileAudioAlbumThumbLocation': InputWebFileLocation.inputWebFileAudioAlbumThumbLocation,
'bots.premiumGiftsOptions': BotsPremiumGiftsOptions.botsPremiumGiftsOptions,
'emojiStatusEmpty': EmojiStatus.emojiStatusEmpty, 'emojiStatusEmpty': EmojiStatus.emojiStatusEmpty,
'emojiStatus': EmojiStatus.emojiStatus, 'emojiStatus': EmojiStatus.emojiStatus,
'emojiStatusUntil': EmojiStatus.emojiStatusUntil, 'emojiStatusUntil': EmojiStatus.emojiStatusUntil,
@ -11839,7 +11945,6 @@ export interface ConstructorDeclMap {
'exportedContactToken': ExportedContactToken.exportedContactToken, 'exportedContactToken': ExportedContactToken.exportedContactToken,
'channelAdminLogEventActionToggleAntiSpam': ChannelAdminLogEventAction.channelAdminLogEventActionToggleAntiSpam, 'channelAdminLogEventActionToggleAntiSpam': ChannelAdminLogEventAction.channelAdminLogEventActionToggleAntiSpam,
'messageActionSuggestProfilePhoto': MessageAction.messageActionSuggestProfilePhoto, 'messageActionSuggestProfilePhoto': MessageAction.messageActionSuggestProfilePhoto,
'messageActionAttachMenuBotAllowed': MessageAction.messageActionAttachMenuBotAllowed,
'stickerSetNoCovered': StickerSetCovered.stickerSetNoCovered, 'stickerSetNoCovered': StickerSetCovered.stickerSetNoCovered,
'updateUser': Update.updateUser, 'updateUser': Update.updateUser,
'auth.sentCodeSuccess': AuthSentCode.authSentCodeSuccess, 'auth.sentCodeSuccess': AuthSentCode.authSentCodeSuccess,
@ -11862,6 +11967,17 @@ export interface ConstructorDeclMap {
'autoSaveException': AutoSaveException.autoSaveException, 'autoSaveException': AutoSaveException.autoSaveException,
'account.autoSaveSettings': AccountAutoSaveSettings.accountAutoSaveSettings, 'account.autoSaveSettings': AccountAutoSaveSettings.accountAutoSaveSettings,
'updateAutoSaveSettings': Update.updateAutoSaveSettings, 'updateAutoSaveSettings': Update.updateAutoSaveSettings,
'help.appConfigNotModified': HelpAppConfig.helpAppConfigNotModified,
'help.appConfig': HelpAppConfig.helpAppConfig,
'inputBotAppID': InputBotApp.inputBotAppID,
'inputBotAppShortName': InputBotApp.inputBotAppShortName,
'botAppNotModified': BotApp.botAppNotModified,
'botApp': BotApp.botApp,
'messages.botApp': MessagesBotApp.messagesBotApp,
'appWebViewResultUrl': AppWebViewResult.appWebViewResultUrl,
'inlineBotWebView': InlineBotWebView.inlineBotWebView,
'readParticipantDate': ReadParticipantDate.readParticipantDate,
'updateGroupInvitePrivacyForbidden': Update.updateGroupInvitePrivacyForbidden,
'messageEntityEmoji': MessageEntity.messageEntityEmoji, 'messageEntityEmoji': MessageEntity.messageEntityEmoji,
'messageEntityHighlight': MessageEntity.messageEntityHighlight, 'messageEntityHighlight': MessageEntity.messageEntityHighlight,
'messageEntityLinebreak': MessageEntity.messageEntityLinebreak, 'messageEntityLinebreak': MessageEntity.messageEntityLinebreak,
@ -12721,7 +12837,8 @@ export type MessagesSetInlineBotResults = {
results: Array<InputBotInlineResult>, results: Array<InputBotInlineResult>,
cache_time: number, cache_time: number,
next_offset?: string, next_offset?: string,
switch_pm?: InlineBotSwitchPM switch_pm?: InlineBotSwitchPM,
switch_webview?: InlineBotWebView
}; };
export type MessagesSendInlineBotResult = { export type MessagesSendInlineBotResult = {
@ -13430,7 +13547,7 @@ export type MessagesClearAllDrafts = {
}; };
export type HelpGetAppConfig = { export type HelpGetAppConfig = {
hash: number
}; };
export type HelpSaveAppLog = { export type HelpSaveAppLog = {
@ -13807,8 +13924,10 @@ export type StatsLoadAsyncGraph = {
}; };
export type StickersSetStickerSetThumb = { export type StickersSetStickerSetThumb = {
flags?: number,
stickerset: InputStickerSet, stickerset: InputStickerSet,
thumb: InputDocument thumb?: InputDocument,
thumb_document_id?: string | number
}; };
export type BotsSetBotCommands = { export type BotsSetBotCommands = {
@ -14366,6 +14485,7 @@ export type MessagesProlongWebView = {
export type MessagesRequestSimpleWebView = { export type MessagesRequestSimpleWebView = {
flags?: number, flags?: number,
from_switch_webview?: boolean,
bot: InputUser, bot: InputUser,
url: string, url: string,
theme_params?: DataJSON, theme_params?: DataJSON,
@ -14711,6 +14831,49 @@ export type AccountDeleteAutoSaveExceptions = {
}; };
export type StickersChangeSticker = {
flags?: number,
sticker: InputDocument,
emoji?: string,
mask_coords?: MaskCoords,
keywords?: string
};
export type StickersRenameStickerSet = {
stickerset: InputStickerSet,
title: string
};
export type StickersDeleteStickerSet = {
stickerset: InputStickerSet
};
export type MessagesGetBotApp = {
app: InputBotApp,
hash: string | number
};
export type MessagesRequestAppWebView = {
flags?: number,
write_allowed?: boolean,
peer: InputPeer,
app: InputBotApp,
start_param?: string,
theme_params?: DataJSON,
platform: string
};
export type BotsSetBotInfo = {
flags?: number,
lang_code: string,
about?: string,
description?: string
};
export type BotsGetBotInfo = {
lang_code: string
};
export interface MethodDeclMap { export interface MethodDeclMap {
'invokeAfterMsg': {req: InvokeAfterMsg, res: any}, 'invokeAfterMsg': {req: InvokeAfterMsg, res: any},
'invokeAfterMsgs': {req: InvokeAfterMsgs, res: any}, 'invokeAfterMsgs': {req: InvokeAfterMsgs, res: any},
@ -14971,7 +15134,7 @@ export interface MethodDeclMap {
'messages.getDialogUnreadMarks': {req: MessagesGetDialogUnreadMarks, res: Array<DialogPeer>}, 'messages.getDialogUnreadMarks': {req: MessagesGetDialogUnreadMarks, res: Array<DialogPeer>},
'contacts.toggleTopPeers': {req: ContactsToggleTopPeers, res: boolean}, 'contacts.toggleTopPeers': {req: ContactsToggleTopPeers, res: boolean},
'messages.clearAllDrafts': {req: MessagesClearAllDrafts, res: boolean}, 'messages.clearAllDrafts': {req: MessagesClearAllDrafts, res: boolean},
'help.getAppConfig': {req: HelpGetAppConfig, res: any}, 'help.getAppConfig': {req: HelpGetAppConfig, res: HelpAppConfig},
'help.saveAppLog': {req: HelpSaveAppLog, res: boolean}, 'help.saveAppLog': {req: HelpSaveAppLog, res: boolean},
'help.getPassportConfig': {req: HelpGetPassportConfig, res: HelpPassportConfig}, 'help.getPassportConfig': {req: HelpGetPassportConfig, res: HelpPassportConfig},
'langpack.getLanguage': {req: LangpackGetLanguage, res: LangPackLanguage}, 'langpack.getLanguage': {req: LangpackGetLanguage, res: LangPackLanguage},
@ -15107,7 +15270,7 @@ export interface MethodDeclMap {
'messages.setChatTheme': {req: MessagesSetChatTheme, res: Updates}, 'messages.setChatTheme': {req: MessagesSetChatTheme, res: Updates},
'channels.viewSponsoredMessage': {req: ChannelsViewSponsoredMessage, res: boolean}, 'channels.viewSponsoredMessage': {req: ChannelsViewSponsoredMessage, res: boolean},
'channels.getSponsoredMessages': {req: ChannelsGetSponsoredMessages, res: MessagesSponsoredMessages}, 'channels.getSponsoredMessages': {req: ChannelsGetSponsoredMessages, res: MessagesSponsoredMessages},
'messages.getMessageReadParticipants': {req: MessagesGetMessageReadParticipants, res: Array<string | number>}, 'messages.getMessageReadParticipants': {req: MessagesGetMessageReadParticipants, res: Array<ReadParticipantDate>},
'messages.getSearchResultsCalendar': {req: MessagesGetSearchResultsCalendar, res: MessagesSearchResultsCalendar}, 'messages.getSearchResultsCalendar': {req: MessagesGetSearchResultsCalendar, res: MessagesSearchResultsCalendar},
'messages.getSearchResultsPositions': {req: MessagesGetSearchResultsPositions, res: MessagesSearchResultsPositions}, 'messages.getSearchResultsPositions': {req: MessagesGetSearchResultsPositions, res: MessagesSearchResultsPositions},
'messages.hideChatJoinRequest': {req: MessagesHideChatJoinRequest, res: Updates}, 'messages.hideChatJoinRequest': {req: MessagesHideChatJoinRequest, res: Updates},
@ -15202,5 +15365,12 @@ export interface MethodDeclMap {
'account.getAutoSaveSettings': {req: AccountGetAutoSaveSettings, res: AccountAutoSaveSettings}, 'account.getAutoSaveSettings': {req: AccountGetAutoSaveSettings, res: AccountAutoSaveSettings},
'account.saveAutoSaveSettings': {req: AccountSaveAutoSaveSettings, res: boolean}, 'account.saveAutoSaveSettings': {req: AccountSaveAutoSaveSettings, res: boolean},
'account.deleteAutoSaveExceptions': {req: AccountDeleteAutoSaveExceptions, res: boolean}, 'account.deleteAutoSaveExceptions': {req: AccountDeleteAutoSaveExceptions, res: boolean},
'stickers.changeSticker': {req: StickersChangeSticker, res: MessagesStickerSet},
'stickers.renameStickerSet': {req: StickersRenameStickerSet, res: MessagesStickerSet},
'stickers.deleteStickerSet': {req: StickersDeleteStickerSet, res: boolean},
'messages.getBotApp': {req: MessagesGetBotApp, res: MessagesBotApp},
'messages.requestAppWebView': {req: MessagesRequestAppWebView, res: AppWebViewResult},
'bots.setBotInfo': {req: BotsSetBotInfo, res: boolean},
'bots.getBotInfo': {req: BotsGetBotInfo, res: Array<string>},
} }

View File

@ -27,7 +27,7 @@ import {MOUNT_CLASS_TO} from '../../config/debug';
import appNavigationController from '../../components/appNavigationController'; import appNavigationController from '../../components/appNavigationController';
import AppPrivateSearchTab from '../../components/sidebarRight/tabs/search'; import AppPrivateSearchTab from '../../components/sidebarRight/tabs/search';
import I18n, {i18n, join, LangPackKey} from '../langPack'; import I18n, {i18n, join, LangPackKey} from '../langPack';
import {ChatFull, ChatInvite, ChatParticipant, ChatParticipants, Message, MessageAction, MessageMedia, SendMessageAction, User, Chat as MTChat, UrlAuthResult, WallPaper} from '../../layer'; import {ChatFull, ChatInvite, ChatParticipant, ChatParticipants, Message, MessageAction, MessageMedia, SendMessageAction, User, Chat as MTChat, UrlAuthResult, WallPaper, Config} from '../../layer';
import PeerTitle from '../../components/peerTitle'; import PeerTitle from '../../components/peerTitle';
import PopupPeer, {PopupPeerCheckboxOptions} from '../../components/popups/peer'; import PopupPeer, {PopupPeerCheckboxOptions} from '../../components/popups/peer';
import blurActiveElement from '../../helpers/dom/blurActiveElement'; import blurActiveElement from '../../helpers/dom/blurActiveElement';
@ -970,11 +970,15 @@ export class AppImManager extends EventListenerBase<{
} }
private handleAutologinDomains() { private handleAutologinDomains() {
let appConfig: MTAppConfig; let appConfig: MTAppConfig, config: Config.config;
rootScope.addEventListener('app_config', (_appConfig) => { rootScope.addEventListener('app_config', (_appConfig) => {
appConfig = _appConfig; appConfig = _appConfig;
}); });
rootScope.addEventListener('config', (_config) => {
config = _config;
});
const onAnchorClick = (element: HTMLAnchorElement) => { const onAnchorClick = (element: HTMLAnchorElement) => {
const url = new URL(element.href); const url = new URL(element.href);
if(appConfig.url_auth_domains.includes(url.hostname)) { if(appConfig.url_auth_domains.includes(url.hostname)) {
@ -983,13 +987,15 @@ export class AppImManager extends EventListenerBase<{
return; return;
} }
if(!appConfig.autologin_token || !appConfig.autologin_domains) { const autologinToken = config.autologin_token;
if(!autologinToken || !appConfig.autologin_domains) {
return; return;
} }
const originalUrl = element.dataset.originalUrl ??= element.href; const originalUrl = element.dataset.originalUrl ??= element.href;
if(appConfig.autologin_domains.includes(url.hostname)) { if(appConfig.autologin_domains.includes(url.hostname)) {
url.searchParams.set('autologin_token', appConfig.autologin_token); url.searchParams.set('autologin_token', autologinToken);
element.href = url.toString(); element.href = url.toString();
setTimeout(() => { setTimeout(() => {

View File

@ -17,7 +17,7 @@ import LazyLoadQueueBase from '../../components/lazyLoadQueueBase';
import deferredPromise, {CancellablePromise} from '../../helpers/cancellablePromise'; import deferredPromise, {CancellablePromise} from '../../helpers/cancellablePromise';
import tsNow from '../../helpers/tsNow'; import tsNow from '../../helpers/tsNow';
import {randomLong} from '../../helpers/random'; import {randomLong} from '../../helpers/random';
import {Chat, ChatFull, Dialog as MTDialog, DialogPeer, DocumentAttribute, InputMedia, InputMessage, InputPeerNotifySettings, InputSingleMedia, Message, MessageAction, MessageEntity, MessageFwdHeader, MessageMedia, MessageReplies, MessageReplyHeader, MessagesDialogs, MessagesFilter, MessagesMessages, MethodDeclMap, NotifyPeer, PeerNotifySettings, PhotoSize, SendMessageAction, Update, Photo, Updates, ReplyMarkup, InputPeer, InputPhoto, InputDocument, InputGeoPoint, WebPage, GeoPoint, ReportReason, MessagesGetDialogs, InputChannel, InputDialogPeer, ReactionCount, MessagePeerReaction, MessagesSearchCounter, Peer, MessageReactions, Document, InputFile, Reaction, ForumTopic as MTForumTopic, MessagesForumTopics, MessagesGetReplies, MessagesGetHistory, MessagesAffectedHistory, UrlAuthResult, MessagesTranscribedAudio} from '../../layer'; import {Chat, ChatFull, Dialog as MTDialog, DialogPeer, DocumentAttribute, InputMedia, InputMessage, InputPeerNotifySettings, InputSingleMedia, Message, MessageAction, MessageEntity, MessageFwdHeader, MessageMedia, MessageReplies, MessageReplyHeader, MessagesDialogs, MessagesFilter, MessagesMessages, MethodDeclMap, NotifyPeer, PeerNotifySettings, PhotoSize, SendMessageAction, Update, Photo, Updates, ReplyMarkup, InputPeer, InputPhoto, InputDocument, InputGeoPoint, WebPage, GeoPoint, ReportReason, MessagesGetDialogs, InputChannel, InputDialogPeer, ReactionCount, MessagePeerReaction, MessagesSearchCounter, Peer, MessageReactions, Document, InputFile, Reaction, ForumTopic as MTForumTopic, MessagesForumTopics, MessagesGetReplies, MessagesGetHistory, MessagesAffectedHistory, UrlAuthResult, MessagesTranscribedAudio, ReadParticipantDate} from '../../layer';
import {ArgumentTypes, InvokeApiOptions} from '../../types'; import {ArgumentTypes, InvokeApiOptions} from '../../types';
import {logger, LogTypes} from '../logger'; import {logger, LogTypes} from '../logger';
import {ReferenceContext} from '../mtproto/referenceDatabase'; import {ReferenceContext} from '../mtproto/referenceDatabase';
@ -5587,45 +5587,51 @@ export class AppMessagesManager extends AppManager {
}; };
const canViewMessageReadParticipants = await this.canViewMessageReadParticipants(message); const canViewMessageReadParticipants = await this.canViewMessageReadParticipants(message);
if(canViewMessageReadParticipants && limit === undefined) { limit ??= canViewMessageReadParticipants ? 100 : 50;
limit = 100;
} else if(limit === undefined) {
limit = 50;
}
return Promise.all([ return Promise.all([
canViewMessageReadParticipants && !reaction && !skipReadParticipants ? this.getMessageReadParticipants(message.peerId, message.mid).catch(() => [] as UserId[]) : [] as UserId[], canViewMessageReadParticipants && !reaction && !skipReadParticipants ? this.getMessageReadParticipants(message.peerId, message.mid).catch(() => [] as ReadParticipantDate[]) : [] as ReadParticipantDate[],
message.reactions?.recent_reactions?.length && !skipReactionsList ? this.appReactionsManager.getMessageReactionsList(message.peerId, message.mid, limit, reaction, offset).catch((err) => emptyMessageReactionsList) : emptyMessageReactionsList message.reactions?.recent_reactions?.length && !skipReactionsList ? this.appReactionsManager.getMessageReactionsList(message.peerId, message.mid, limit, reaction, offset).catch((err) => emptyMessageReactionsList) : emptyMessageReactionsList
]).then(([userIds, messageReactionsList]) => { ]).then(([readParticipantDates, messageReactionsList]) => {
const readParticipantsPeerIds = userIds.map((userId) => userId.toPeerId()); const filteredReadParticipants = readParticipantDates.slice();
forEachReverse(filteredReadParticipants, ({user_id}, idx, arr) => {
const filteredReadParticipants = readParticipantsPeerIds.slice(); if(messageReactionsList.reactions.some((reaction) => this.appPeersManager.getPeerId(reaction.peer_id) === user_id.toPeerId())) {
forEachReverse(filteredReadParticipants, (peerId, idx, arr) => {
if(messageReactionsList.reactions.some((reaction) => this.appPeersManager.getPeerId(reaction.peer_id) === peerId)) {
arr.splice(idx, 1); arr.splice(idx, 1);
} }
}); });
let combined: {peerId: PeerId, reaction?: Reaction}[] = messageReactionsList.reactions.map((reaction) => ({peerId: this.appPeersManager.getPeerId(reaction.peer_id), reaction: reaction.reaction})); let combined: {
combined = combined.concat(filteredReadParticipants.map((readPeerId) => ({peerId: readPeerId}))); peerId: PeerId,
date?: number,
reaction?: Reaction
}[] = messageReactionsList.reactions.map((reaction) => {
return {
peerId: this.appPeersManager.getPeerId(reaction.peer_id),
reaction: reaction.reaction,
date: reaction.date
};
});
combined = combined.concat(filteredReadParticipants.map(({user_id, date}) => ({date, peerId: user_id.toPeerId()})));
return { return {
reactions: messageReactionsList.reactions, reactions: messageReactionsList.reactions,
reactionsCount: messageReactionsList.count, reactionsCount: messageReactionsList.count,
readParticipants: readParticipantsPeerIds, readParticipantDates: readParticipantDates,
combined: combined, combined: combined,
nextOffset: messageReactionsList.next_offset nextOffset: messageReactionsList.next_offset
}; };
}); });
} }
public getMessageReadParticipants(peerId: PeerId, mid: number): Promise<UserId[]> { public getMessageReadParticipants(peerId: PeerId, mid: number) {
return this.apiManager.invokeApiSingle('messages.getMessageReadParticipants', { return this.apiManager.invokeApiSingle('messages.getMessageReadParticipants', {
peer: this.appPeersManager.getInputPeerById(peerId), peer: this.appPeersManager.getInputPeerById(peerId),
msg_id: getServerMessageId(mid) msg_id: getServerMessageId(mid)
}).then((userIds) => { // ! convert long to number }).then((readParticipantDates) => { // ! convert long to number
return userIds.map((userId) => userId.toUserId()); readParticipantDates.forEach((readParticipantDate) => readParticipantDate.user_id = readParticipantDate.user_id.toUserId());
return readParticipantDates;
}); });
} }

View File

@ -11,6 +11,7 @@ import callbackify from '../../helpers/callbackify';
import callbackifyAll from '../../helpers/callbackifyAll'; import callbackifyAll from '../../helpers/callbackifyAll';
import copy from '../../helpers/object/copy'; import copy from '../../helpers/object/copy';
import pause from '../../helpers/schedulers/pause'; import pause from '../../helpers/schedulers/pause';
import tsNow from '../../helpers/tsNow';
import {AvailableReaction, Message, MessagePeerReaction, MessagesAvailableReactions, Reaction, ReactionCount, Update, Updates} from '../../layer'; import {AvailableReaction, Message, MessagePeerReaction, MessagesAvailableReactions, Reaction, ReactionCount, Update, Updates} from '../../layer';
import {ReferenceContext} from '../mtproto/referenceDatabase'; import {ReferenceContext} from '../mtproto/referenceDatabase';
import {AppManager} from './manager'; import {AppManager} from './manager';
@ -345,7 +346,8 @@ export class AppReactionsManager extends AppManager {
_: 'messagePeerReaction', _: 'messagePeerReaction',
reaction, reaction,
peer_id: this.appPeersManager.getOutputPeer(myPeerId), peer_id: this.appPeersManager.getOutputPeer(myPeerId),
pFlags: {} pFlags: {},
date: tsNow(true)
}; };
if(!this.appPeersManager.isMegagroup(peerId) && false) { if(!this.appPeersManager.isMegagroup(peerId) && false) {

View File

@ -104,7 +104,7 @@ export class ApiManager extends ApiManagerMethods {
// * https://core.telegram.org/api/url-authorization // * https://core.telegram.org/api/url-authorization
const REFRESH_APP_CONFIG_INTERVAL = (10000 - 30) * 1000; const REFRESH_APP_CONFIG_INTERVAL = (10000 - 30) * 1000;
setInterval(() => { setInterval(() => {
this.getAppConfig(true); this.getConfig(true);
}, REFRESH_APP_CONFIG_INTERVAL); }, REFRESH_APP_CONFIG_INTERVAL);
} }

View File

@ -5,9 +5,10 @@
*/ */
import ctx from '../../environment/ctx'; import ctx from '../../environment/ctx';
import assumeType from '../../helpers/assumeType';
import callbackify from '../../helpers/callbackify'; import callbackify from '../../helpers/callbackify';
import {ignoreRestrictionReasons} from '../../helpers/restrictions'; import {ignoreRestrictionReasons} from '../../helpers/restrictions';
import {Config, MethodDeclMap, User} from '../../layer'; import {Config, HelpAppConfig, MethodDeclMap, User} from '../../layer';
import {InvokeApiOptions} from '../../types'; import {InvokeApiOptions} from '../../types';
import {AppManager} from '../appManagers/manager'; import {AppManager} from '../appManagers/manager';
import {MTAppConfig} from './appConfig'; import {MTAppConfig} from './appConfig';
@ -283,8 +284,12 @@ export default abstract class ApiManagerMethods extends AppManager {
return this.invokeApiSingleProcess({ return this.invokeApiSingleProcess({
method: 'help.getAppConfig', method: 'help.getAppConfig',
params: {}, params: {
processResult: (config: MTAppConfig) => { hash: 0
},
processResult: (helpAppConfig) => {
assumeType<HelpAppConfig.helpAppConfig>(helpAppConfig);
const config = helpAppConfig.config as MTAppConfig;
this.appConfig = config; this.appConfig = config;
ignoreRestrictionReasons(config.ignore_restriction_reasons ?? []); ignoreRestrictionReasons(config.ignore_restriction_reasons ?? []);
this.rootScope.dispatchEvent('app_config', config); this.rootScope.dispatchEvent('app_config', config);

View File

@ -1,9 +1,7 @@
export interface MTAppConfig { export interface MTAppConfig {
test?: number; test?: number;
emojies_animated_zoom?: number; emojies_animated_zoom?: number;
emojies_send_dice?: string[]; emojies_send_dice?: any[];
emojies_send_dice_success?: EmojiesSendDiceSuccess;
emojies_sounds?: EmojiesSoundsClass;
gif_search_branding?: string; gif_search_branding?: string;
gif_search_emojies?: string[]; gif_search_emojies?: string[];
stickers_emoji_suggest_only_api?: boolean; stickers_emoji_suggest_only_api?: boolean;
@ -12,15 +10,10 @@ export interface MTAppConfig {
youtube_pip?: string; youtube_pip?: string;
qr_login_camera?: boolean; qr_login_camera?: boolean;
qr_login_code?: string; qr_login_code?: string;
reactions_in_chat_max?: number;
reactions_user_max_default?: number;
reactions_user_max_premium?: number;
dialog_filters_enabled?: boolean; dialog_filters_enabled?: boolean;
dialog_filters_tooltip?: boolean; dialog_filters_tooltip?: boolean;
ignore_restriction_reasons?: string[];
autoarchive_setting_available?: boolean; autoarchive_setting_available?: boolean;
pending_suggestions?: any[]; pending_suggestions?: string[];
autologin_token?: string;
autologin_domains?: string[]; autologin_domains?: string[];
url_auth_domains?: string[]; url_auth_domains?: string[];
round_video_encoding?: RoundVideoEncoding; round_video_encoding?: RoundVideoEncoding;
@ -30,6 +23,7 @@ export interface MTAppConfig {
ringtone_duration_max?: number; ringtone_duration_max?: number;
ringtone_size_max?: number; ringtone_size_max?: number;
ringtone_saved_count_max?: number; ringtone_saved_count_max?: number;
premium_purchase_blocked?: boolean;
channels_limit_default?: number; channels_limit_default?: number;
channels_limit_premium?: number; channels_limit_premium?: number;
saved_gifs_limit_default?: number; saved_gifs_limit_default?: number;
@ -55,14 +49,32 @@ export interface MTAppConfig {
stickers_premium_by_emoji_num?: number; stickers_premium_by_emoji_num?: number;
stickers_normal_by_emoji_per_premium_num?: number; stickers_normal_by_emoji_per_premium_num?: number;
message_animated_emoji_max?: number; message_animated_emoji_max?: number;
reactions_user_max_default?: number;
reactions_user_max_premium?: number;
reactions_in_chat_max?: number;
default_emoji_statuses_stickerset_id?: string;
premium_promo_order?: string[]; premium_promo_order?: string[];
premium_bot_username?: string; premium_bot_username?: string;
premium_purchase_blocked?: boolean; premium_playmarket_direct_currency_list?: string[];
forum_upgrade_participants_min?: number; forum_upgrade_participants_min?: number;
fragment_prefixes?: string[]; whitelisted_domains?: string[];
telegram_antispam_group_size_min?: number; restriction_add_platforms?: string[];
telegram_antispam_user_id?: UserId;
topics_pinned_limit?: number; topics_pinned_limit?: number;
telegram_antispam_user_id?: string;
telegram_antispam_group_size_min?: number;
fragment_prefixes?: string[];
hidden_members_group_size_min?: number;
ios_disable_parallel_channel_reset?: number;
getfile_experimental_params?: boolean;
lite_battery_min_pct?: number;
lite_device_class?: number;
lite_app_options?: LiteAppOptions;
premium_gift_attach_menu_icon?: boolean;
premium_gift_text_field_icon?: boolean;
ignore_restriction_reasons?: string[];
emojies_send_dice?: string[];
emojies_send_dice_success?: EmojiesSendDiceSuccess;
emojies_sounds?: EmojiesSoundsClass;
} }
export interface EmojiesSendDiceSuccess { export interface EmojiesSendDiceSuccess {
@ -82,6 +94,11 @@ export interface EmojiSound {
file_reference_base64?: string; file_reference_base64?: string;
} }
export interface LiteAppOptions {
chat_open_animation_enabled?: boolean[];
video_autoplay_enabled?: boolean[];
}
export interface RoundVideoEncoding { export interface RoundVideoEncoding {
diameter?: number; diameter?: number;
video_bitrate?: number; video_bitrate?: number;

File diff suppressed because one or more lines are too long

View File

@ -317,7 +317,7 @@ export default class FiltersStorage extends AppManager {
} }
if(!wasPinned) { if(!wasPinned) {
if(filter.pinned_peers.length >= (await this.apiManager.getConfig()).pinned_infolder_count_max) { if(filter.pinned_peers.length >= (await this.apiManager.getLimit('folderPin'))) {
return Promise.reject(makeError('PINNED_DIALOGS_TOO_MUCH')); return Promise.reject(makeError('PINNED_DIALOGS_TOO_MUCH'));
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,7 @@
&-close { &-close {
margin-top: .375rem; margin-top: .375rem;
margin-right: .5rem; margin-inline-end: .5rem;
height: 40px; height: 40px;
order: -1; order: -1;
} }
@ -74,17 +74,24 @@
background-color: var(--surface-color); background-color: var(--surface-color);
} }
.reacted-list-reaction-icon { .reacted-list {
display: flex; &-reaction-icon {
width: var(--size); display: flex;
height: var(--size); width: var(--size);
position: absolute; height: var(--size);
top: 50%; position: absolute;
right: 1rem; top: 50%;
transform: translateY(-50%); inset-inline-end: 1rem;
transform: translateY(-50%);
}
&-checks {
margin-inline-end: .25rem;
font-size: 1.125rem;
}
} }
.chatlist-chat { .chatlist-chat {
padding-right: 3.25rem !important; padding-inline-end: 3.25rem !important;
} }
} }