diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index edd9e203e..156557043 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -118,6 +118,11 @@ interface Navigator { setAppBadge?(count: number): Promise; } +type Undefined = { + [K in keyof T]: undefined; +}; +type OptionalCombine = (A & B) | (A & Undefined); + // Fix to make Boolean() work as !! // https://github.com/microsoft/TypeScript/issues/16655 type Falsy = false | 0 | '' | null | undefined; diff --git a/src/api/gramjs/apiBuilders/bots.ts b/src/api/gramjs/apiBuilders/bots.ts index 3f284f8d0..9a1e645be 100644 --- a/src/api/gramjs/apiBuilders/bots.ts +++ b/src/api/gramjs/apiBuilders/bots.ts @@ -75,8 +75,12 @@ export function buildApiAttachBot(bot: GramJs.AttachMenuBot): ApiAttachBot { hasSettings: bot.hasSettings, shouldRequestWriteAccess: bot.requestWriteAccess, shortName: bot.shortName, - peerTypes: bot.peerTypes.map(buildApiAttachMenuPeerType), + isForAttachMenu: bot.showInAttachMenu!, + isForSideMenu: bot.showInSideMenu, + attachMenuPeerTypes: bot.peerTypes?.map(buildApiAttachMenuPeerType)!, icons: bot.icons.map(buildApiAttachMenuIcon).filter(Boolean), + isInactive: bot.inactive, + isDisclaimerNeeded: bot.sideMenuDisclaimerNeeded, }; } diff --git a/src/api/gramjs/methods/bots.ts b/src/api/gramjs/methods/bots.ts index 8abc86e5e..734a0696d 100644 --- a/src/api/gramjs/methods/bots.ts +++ b/src/api/gramjs/methods/bots.ts @@ -214,17 +214,28 @@ export async function requestWebView({ } export async function requestSimpleWebView({ - bot, url, theme, + bot, + url, + theme, + startParam, + isFromSwitchWebView, + isFromSideMenu, }: { bot: ApiUser; - url: string; + url?: string; theme?: ApiThemeParameters; + startParam?: string; + isFromSwitchWebView?: boolean; + isFromSideMenu?: boolean; }) { const result = await invokeRequest(new GramJs.messages.RequestSimpleWebView({ url, bot: buildInputPeer(bot.id, bot.accessHash), themeParams: theme ? buildInputThemeParams(theme) : undefined, platform: WEB_APP_PLATFORM, + startParam, + fromSwitchWebview: isFromSwitchWebView || undefined, + fromSideMenu: isFromSideMenu || undefined, })); return result?.url; diff --git a/src/api/gramjs/updater.ts b/src/api/gramjs/updater.ts index a0f28120a..caaba42e7 100644 --- a/src/api/gramjs/updater.ts +++ b/src/api/gramjs/updater.ts @@ -1104,6 +1104,10 @@ export function updater(update: Update) { '@type': 'updateStealthMode', stealthMode: buildApiStealthMode(update.stealthMode), }); + } else if (update instanceof GramJs.UpdateAttachMenuBots) { + onUpdate({ + '@type': 'updateAttachMenuBots', + }); } else if (DEBUG) { const params = typeof update === 'object' && 'className' in update ? update.className : update; log('UNEXPECTED UPDATE', params); diff --git a/src/api/types/updates.ts b/src/api/types/updates.ts index fd7a64775..80bec10b7 100644 --- a/src/api/types/updates.ts +++ b/src/api/types/updates.ts @@ -661,6 +661,10 @@ export type ApiRequestSync = { '@type': 'requestSync'; }; +export type ApiUpdateAttachMenuBots = { + '@type': 'updateAttachMenuBots'; +}; + export type ApiUpdate = ( ApiUpdateReady | ApiUpdateSession | ApiUpdateWebAuthTokenFailed | ApiUpdateRequestUserUpdate | ApiUpdateAuthorizationState | ApiUpdateAuthorizationError | ApiUpdateConnectionState | ApiUpdateCurrentUser | @@ -689,7 +693,7 @@ export type ApiUpdate = ( ApiUpdatePinnedTopicsOrder | ApiUpdateTopic | ApiUpdateTopics | ApiUpdateRecentEmojiStatuses | ApiUpdateRecentReactions | ApiUpdateStory | ApiUpdateReadStories | ApiUpdateDeleteStory | ApiUpdateSentStoryReaction | ApiRequestReconnectApi | ApiRequestSync | ApiUpdateFetchingDifference | ApiUpdateChannelMessages | - ApiUpdateStealthMode + ApiUpdateStealthMode | ApiUpdateAttachMenuBots ); export type OnApiUpdate = (update: ApiUpdate) => void; diff --git a/src/api/types/users.ts b/src/api/types/users.ts index e49767068..3ba7ee718 100644 --- a/src/api/types/users.ts +++ b/src/api/types/users.ts @@ -74,14 +74,23 @@ export interface ApiUsername { export type ApiChatType = typeof API_CHAT_TYPES[number]; export type ApiAttachMenuPeerType = 'self' | ApiChatType; -export interface ApiAttachBot { +type ApiAttachBotForMenu = { + isForAttachMenu: true; + attachMenuPeerTypes: ApiAttachMenuPeerType[]; +}; + +type ApiAttachBotBase = { id: string; hasSettings?: boolean; shouldRequestWriteAccess?: boolean; shortName: string; - peerTypes: ApiAttachMenuPeerType[]; + isForSideMenu?: true; + isDisclaimerNeeded?: boolean; icons: ApiAttachBotIcon[]; -} + isInactive?: boolean; +}; + +export type ApiAttachBot = OptionalCombine; export interface ApiAttachBotIcon { name: string; diff --git a/src/components/left/main/LeftMainHeader.tsx b/src/components/left/main/LeftMainHeader.tsx index db458161f..a5d46b377 100644 --- a/src/components/left/main/LeftMainHeader.tsx +++ b/src/components/left/main/LeftMainHeader.tsx @@ -4,28 +4,15 @@ import React, { } from '../../../lib/teact/teact'; import { getActions, withGlobal } from '../../../global'; -import type { GlobalState, TabState } from '../../../global/types'; -import type { AnimationLevel, ISettings } from '../../../types'; +import type { GlobalState } from '../../../global/types'; +import type { ISettings } from '../../../types'; import { LeftColumnContent, SettingsScreens } from '../../../types'; import { - ANIMATION_LEVEL_MAX, - ANIMATION_LEVEL_MIN, APP_NAME, - ARCHIVED_FOLDER_ID, - BETA_CHANGELOG_URL, DEBUG, - FEEDBACK_URL, IS_BETA, - IS_TEST, - PRODUCTION_HOSTNAME, - WEB_VERSION_BASE, } from '../../../config'; -import { - INITIAL_PERFORMANCE_STATE_MAX, - INITIAL_PERFORMANCE_STATE_MID, - INITIAL_PERFORMANCE_STATE_MIN, -} from '../../../global/initialState'; import { selectCanSetPasscode, selectCurrentMessageList, @@ -36,14 +23,12 @@ import { import buildClassName from '../../../util/buildClassName'; import captureEscKeyListener from '../../../util/captureEscKeyListener'; import { formatDateToString } from '../../../util/dateFormat'; -import { getPromptInstall } from '../../../util/installPrompt'; -import { switchPermanentWebVersion } from '../../../util/permanentWebVersion'; import { IS_APP, IS_ELECTRON, IS_MAC_OS } from '../../../util/windowEnvironment'; import useAppLayout from '../../../hooks/useAppLayout'; import useConnectionStatus from '../../../hooks/useConnectionStatus'; import useElectronDrag from '../../../hooks/useElectronDrag'; -import { useFolderManagerForUnreadCounters } from '../../../hooks/useFolderManager'; +import useFlag from '../../../hooks/useFlag'; import { useFullscreenStatus } from '../../../hooks/useFullscreen'; import { useHotkeys } from '../../../hooks/useHotkeys'; import useLang from '../../../hooks/useLang'; @@ -54,12 +39,10 @@ import PickerSelectedItem from '../../common/PickerSelectedItem'; import StoryToggler from '../../story/StoryToggler'; import Button from '../../ui/Button'; import DropdownMenu from '../../ui/DropdownMenu'; -import MenuItem from '../../ui/MenuItem'; import SearchInput from '../../ui/SearchInput'; import ShowTransition from '../../ui/ShowTransition'; -import Switcher from '../../ui/Switcher'; -import Toggle from '../../ui/Toggle'; import ConnectionStatusOverlay from '../ConnectionStatusOverlay'; +import LeftSideMenuItems from './LeftSideMenuItems'; import StatusButton from './StatusButton'; import './LeftMainHeader.scss'; @@ -71,21 +54,19 @@ type OwnProps = { isClosingSearch?: boolean; shouldSkipTransition?: boolean; onSearchQuery: (query: string) => void; - onSelectSettings: () => void; - onSelectContacts: () => void; - onSelectArchived: () => void; - onReset: () => void; + onSelectSettings: NoneToVoidFunction; + onSelectContacts: NoneToVoidFunction; + onSelectArchived: NoneToVoidFunction; + onReset: NoneToVoidFunction; }; type StateProps = { searchQuery?: string; isLoading: boolean; - currentUserId?: string; globalSearchChatId?: string; searchDate?: number; theme: ISettings['theme']; - animationLevel: AnimationLevel; isMessageListOpen: boolean; isCurrentUserPremium?: boolean; isConnectionStatusMinimized: ISettings['isConnectionStatusMinimized']; @@ -93,8 +74,7 @@ type StateProps = hasPasscode?: boolean; canSetPasscode?: boolean; } - & Pick - & Pick; + & Pick; const CLEAR_DATE_SEARCH_PARAM = { date: undefined }; const CLEAR_CHAT_SEARCH_PARAM = { id: undefined }; @@ -103,21 +83,14 @@ const LeftMainHeader: FC = ({ shouldHideSearch, content, contactsFilter, - onSearchQuery, isClosingSearch, - onSelectSettings, - onSelectContacts, - onSelectArchived, - onReset, searchQuery, isLoading, isCurrentUserPremium, shouldSkipTransition, - currentUserId, globalSearchChatId, searchDate, theme, - animationLevel, connectionState, isSyncing, isFetchingDifference, @@ -126,24 +99,25 @@ const LeftMainHeader: FC = ({ areChatsLoaded, hasPasscode, canSetPasscode, - canInstall, - archiveSettings, + onSearchQuery, + onSelectSettings, + onSelectContacts, + onSelectArchived, + onReset, }) => { const { - openChat, - openChatWithInfo, setGlobalSearchDate, setSettingOption, setGlobalSearchChatId, - openChatByUsername, lockScreen, requestNextSettingsScreen, - openUrl, - updatePerformanceSettings, } = getActions(); const lang = useLang(); const { isMobile } = useAppLayout(); + + const [isBotMenuOpen, markBotMenuOpen, unmarkBotMenuOpen] = useFlag(); + const hasMenu = content === LeftColumnContent.ChatList; const selectedSearchDate = useMemo(() => { return searchDate @@ -151,8 +125,6 @@ const LeftMainHeader: FC = ({ : undefined; }, [searchDate]); - const archivedUnreadChatsCount = useFolderManagerForUnreadCounters()[ARCHIVED_FOLDER_ID]?.chatsCount || 0; - const { connectionStatus, connectionStatusText, connectionStatusPosition } = useConnectionStatus( lang, connectionState, @@ -172,10 +144,6 @@ const LeftMainHeader: FC = ({ } }); - const handleOpenMyStories = useLastCallback(() => { - openChatWithInfo({ id: currentUserId, shouldReplaceHistory: true, profileTab: 'stories' }); - }); - useHotkeys(canSetPasscode ? { 'Ctrl+Shift+L': handleLockScreenHotkey, 'Alt+Shift+L': handleLockScreenHotkey, @@ -183,8 +151,6 @@ const LeftMainHeader: FC = ({ ...(IS_APP && { 'Mod+L': handleLockScreenHotkey }), } : undefined); - const withOtherVersions = window.location.hostname === PRODUCTION_HOSTNAME || IS_TEST; - const MainButton: FC<{ onTrigger: () => void; isOpen?: boolean }> = useMemo(() => { return ({ onTrigger, isOpen }) => ( diff --git a/src/config.ts b/src/config.ts index 2a4616b72..c3e40db49 100644 --- a/src/config.ts +++ b/src/config.ts @@ -51,7 +51,7 @@ export const CUSTOM_EMOJI_PREVIEW_CACHE_DISABLED = false; export const CUSTOM_EMOJI_PREVIEW_CACHE_NAME = 'tt-custom-emoji-preview'; export const MEDIA_CACHE_MAX_BYTES = 512 * 1024; // 512 KB export const CUSTOM_BG_CACHE_NAME = 'tt-custom-bg'; -export const LANG_CACHE_NAME = 'tt-lang-packs-v22'; +export const LANG_CACHE_NAME = 'tt-lang-packs-v23'; export const ASSET_CACHE_NAME = 'tt-assets'; export const AUTODOWNLOAD_FILESIZE_MB_LIMITS = [1, 5, 10, 50, 100, 500]; export const DATA_BROADCAST_CHANNEL_NAME = 'tt-global'; @@ -293,6 +293,7 @@ export const DEFAULT_LANG_CODE = 'en'; export const DEFAULT_LANG_PACK = 'android'; export const LANG_PACKS = ['android', 'ios', 'tdesktop', 'macos'] as const; export const FEEDBACK_URL = 'https://bugs.telegram.org/?tag_ids=41&sort=time'; +export const MINI_APP_TOS_URL = 'https://telegram.org/tos/mini-apps'; export const GENERAL_TOPIC_ID = 1; export const STORY_EXPIRE_PERIOD = 86400; // 1 day export const STORY_VIEWERS_EXPIRE_PERIOD = 86400; // 1 day diff --git a/src/global/actions/api/bots.ts b/src/global/actions/api/bots.ts index 3f62f28e2..7d7541eb1 100644 --- a/src/global/actions/api/bots.ts +++ b/src/global/actions/api/bots.ts @@ -452,7 +452,7 @@ addActionHandler('sharePhoneWithBot', async (global, actions, payload): Promise< addActionHandler('requestSimpleWebView', async (global, actions, payload): Promise => { const { - url, botId, theme, buttonText, + url, botId, theme, buttonText, isFromSideMenu, isFromSwitchWebView, startParam, tabId = getCurrentTabId(), } = payload; @@ -474,7 +474,14 @@ addActionHandler('requestSimpleWebView', async (global, actions, payload): Promi return; } - const webViewUrl = await callApi('requestSimpleWebView', { url, bot, theme }); + const webViewUrl = await callApi('requestSimpleWebView', { + url, + bot, + theme, + startParam, + isFromSideMenu, + isFromSwitchWebView, + }); if (!webViewUrl) { return; } @@ -724,16 +731,8 @@ addActionHandler('toggleAttachBot', async (global, actions, payload): Promise( - global: T, bot: ApiUser, isEnabled: boolean, isWriteAllowed?: boolean, -) { await callApi('toggleAttachBot', { bot, isWriteAllowed, isEnabled }); - global = getGlobal(); - await loadAttachBots(global); -} +}); async function loadAttachBots(global: T, hash?: string) { const result = await callApi('loadAttachBots', { hash }); @@ -755,33 +754,52 @@ async function loadAttachBots(global: T, hash?: string) { addActionHandler('callAttachBot', (global, actions, payload): ActionReturnType => { const { - chatId, bot, url, startParam, threadId, + chatId, bot, url, startParam, threadId, isFromSideMenu, tabId = getCurrentTabId(), } = payload; const isFromBotMenu = !bot; - if (!isFromBotMenu && !global.attachMenu.bots[bot.id]) { + if ((!isFromBotMenu && !global.attachMenu.bots[bot.id]) + || (isFromSideMenu && (bot?.isInactive || bot?.isDisclaimerNeeded))) { return updateTabState(global, { requestedAttachBotInstall: { bot, onConfirm: { action: 'callAttachBot', - payload, + payload: { + ...payload, + bot: { + ...bot, + isInactive: false, + isDisclaimerNeeded: false, + }, + }, }, }, }, tabId); } + const theme = extractCurrentThemeParams(); - actions.openChat({ id: chatId, threadId, tabId }); - actions.requestWebView({ - url, - peerId: chatId, - botId: isFromBotMenu ? chatId : bot.id, - theme, - buttonText: '', - isFromBotMenu, - startParam, - tabId, - }); + if (isFromSideMenu) { + actions.requestSimpleWebView({ + botId: bot!.id, + buttonText: '', + isFromSideMenu: true, + theme, + tabId, + }); + } else { + actions.openChat({ id: chatId, threadId, tabId }); + actions.requestWebView({ + url, + peerId: chatId, + botId: isFromBotMenu ? chatId : bot.id, + theme, + buttonText: '', + isFromBotMenu, + startParam, + tabId, + }); + } return undefined; }); @@ -800,7 +818,7 @@ addActionHandler('confirmAttachBotInstall', async (global, actions, payload): Pr const botUser = selectUser(global, bot.id); if (!botUser) return; - await toggleAttachBot(global, botUser, true, isWriteAllowed); + await callApi('toggleAttachBot', { bot: botUser, isWriteAllowed, isEnabled: true }); if (onConfirm) { const { action, payload: actionPayload } = onConfirm; // @ts-ignore @@ -821,11 +839,11 @@ addActionHandler('requestAttachBotInChat', (global, actions, payload): ActionRet } = payload; const currentChatId = selectCurrentMessageList(global, tabId)?.chatId; - const supportedFilters = bot.peerTypes.filter((type): type is ApiChatType => ( + const supportedFilters = bot.attachMenuPeerTypes?.filter((type): type is ApiChatType => ( type !== 'self' && filter.includes(type) )); - if (!supportedFilters.length) { + if (!supportedFilters?.length) { actions.callAttachBot({ chatId: currentChatId || bot.id, bot, diff --git a/src/global/actions/apiUpdaters/misc.ts b/src/global/actions/apiUpdaters/misc.ts index df2aa4591..f1cdad2e0 100644 --- a/src/global/actions/apiUpdaters/misc.ts +++ b/src/global/actions/apiUpdaters/misc.ts @@ -141,6 +141,10 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => { global = updateStealthMode(global, update.stealthMode); setGlobal(global); break; + + case 'updateAttachMenuBots': + actions.loadAttachBots({ hash: global.attachMenu.hash }); + break; } return undefined; diff --git a/src/global/types.ts b/src/global/types.ts index e63fe1348..0e42f74ec 100644 --- a/src/global/types.ts +++ b/src/global/types.ts @@ -2346,10 +2346,13 @@ export interface ActionPayloads { threadId?: number; } & WithTabId; requestSimpleWebView: { - url: string; + url?: string; botId: string; buttonText: string; theme?: ApiThemeParameters; + startParam?: string; + isFromSwitchWebView?: boolean; + isFromSideMenu?: boolean; } & WithTabId; requestAppWebView: { botId: string; @@ -2407,6 +2410,7 @@ export interface ActionPayloads { bot?: ApiAttachBot; url?: string; startParam?: string; + isFromSideMenu?: boolean; } & WithTabId; requestBotUrlAuth: { diff --git a/src/lib/gramjs/tl/AllTLObjects.js b/src/lib/gramjs/tl/AllTLObjects.js index 999732e0b..1de3d92a3 100644 --- a/src/lib/gramjs/tl/AllTLObjects.js +++ b/src/lib/gramjs/tl/AllTLObjects.js @@ -1,6 +1,6 @@ const api = require('./api'); -const LAYER = 162; +const LAYER = 163; const tlobjects = {}; for (const tl of Object.values(api)) { diff --git a/src/lib/gramjs/tl/api.d.ts b/src/lib/gramjs/tl/api.d.ts index 50fa2b827..e14b9d725 100644 --- a/src/lib/gramjs/tl/api.d.ts +++ b/src/lib/gramjs/tl/api.d.ts @@ -86,7 +86,7 @@ namespace Api { export type TypeImportedContact = ImportedContact; export type TypeContactStatus = ContactStatus; export type TypeMessagesFilter = InputMessagesFilterEmpty | InputMessagesFilterPhotos | InputMessagesFilterVideo | InputMessagesFilterPhotoVideo | InputMessagesFilterDocument | InputMessagesFilterUrl | InputMessagesFilterGif | InputMessagesFilterVoice | InputMessagesFilterMusic | InputMessagesFilterChatPhotos | InputMessagesFilterPhoneCalls | InputMessagesFilterRoundVoice | InputMessagesFilterRoundVideo | InputMessagesFilterMyMentions | InputMessagesFilterGeo | InputMessagesFilterContacts | InputMessagesFilterPinned; - export type TypeUpdate = UpdateNewMessage | UpdateMessageID | UpdateDeleteMessages | UpdateUserTyping | UpdateChatUserTyping | UpdateChatParticipants | UpdateUserStatus | UpdateUserName | UpdateNewEncryptedMessage | UpdateEncryptedChatTyping | UpdateEncryption | UpdateEncryptedMessagesRead | UpdateChatParticipantAdd | UpdateChatParticipantDelete | UpdateDcOptions | UpdateNotifySettings | UpdateServiceNotification | UpdatePrivacy | UpdateUserPhone | UpdateReadHistoryInbox | UpdateReadHistoryOutbox | UpdateWebPage | UpdateReadMessagesContents | UpdateChannelTooLong | UpdateChannel | UpdateNewChannelMessage | UpdateReadChannelInbox | UpdateDeleteChannelMessages | UpdateChannelMessageViews | UpdateChatParticipantAdmin | UpdateNewStickerSet | UpdateStickerSetsOrder | UpdateStickerSets | UpdateSavedGifs | UpdateBotInlineQuery | UpdateBotInlineSend | UpdateEditChannelMessage | UpdateBotCallbackQuery | UpdateEditMessage | UpdateInlineBotCallbackQuery | UpdateReadChannelOutbox | UpdateDraftMessage | UpdateReadFeaturedStickers | UpdateRecentStickers | UpdateConfig | UpdatePtsChanged | UpdateChannelWebPage | UpdateDialogPinned | UpdatePinnedDialogs | UpdateBotWebhookJSON | UpdateBotWebhookJSONQuery | UpdateBotShippingQuery | UpdateBotPrecheckoutQuery | UpdatePhoneCall | UpdateLangPackTooLong | UpdateLangPack | UpdateFavedStickers | UpdateChannelReadMessagesContents | UpdateContactsReset | UpdateChannelAvailableMessages | UpdateDialogUnreadMark | UpdateMessagePoll | UpdateChatDefaultBannedRights | UpdateFolderPeers | UpdatePeerSettings | UpdatePeerLocated | UpdateNewScheduledMessage | UpdateDeleteScheduledMessages | UpdateTheme | UpdateGeoLiveViewed | UpdateLoginToken | UpdateMessagePollVote | UpdateDialogFilter | UpdateDialogFilterOrder | UpdateDialogFilters | UpdatePhoneCallSignalingData | UpdateChannelMessageForwards | UpdateReadChannelDiscussionInbox | UpdateReadChannelDiscussionOutbox | UpdatePeerBlocked | UpdateChannelUserTyping | UpdatePinnedMessages | UpdatePinnedChannelMessages | UpdateChat | UpdateGroupCallParticipants | UpdateGroupCall | UpdatePeerHistoryTTL | UpdateChatParticipant | UpdateChannelParticipant | UpdateBotStopped | UpdateGroupCallConnection | UpdateBotCommands | UpdatePendingJoinRequests | UpdateBotChatInviteRequester | UpdateMessageReactions | UpdateAttachMenuBots | UpdateWebViewResultSent | UpdateBotMenuButton | UpdateSavedRingtones | UpdateTranscribedAudio | UpdateReadFeaturedEmojiStickers | UpdateUserEmojiStatus | UpdateRecentEmojiStatuses | UpdateRecentReactions | UpdateMoveStickerSetToTop | UpdateMessageExtendedMedia | UpdateChannelPinnedTopic | UpdateChannelPinnedTopics | UpdateUser | UpdateAutoSaveSettings | UpdateGroupInvitePrivacyForbidden | UpdateStory | UpdateReadStories | UpdateStoryID | UpdateStoriesStealthMode | UpdateSentStoryReaction; + export type TypeUpdate = UpdateNewMessage | UpdateMessageID | UpdateDeleteMessages | UpdateUserTyping | UpdateChatUserTyping | UpdateChatParticipants | UpdateUserStatus | UpdateUserName | UpdateNewAuthorization | UpdateNewEncryptedMessage | UpdateEncryptedChatTyping | UpdateEncryption | UpdateEncryptedMessagesRead | UpdateChatParticipantAdd | UpdateChatParticipantDelete | UpdateDcOptions | UpdateNotifySettings | UpdateServiceNotification | UpdatePrivacy | UpdateUserPhone | UpdateReadHistoryInbox | UpdateReadHistoryOutbox | UpdateWebPage | UpdateReadMessagesContents | UpdateChannelTooLong | UpdateChannel | UpdateNewChannelMessage | UpdateReadChannelInbox | UpdateDeleteChannelMessages | UpdateChannelMessageViews | UpdateChatParticipantAdmin | UpdateNewStickerSet | UpdateStickerSetsOrder | UpdateStickerSets | UpdateSavedGifs | UpdateBotInlineQuery | UpdateBotInlineSend | UpdateEditChannelMessage | UpdateBotCallbackQuery | UpdateEditMessage | UpdateInlineBotCallbackQuery | UpdateReadChannelOutbox | UpdateDraftMessage | UpdateReadFeaturedStickers | UpdateRecentStickers | UpdateConfig | UpdatePtsChanged | UpdateChannelWebPage | UpdateDialogPinned | UpdatePinnedDialogs | UpdateBotWebhookJSON | UpdateBotWebhookJSONQuery | UpdateBotShippingQuery | UpdateBotPrecheckoutQuery | UpdatePhoneCall | UpdateLangPackTooLong | UpdateLangPack | UpdateFavedStickers | UpdateChannelReadMessagesContents | UpdateContactsReset | UpdateChannelAvailableMessages | UpdateDialogUnreadMark | UpdateMessagePoll | UpdateChatDefaultBannedRights | UpdateFolderPeers | UpdatePeerSettings | UpdatePeerLocated | UpdateNewScheduledMessage | UpdateDeleteScheduledMessages | UpdateTheme | UpdateGeoLiveViewed | UpdateLoginToken | UpdateMessagePollVote | UpdateDialogFilter | UpdateDialogFilterOrder | UpdateDialogFilters | UpdatePhoneCallSignalingData | UpdateChannelMessageForwards | UpdateReadChannelDiscussionInbox | UpdateReadChannelDiscussionOutbox | UpdatePeerBlocked | UpdateChannelUserTyping | UpdatePinnedMessages | UpdatePinnedChannelMessages | UpdateChat | UpdateGroupCallParticipants | UpdateGroupCall | UpdatePeerHistoryTTL | UpdateChatParticipant | UpdateChannelParticipant | UpdateBotStopped | UpdateGroupCallConnection | UpdateBotCommands | UpdatePendingJoinRequests | UpdateBotChatInviteRequester | UpdateMessageReactions | UpdateAttachMenuBots | UpdateWebViewResultSent | UpdateBotMenuButton | UpdateSavedRingtones | UpdateTranscribedAudio | UpdateReadFeaturedEmojiStickers | UpdateUserEmojiStatus | UpdateRecentEmojiStatuses | UpdateRecentReactions | UpdateMoveStickerSetToTop | UpdateMessageExtendedMedia | UpdateChannelPinnedTopic | UpdateChannelPinnedTopics | UpdateUser | UpdateAutoSaveSettings | UpdateGroupInvitePrivacyForbidden | UpdateStory | UpdateReadStories | UpdateStoryID | UpdateStoriesStealthMode | UpdateSentStoryReaction; export type TypeUpdates = UpdatesTooLong | UpdateShortMessage | UpdateShortChatMessage | UpdateShort | UpdatesCombined | Updates | UpdateShortSentMessage; export type TypeDcOption = DcOption; export type TypeConfig = Config; @@ -2371,6 +2371,21 @@ namespace Api { lastName: string; usernames: Api.TypeUsername[]; }; + export class UpdateNewAuthorization extends VirtualClass<{ + // flags: undefined; + unconfirmed?: true; + hash: long; + date?: int; + device?: string; + location?: string; + }> { + // flags: undefined; + unconfirmed?: true; + hash: long; + date?: int; + device?: string; + location?: string; + }; export class UpdateNewEncryptedMessage extends VirtualClass<{ message: Api.TypeEncryptedMessage; qts: int; @@ -2502,13 +2517,17 @@ namespace Api { ptsCount: int; }; export class UpdateReadMessagesContents extends VirtualClass<{ + // flags: undefined; messages: int[]; pts: int; ptsCount: int; + date?: int; }> { + // flags: undefined; messages: int[]; pts: int; ptsCount: int; + date?: int; }; export class UpdateChannelTooLong extends VirtualClass<{ // flags: undefined; @@ -4013,6 +4032,7 @@ namespace Api { passwordPending?: true; encryptedRequestsDisabled?: true; callRequestsDisabled?: true; + unconfirmed?: true; hash: long; deviceModel: string; platform: string; @@ -4032,6 +4052,7 @@ namespace Api { passwordPending?: true; encryptedRequestsDisabled?: true; callRequestsDisabled?: true; + unconfirmed?: true; hash: long; deviceModel: string; platform: string; @@ -7812,18 +7833,24 @@ namespace Api { inactive?: true; hasSettings?: true; requestWriteAccess?: true; + showInAttachMenu?: true; + showInSideMenu?: true; + sideMenuDisclaimerNeeded?: true; botId: long; shortName: string; - peerTypes: Api.TypeAttachMenuPeerType[]; + peerTypes?: Api.TypeAttachMenuPeerType[]; icons: Api.TypeAttachMenuBotIcon[]; }> { // flags: undefined; inactive?: true; hasSettings?: true; requestWriteAccess?: true; + showInAttachMenu?: true; + showInSideMenu?: true; + sideMenuDisclaimerNeeded?: true; botId: long; shortName: string; - peerTypes: Api.TypeAttachMenuPeerType[]; + peerTypes?: Api.TypeAttachMenuPeerType[]; icons: Api.TypeAttachMenuBotIcon[]; }; export class AttachMenuBotsNotModified extends VirtualClass {}; @@ -9669,11 +9696,13 @@ namespace Api { // flags: undefined; inactive?: true; requestWriteAccess?: true; + hasSettings?: true; app: Api.TypeBotApp; }> { // flags: undefined; inactive?: true; requestWriteAccess?: true; + hasSettings?: true; app: Api.TypeBotApp; }; } @@ -11476,11 +11505,13 @@ namespace Api { }; export class ChangeAuthorizationSettings extends Request, Bool> { // flags: undefined; + confirmed?: true; hash: long; encryptedRequestsDisabled?: Bool; callRequestsDisabled?: Bool; @@ -13409,15 +13440,19 @@ namespace Api { export class RequestSimpleWebView extends Request, Api.TypeSimpleWebViewResult> { // flags: undefined; fromSwitchWebview?: true; + fromSideMenu?: true; bot: Api.TypeInputUser; - url: string; + url?: string; + startParam?: string; themeParams?: Api.TypeDataJSON; platform: string; }; diff --git a/src/lib/gramjs/tl/apiTl.js b/src/lib/gramjs/tl/apiTl.js index a175763ef..d60725f88 100644 --- a/src/lib/gramjs/tl/apiTl.js +++ b/src/lib/gramjs/tl/apiTl.js @@ -226,6 +226,7 @@ updateChatUserTyping#83487af0 chat_id:long from_id:Peer action:SendMessageAction updateChatParticipants#7761198 participants:ChatParticipants = Update; updateUserStatus#e5bdf8de user_id:long status:UserStatus = Update; updateUserName#a7848924 user_id:long first_name:string last_name:string usernames:Vector = Update; +updateNewAuthorization#8951abef flags:# unconfirmed:flags.0?true hash:long date:flags.0?int device:flags.0?string location:flags.0?string = Update; updateNewEncryptedMessage#12bcbd9a message:EncryptedMessage qts:int = Update; updateEncryptedChatTyping#1710f156 chat_id:int = Update; updateEncryption#b4a2e88d chat:EncryptedChat date:int = Update; @@ -240,7 +241,7 @@ updateUserPhone#5492a13 user_id:long phone:string = Update; updateReadHistoryInbox#9c974fdf flags:# folder_id:flags.0?int peer:Peer max_id:int still_unread_count:int pts:int pts_count:int = Update; updateReadHistoryOutbox#2f2f21bf peer:Peer max_id:int pts:int pts_count:int = Update; updateWebPage#7f891213 webpage:WebPage pts:int pts_count:int = Update; -updateReadMessagesContents#68c13933 messages:Vector pts:int pts_count:int = Update; +updateReadMessagesContents#f8227181 flags:# messages:Vector pts:int pts_count:int date:flags.0?int = Update; updateChannelTooLong#108d941f flags:# channel_id:long pts:flags.0?int = Update; updateChannel#635b4c09 channel_id:long = Update; updateNewChannelMessage#62ba04d9 message:Message pts:int pts_count:int = Update; @@ -462,7 +463,7 @@ webPageEmpty#eb1477e8 id:long = WebPage; webPagePending#c586da1c id:long date:int = WebPage; webPage#e89c45b2 flags:# id:long url:string display_url:string hash:int type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document cached_page:flags.10?Page attributes:flags.12?Vector = WebPage; webPageNotModified#7311ca11 flags:# cached_page_views:flags.0?int = WebPage; -authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true password_pending:flags.2?true encrypted_requests_disabled:flags.3?true call_requests_disabled:flags.4?true hash:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization; +authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true password_pending:flags.2?true encrypted_requests_disabled:flags.3?true call_requests_disabled:flags.4?true unconfirmed:flags.5?true hash:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization; account.authorizations#4bff8ea0 authorization_ttl_days:int authorizations:Vector = account.Authorizations; account.password#957b50fb flags:# has_recovery:flags.0?true has_secure_values:flags.1?true has_password:flags.2?true current_algo:flags.2?PasswordKdfAlgo srp_B:flags.2?bytes srp_id:flags.2?long hint:flags.3?string email_unconfirmed_pattern:flags.4?string new_algo:PasswordKdfAlgo new_secure_algo:SecurePasswordKdfAlgo secure_random:bytes pending_reset_date:flags.5?int login_email_pattern:flags.6?string = account.Password; account.passwordSettings#9a5c33e5 flags:# email:flags.0?string secure_settings:flags.1?SecureSecretSettings = account.PasswordSettings; @@ -1027,7 +1028,7 @@ phone.groupCallStreamChannels#d0e482b2 channels:Vector = phone.groupCallStreamRtmpUrl#2dbf3432 url:string key:string = phone.GroupCallStreamRtmpUrl; attachMenuBotIconColor#4576f3f0 name:string color:int = AttachMenuBotIconColor; attachMenuBotIcon#b2a7386b flags:# name:string icon:Document colors:flags.0?Vector = AttachMenuBotIcon; -attachMenuBot#c8aa2cd2 flags:# inactive:flags.0?true has_settings:flags.1?true request_write_access:flags.2?true bot_id:long short_name:string peer_types:Vector icons:Vector = AttachMenuBot; +attachMenuBot#d90d8dfe flags:# inactive:flags.0?true has_settings:flags.1?true request_write_access:flags.2?true show_in_attach_menu:flags.3?true show_in_side_menu:flags.4?true side_menu_disclaimer_needed:flags.5?true bot_id:long short_name:string peer_types:flags.3?Vector icons:Vector = AttachMenuBot; attachMenuBotsNotModified#f1d88a5c = AttachMenuBots; attachMenuBots#3c4301c0 hash:long bots:Vector users:Vector = AttachMenuBots; attachMenuBotsBot#93bf667f bot:AttachMenuBot users:Vector = AttachMenuBotsBot; @@ -1110,7 +1111,7 @@ inputBotAppID#a920bd7a id:long access_hash:long = InputBotApp; inputBotAppShortName#908c0407 bot_id:InputUser short_name:string = InputBotApp; botAppNotModified#5da674b7 = BotApp; botApp#95fcd1d6 flags:# id:long access_hash:long short_name:string title:string description:string photo:Photo document:flags.0?Document hash:long = BotApp; -messages.botApp#eb50adf5 flags:# inactive:flags.0?true request_write_access:flags.1?true app:BotApp = messages.BotApp; +messages.botApp#eb50adf5 flags:# inactive:flags.0?true request_write_access:flags.1?true has_settings:flags.2?true app:BotApp = messages.BotApp; appWebViewResultUrl#3c1b4f0d url:string = AppWebViewResult; inlineBotWebView#b57295d5 text:string url:string = InlineBotWebView; readParticipantDate#4a4ff172 user_id:long date:int = ReadParticipantDate; @@ -1201,7 +1202,7 @@ account.getGlobalPrivacySettings#eb2b4cf6 = GlobalPrivacySettings; account.setGlobalPrivacySettings#1edaaac2 settings:GlobalPrivacySettings = GlobalPrivacySettings; account.reportProfilePhoto#fa8cc6f5 peer:InputPeer photo_id:InputPhoto reason:ReportReason message:string = Bool; account.setAuthorizationTTL#bf899aa0 authorization_ttl_days:int = Bool; -account.changeAuthorizationSettings#40f48462 flags:# hash:long encrypted_requests_disabled:flags.0?Bool call_requests_disabled:flags.1?Bool = Bool; +account.changeAuthorizationSettings#40f48462 flags:# confirmed:flags.3?true hash:long encrypted_requests_disabled:flags.0?Bool call_requests_disabled:flags.1?Bool = Bool; account.updateEmojiStatus#fbd3de6b emoji_status:EmojiStatus = Bool; account.getRecentEmojiStatuses#f578105 hash:long = account.EmojiStatuses; account.reorderUsernames#ef500eab order:Vector = Bool; @@ -1331,7 +1332,7 @@ messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; messages.toggleBotInAttachMenu#69f59d69 flags:# write_allowed:flags.0?true bot:InputUser enabled:Bool = Bool; messages.requestWebView#269dc2c1 flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to:flags.0?InputReplyTo send_as:flags.13?InputPeer = WebViewResult; messages.prolongWebView#b0d81a83 flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to:flags.0?InputReplyTo send_as:flags.13?InputPeer = Bool; -messages.requestSimpleWebView#299bec8e flags:# from_switch_webview:flags.1?true bot:InputUser url:string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; +messages.requestSimpleWebView#1a46500a flags:# from_switch_webview:flags.1?true from_side_menu:flags.2?true bot:InputUser url:flags.3?string start_param:flags.4?string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent; messages.sendWebViewData#dc0242c8 bot:InputUser random_id:long button_text:string data:string = Updates; messages.transcribeAudio#269e9a49 peer:InputPeer msg_id:int = messages.TranscribedAudio; diff --git a/src/lib/gramjs/tl/static/api.tl b/src/lib/gramjs/tl/static/api.tl index 3eb6f4bc2..42471d70b 100644 --- a/src/lib/gramjs/tl/static/api.tl +++ b/src/lib/gramjs/tl/static/api.tl @@ -279,6 +279,7 @@ updateChatUserTyping#83487af0 chat_id:long from_id:Peer action:SendMessageAction updateChatParticipants#7761198 participants:ChatParticipants = Update; updateUserStatus#e5bdf8de user_id:long status:UserStatus = Update; updateUserName#a7848924 user_id:long first_name:string last_name:string usernames:Vector = Update; +updateNewAuthorization#8951abef flags:# unconfirmed:flags.0?true hash:long date:flags.0?int device:flags.0?string location:flags.0?string = Update; updateNewEncryptedMessage#12bcbd9a message:EncryptedMessage qts:int = Update; updateEncryptedChatTyping#1710f156 chat_id:int = Update; updateEncryption#b4a2e88d chat:EncryptedChat date:int = Update; @@ -293,7 +294,7 @@ updateUserPhone#5492a13 user_id:long phone:string = Update; updateReadHistoryInbox#9c974fdf flags:# folder_id:flags.0?int peer:Peer max_id:int still_unread_count:int pts:int pts_count:int = Update; updateReadHistoryOutbox#2f2f21bf peer:Peer max_id:int pts:int pts_count:int = Update; updateWebPage#7f891213 webpage:WebPage pts:int pts_count:int = Update; -updateReadMessagesContents#68c13933 messages:Vector pts:int pts_count:int = Update; +updateReadMessagesContents#f8227181 flags:# messages:Vector pts:int pts_count:int date:flags.0?int = Update; updateChannelTooLong#108d941f flags:# channel_id:long pts:flags.0?int = Update; updateChannel#635b4c09 channel_id:long = Update; updateNewChannelMessage#62ba04d9 message:Message pts:int pts_count:int = Update; @@ -552,7 +553,7 @@ webPagePending#c586da1c id:long date:int = WebPage; webPage#e89c45b2 flags:# id:long url:string display_url:string hash:int type:flags.0?string site_name:flags.1?string title:flags.2?string description:flags.3?string photo:flags.4?Photo embed_url:flags.5?string embed_type:flags.5?string embed_width:flags.6?int embed_height:flags.6?int duration:flags.7?int author:flags.8?string document:flags.9?Document cached_page:flags.10?Page attributes:flags.12?Vector = WebPage; webPageNotModified#7311ca11 flags:# cached_page_views:flags.0?int = WebPage; -authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true password_pending:flags.2?true encrypted_requests_disabled:flags.3?true call_requests_disabled:flags.4?true hash:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization; +authorization#ad01d61d flags:# current:flags.0?true official_app:flags.1?true password_pending:flags.2?true encrypted_requests_disabled:flags.3?true call_requests_disabled:flags.4?true unconfirmed:flags.5?true hash:long device_model:string platform:string system_version:string api_id:int app_name:string app_version:string date_created:int date_active:int ip:string country:string region:string = Authorization; account.authorizations#4bff8ea0 authorization_ttl_days:int authorizations:Vector = account.Authorizations; @@ -1369,7 +1370,7 @@ attachMenuBotIconColor#4576f3f0 name:string color:int = AttachMenuBotIconColor; attachMenuBotIcon#b2a7386b flags:# name:string icon:Document colors:flags.0?Vector = AttachMenuBotIcon; -attachMenuBot#c8aa2cd2 flags:# inactive:flags.0?true has_settings:flags.1?true request_write_access:flags.2?true bot_id:long short_name:string peer_types:Vector icons:Vector = AttachMenuBot; +attachMenuBot#d90d8dfe flags:# inactive:flags.0?true has_settings:flags.1?true request_write_access:flags.2?true show_in_attach_menu:flags.3?true show_in_side_menu:flags.4?true side_menu_disclaimer_needed:flags.5?true bot_id:long short_name:string peer_types:flags.3?Vector icons:Vector = AttachMenuBot; attachMenuBotsNotModified#f1d88a5c = AttachMenuBots; attachMenuBots#3c4301c0 hash:long bots:Vector users:Vector = AttachMenuBots; @@ -1499,7 +1500,7 @@ inputBotAppShortName#908c0407 bot_id:InputUser short_name:string = InputBotApp; botAppNotModified#5da674b7 = BotApp; botApp#95fcd1d6 flags:# id:long access_hash:long short_name:string title:string description:string photo:Photo document:flags.0?Document hash:long = BotApp; -messages.botApp#eb50adf5 flags:# inactive:flags.0?true request_write_access:flags.1?true app:BotApp = messages.BotApp; +messages.botApp#eb50adf5 flags:# inactive:flags.0?true request_write_access:flags.1?true has_settings:flags.2?true app:BotApp = messages.BotApp; appWebViewResultUrl#3c1b4f0d url:string = AppWebViewResult; @@ -1667,7 +1668,7 @@ account.resetPassword#9308ce1b = account.ResetPasswordResult; account.declinePasswordReset#4c9409f6 = Bool; account.getChatThemes#d638de89 hash:long = account.Themes; account.setAuthorizationTTL#bf899aa0 authorization_ttl_days:int = Bool; -account.changeAuthorizationSettings#40f48462 flags:# hash:long encrypted_requests_disabled:flags.0?Bool call_requests_disabled:flags.1?Bool = Bool; +account.changeAuthorizationSettings#40f48462 flags:# confirmed:flags.3?true hash:long encrypted_requests_disabled:flags.0?Bool call_requests_disabled:flags.1?Bool = Bool; account.getSavedRingtones#e1902288 hash:long = account.SavedRingtones; account.saveRingtone#3dea5b03 id:InputDocument unsave:Bool = account.SavedRingtone; account.uploadRingtone#831a83a2 file:InputFile file_name:string mime_type:string = Document; @@ -1879,7 +1880,7 @@ messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; messages.toggleBotInAttachMenu#69f59d69 flags:# write_allowed:flags.0?true bot:InputUser enabled:Bool = Bool; messages.requestWebView#269dc2c1 flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to:flags.0?InputReplyTo send_as:flags.13?InputPeer = WebViewResult; messages.prolongWebView#b0d81a83 flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to:flags.0?InputReplyTo send_as:flags.13?InputPeer = Bool; -messages.requestSimpleWebView#299bec8e flags:# from_switch_webview:flags.1?true bot:InputUser url:string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; +messages.requestSimpleWebView#1a46500a flags:# from_switch_webview:flags.1?true from_side_menu:flags.2?true bot:InputUser url:flags.3?string start_param:flags.4?string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent; messages.sendWebViewData#dc0242c8 bot:InputUser random_id:long button_text:string data:string = Updates; messages.transcribeAudio#269e9a49 peer:InputPeer msg_id:int = messages.TranscribedAudio; @@ -2121,4 +2122,4 @@ stories.getStoriesViews#9a75d6a6 id:Vector = stories.StoryViews; stories.exportStoryLink#16e443ce user_id:InputUser id:int = ExportedStoryLink; stories.report#c95be06a user_id:InputUser id:Vector reason:ReportReason message:string = Bool; stories.activateStealthMode#57bbd166 flags:# past:flags.0?true future:flags.1?true = Updates; -stories.sendReaction#49aaa9b3 flags:# add_to_recent:flags.0?true user_id:InputUser story_id:int reaction:Reaction = Updates; \ No newline at end of file +stories.sendReaction#49aaa9b3 flags:# add_to_recent:flags.0?true user_id:InputUser story_id:int reaction:Reaction = Updates; diff --git a/src/types/webapp.ts b/src/types/webapp.ts index 84b897baa..bb0417471 100644 --- a/src/types/webapp.ts +++ b/src/types/webapp.ts @@ -59,7 +59,8 @@ export type WebAppInboundEvent = { } | { eventType: 'web_app_set_header_color'; eventData: { - color_key: 'bg_color' | 'secondary_bg_color'; + color_key?: 'bg_color' | 'secondary_bg_color'; + color?: string; }; } | { eventType: 'web_app_open_popup';