Fix downloads again
This commit is contained in:
parent
79c5afd79b
commit
02ac2c189a
@ -24,6 +24,10 @@ export function processPeerFullForCommands(peerId: PeerId, full: ChatFull.chatFu
|
||||
type T = {peerId: PeerId, name: string, description: string, index: number, command: string};
|
||||
const commands: Map<string, T> = new Map();
|
||||
botInfos.forEach((botInfo) => {
|
||||
if(!botInfo.commands) {
|
||||
return;
|
||||
}
|
||||
|
||||
botInfo.commands.forEach(({command, description}, idx) => {
|
||||
const c = '/' + command;
|
||||
commands.set(command, {
|
||||
|
@ -221,7 +221,7 @@ export default class PopupPayment extends PopupElement {
|
||||
}
|
||||
|
||||
let savedInfo = (paymentForm as PaymentsPaymentForm).saved_info || (paymentForm as PaymentsPaymentReceipt).info;
|
||||
const savedCredentials = (paymentForm as PaymentsPaymentForm).saved_credentials;
|
||||
const savedCredentials = (paymentForm as PaymentsPaymentForm).saved_credentials?.[0];
|
||||
let [lastRequestedInfo, passwordState, providerPeerTitle] = await Promise.all([
|
||||
!isReceipt && savedInfo && this.managers.appPaymentsManager.validateRequestedInfo(inputInvoice, savedInfo),
|
||||
savedCredentials && this.managers.passwordManager.getState(),
|
||||
|
177
src/layer.d.ts
vendored
177
src/layer.d.ts
vendored
@ -1039,7 +1039,7 @@ export namespace MessageMedia {
|
||||
/**
|
||||
* @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.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.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 type messageActionEmpty = {
|
||||
@ -1229,6 +1229,13 @@ export namespace MessageAction {
|
||||
text: string
|
||||
};
|
||||
|
||||
export type messageActionGiftPremium = {
|
||||
_: 'messageActionGiftPremium',
|
||||
currency: string,
|
||||
amount: string | number,
|
||||
months: number
|
||||
};
|
||||
|
||||
export type messageActionDiscussionStarted = {
|
||||
_: 'messageActionDiscussionStarted'
|
||||
};
|
||||
@ -1689,6 +1696,7 @@ export namespace UserFull {
|
||||
can_pin_message?: true,
|
||||
has_scheduled?: true,
|
||||
video_calls_available?: true,
|
||||
voice_messages_forbidden?: true,
|
||||
}>,
|
||||
id: string | number,
|
||||
about?: string,
|
||||
@ -1703,7 +1711,8 @@ export namespace UserFull {
|
||||
theme_emoticon?: string,
|
||||
private_forward_name?: string,
|
||||
bot_group_admin_rights?: ChatAdminRights,
|
||||
bot_broadcast_admin_rights?: ChatAdminRights
|
||||
bot_broadcast_admin_rights?: ChatAdminRights,
|
||||
premium_gifts?: Array<PremiumGiftOption>
|
||||
};
|
||||
}
|
||||
|
||||
@ -2005,7 +2014,7 @@ export namespace MessagesFilter {
|
||||
/**
|
||||
* @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.updateUserPhoto | 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.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.updateUserPhoto | 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.updateNewDiscussionMessage | Update.updateDeleteDiscussionMessages | Update.updateChannelReload;
|
||||
|
||||
export namespace Update {
|
||||
export type updateNewMessage = {
|
||||
@ -2726,6 +2735,10 @@ export namespace Update {
|
||||
text: string
|
||||
};
|
||||
|
||||
export type updateReadFeaturedEmojiStickers = {
|
||||
_: 'updateReadFeaturedEmojiStickers'
|
||||
};
|
||||
|
||||
export type updateNewDiscussionMessage = {
|
||||
_: 'updateNewDiscussionMessage',
|
||||
message?: Message
|
||||
@ -3474,7 +3487,7 @@ export namespace ContactsFound {
|
||||
/**
|
||||
* @link https://core.telegram.org/type/InputPrivacyKey
|
||||
*/
|
||||
export type InputPrivacyKey = InputPrivacyKey.inputPrivacyKeyStatusTimestamp | InputPrivacyKey.inputPrivacyKeyChatInvite | InputPrivacyKey.inputPrivacyKeyPhoneCall | InputPrivacyKey.inputPrivacyKeyPhoneP2P | InputPrivacyKey.inputPrivacyKeyForwards | InputPrivacyKey.inputPrivacyKeyProfilePhoto | InputPrivacyKey.inputPrivacyKeyPhoneNumber | InputPrivacyKey.inputPrivacyKeyAddedByPhone;
|
||||
export type InputPrivacyKey = InputPrivacyKey.inputPrivacyKeyStatusTimestamp | InputPrivacyKey.inputPrivacyKeyChatInvite | InputPrivacyKey.inputPrivacyKeyPhoneCall | InputPrivacyKey.inputPrivacyKeyPhoneP2P | InputPrivacyKey.inputPrivacyKeyForwards | InputPrivacyKey.inputPrivacyKeyProfilePhoto | InputPrivacyKey.inputPrivacyKeyPhoneNumber | InputPrivacyKey.inputPrivacyKeyAddedByPhone | InputPrivacyKey.inputPrivacyKeyVoiceMessages;
|
||||
|
||||
export namespace InputPrivacyKey {
|
||||
export type inputPrivacyKeyStatusTimestamp = {
|
||||
@ -3508,12 +3521,16 @@ export namespace InputPrivacyKey {
|
||||
export type inputPrivacyKeyAddedByPhone = {
|
||||
_: 'inputPrivacyKeyAddedByPhone'
|
||||
};
|
||||
|
||||
export type inputPrivacyKeyVoiceMessages = {
|
||||
_: 'inputPrivacyKeyVoiceMessages'
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/type/PrivacyKey
|
||||
*/
|
||||
export type PrivacyKey = PrivacyKey.privacyKeyStatusTimestamp | PrivacyKey.privacyKeyChatInvite | PrivacyKey.privacyKeyPhoneCall | PrivacyKey.privacyKeyPhoneP2P | PrivacyKey.privacyKeyForwards | PrivacyKey.privacyKeyProfilePhoto | PrivacyKey.privacyKeyPhoneNumber | PrivacyKey.privacyKeyAddedByPhone;
|
||||
export type PrivacyKey = PrivacyKey.privacyKeyStatusTimestamp | PrivacyKey.privacyKeyChatInvite | PrivacyKey.privacyKeyPhoneCall | PrivacyKey.privacyKeyPhoneP2P | PrivacyKey.privacyKeyForwards | PrivacyKey.privacyKeyProfilePhoto | PrivacyKey.privacyKeyPhoneNumber | PrivacyKey.privacyKeyAddedByPhone | PrivacyKey.privacyKeyVoiceMessages;
|
||||
|
||||
export namespace PrivacyKey {
|
||||
export type privacyKeyStatusTimestamp = {
|
||||
@ -3547,6 +3564,10 @@ export namespace PrivacyKey {
|
||||
export type privacyKeyAddedByPhone = {
|
||||
_: 'privacyKeyAddedByPhone'
|
||||
};
|
||||
|
||||
export type privacyKeyVoiceMessages = {
|
||||
_: 'privacyKeyVoiceMessages'
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3664,7 +3685,7 @@ export namespace AccountDaysTTL {
|
||||
/**
|
||||
* @link https://core.telegram.org/type/DocumentAttribute
|
||||
*/
|
||||
export type DocumentAttribute = DocumentAttribute.documentAttributeImageSize | DocumentAttribute.documentAttributeAnimated | DocumentAttribute.documentAttributeSticker | DocumentAttribute.documentAttributeVideo | DocumentAttribute.documentAttributeAudio | DocumentAttribute.documentAttributeFilename | DocumentAttribute.documentAttributeHasStickers;
|
||||
export type DocumentAttribute = DocumentAttribute.documentAttributeImageSize | DocumentAttribute.documentAttributeAnimated | DocumentAttribute.documentAttributeSticker | DocumentAttribute.documentAttributeVideo | DocumentAttribute.documentAttributeAudio | DocumentAttribute.documentAttributeFilename | DocumentAttribute.documentAttributeHasStickers | DocumentAttribute.documentAttributeCustomEmoji;
|
||||
|
||||
export namespace DocumentAttribute {
|
||||
export type documentAttributeImageSize = {
|
||||
@ -3720,6 +3741,16 @@ export namespace DocumentAttribute {
|
||||
export type documentAttributeHasStickers = {
|
||||
_: 'documentAttributeHasStickers'
|
||||
};
|
||||
|
||||
export type documentAttributeCustomEmoji = {
|
||||
_: 'documentAttributeCustomEmoji',
|
||||
flags?: number,
|
||||
pFlags?: Partial<{
|
||||
free?: true,
|
||||
}>,
|
||||
alt: string,
|
||||
stickerset: InputStickerSet
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4023,7 +4054,7 @@ export namespace ChatInvite {
|
||||
/**
|
||||
* @link https://core.telegram.org/type/InputStickerSet
|
||||
*/
|
||||
export type InputStickerSet = InputStickerSet.inputStickerSetEmpty | InputStickerSet.inputStickerSetID | InputStickerSet.inputStickerSetShortName | InputStickerSet.inputStickerSetAnimatedEmoji | InputStickerSet.inputStickerSetDice | InputStickerSet.inputStickerSetAnimatedEmojiAnimations;
|
||||
export type InputStickerSet = InputStickerSet.inputStickerSetEmpty | InputStickerSet.inputStickerSetID | InputStickerSet.inputStickerSetShortName | InputStickerSet.inputStickerSetAnimatedEmoji | InputStickerSet.inputStickerSetDice | InputStickerSet.inputStickerSetAnimatedEmojiAnimations | InputStickerSet.inputStickerSetPremiumGifts;
|
||||
|
||||
export namespace InputStickerSet {
|
||||
export type inputStickerSetEmpty = {
|
||||
@ -4053,6 +4084,10 @@ export namespace InputStickerSet {
|
||||
export type inputStickerSetAnimatedEmojiAnimations = {
|
||||
_: 'inputStickerSetAnimatedEmojiAnimations'
|
||||
};
|
||||
|
||||
export type inputStickerSetPremiumGifts = {
|
||||
_: 'inputStickerSetPremiumGifts'
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4080,6 +4115,7 @@ export namespace StickerSet {
|
||||
thumbs?: Array<PhotoSize>,
|
||||
thumb_dc_id?: number,
|
||||
thumb_version?: number,
|
||||
thumb_document_id?: string | number,
|
||||
count: number,
|
||||
hash: number
|
||||
};
|
||||
@ -4310,7 +4346,7 @@ export namespace ReplyMarkup {
|
||||
/**
|
||||
* @link https://core.telegram.org/type/MessageEntity
|
||||
*/
|
||||
export type MessageEntity = MessageEntity.messageEntityUnknown | MessageEntity.messageEntityMention | MessageEntity.messageEntityHashtag | MessageEntity.messageEntityBotCommand | MessageEntity.messageEntityUrl | MessageEntity.messageEntityEmail | MessageEntity.messageEntityBold | MessageEntity.messageEntityItalic | MessageEntity.messageEntityCode | MessageEntity.messageEntityPre | MessageEntity.messageEntityTextUrl | MessageEntity.messageEntityMentionName | MessageEntity.inputMessageEntityMentionName | MessageEntity.messageEntityPhone | MessageEntity.messageEntityCashtag | MessageEntity.messageEntityUnderline | MessageEntity.messageEntityStrike | MessageEntity.messageEntityBlockquote | MessageEntity.messageEntityBankCard | MessageEntity.messageEntitySpoiler | MessageEntity.messageEntityEmoji | MessageEntity.messageEntityHighlight | MessageEntity.messageEntityLinebreak | MessageEntity.messageEntityCaret;
|
||||
export type MessageEntity = MessageEntity.messageEntityUnknown | MessageEntity.messageEntityMention | MessageEntity.messageEntityHashtag | MessageEntity.messageEntityBotCommand | MessageEntity.messageEntityUrl | MessageEntity.messageEntityEmail | MessageEntity.messageEntityBold | MessageEntity.messageEntityItalic | MessageEntity.messageEntityCode | MessageEntity.messageEntityPre | MessageEntity.messageEntityTextUrl | MessageEntity.messageEntityMentionName | MessageEntity.inputMessageEntityMentionName | MessageEntity.messageEntityPhone | MessageEntity.messageEntityCashtag | MessageEntity.messageEntityUnderline | MessageEntity.messageEntityStrike | MessageEntity.messageEntityBlockquote | MessageEntity.messageEntityBankCard | MessageEntity.messageEntitySpoiler | MessageEntity.messageEntityCustomEmoji | MessageEntity.messageEntityEmoji | MessageEntity.messageEntityHighlight | MessageEntity.messageEntityLinebreak | MessageEntity.messageEntityCaret;
|
||||
|
||||
export namespace MessageEntity {
|
||||
export type messageEntityUnknown = {
|
||||
@ -4438,6 +4474,13 @@ export namespace MessageEntity {
|
||||
length: number
|
||||
};
|
||||
|
||||
export type messageEntityCustomEmoji = {
|
||||
_: 'messageEntityCustomEmoji',
|
||||
offset: number,
|
||||
length: number,
|
||||
document_id: string | number
|
||||
};
|
||||
|
||||
export type messageEntityEmoji = {
|
||||
_: 'messageEntityEmoji',
|
||||
offset?: number,
|
||||
@ -5373,7 +5416,7 @@ export namespace MessagesStickerSetInstallResult {
|
||||
/**
|
||||
* @link https://core.telegram.org/type/StickerSetCovered
|
||||
*/
|
||||
export type StickerSetCovered = StickerSetCovered.stickerSetCovered | StickerSetCovered.stickerSetMultiCovered;
|
||||
export type StickerSetCovered = StickerSetCovered.stickerSetCovered | StickerSetCovered.stickerSetMultiCovered | StickerSetCovered.stickerSetFullCovered;
|
||||
|
||||
export namespace StickerSetCovered {
|
||||
export type stickerSetCovered = {
|
||||
@ -5387,6 +5430,13 @@ export namespace StickerSetCovered {
|
||||
set: StickerSet,
|
||||
covers: Array<Document>
|
||||
};
|
||||
|
||||
export type stickerSetFullCovered = {
|
||||
_: 'stickerSetFullCovered',
|
||||
set: StickerSet,
|
||||
packs: Array<StickerPack>,
|
||||
documents: Array<Document>
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -5959,7 +6009,7 @@ export namespace InputWebDocument {
|
||||
/**
|
||||
* @link https://core.telegram.org/type/InputWebFileLocation
|
||||
*/
|
||||
export type InputWebFileLocation = InputWebFileLocation.inputWebFileLocation | InputWebFileLocation.inputWebFileGeoPointLocation;
|
||||
export type InputWebFileLocation = InputWebFileLocation.inputWebFileLocation | InputWebFileLocation.inputWebFileGeoPointLocation | InputWebFileLocation.inputWebFileAudioAlbumThumbLocation;
|
||||
|
||||
export namespace InputWebFileLocation {
|
||||
export type inputWebFileLocation = {
|
||||
@ -5977,6 +6027,17 @@ export namespace InputWebFileLocation {
|
||||
zoom: number,
|
||||
scale: number
|
||||
};
|
||||
|
||||
export type inputWebFileAudioAlbumThumbLocation = {
|
||||
_: 'inputWebFileAudioAlbumThumbLocation',
|
||||
flags?: number,
|
||||
pFlags?: Partial<{
|
||||
small?: true,
|
||||
}>,
|
||||
document?: InputDocument,
|
||||
title?: string,
|
||||
performer?: string
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -6018,8 +6079,9 @@ export namespace PaymentsPaymentForm {
|
||||
url: string,
|
||||
native_provider?: string,
|
||||
native_params?: DataJSON,
|
||||
additional_methods?: Array<PaymentFormMethod>,
|
||||
saved_info?: PaymentRequestedInfo,
|
||||
saved_credentials?: PaymentSavedCredentials,
|
||||
saved_credentials?: Array<PaymentSavedCredentials>,
|
||||
users: Array<User>
|
||||
};
|
||||
}
|
||||
@ -9861,6 +9923,58 @@ export namespace HelpPremiumPromo {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/type/InputStorePaymentPurpose
|
||||
*/
|
||||
export type InputStorePaymentPurpose = InputStorePaymentPurpose.inputStorePaymentPremiumSubscription | InputStorePaymentPurpose.inputStorePaymentGiftPremium;
|
||||
|
||||
export namespace InputStorePaymentPurpose {
|
||||
export type inputStorePaymentPremiumSubscription = {
|
||||
_: 'inputStorePaymentPremiumSubscription',
|
||||
flags?: number,
|
||||
pFlags?: Partial<{
|
||||
restore?: true,
|
||||
}>
|
||||
};
|
||||
|
||||
export type inputStorePaymentGiftPremium = {
|
||||
_: 'inputStorePaymentGiftPremium',
|
||||
user_id: InputUser,
|
||||
currency: string,
|
||||
amount: string | number
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/type/PremiumGiftOption
|
||||
*/
|
||||
export type PremiumGiftOption = PremiumGiftOption.premiumGiftOption;
|
||||
|
||||
export namespace PremiumGiftOption {
|
||||
export type premiumGiftOption = {
|
||||
_: 'premiumGiftOption',
|
||||
flags?: number,
|
||||
months: number,
|
||||
currency: string,
|
||||
amount: string | number,
|
||||
bot_url: string,
|
||||
store_product?: string
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @link https://core.telegram.org/type/PaymentFormMethod
|
||||
*/
|
||||
export type PaymentFormMethod = PaymentFormMethod.paymentFormMethod;
|
||||
|
||||
export namespace PaymentFormMethod {
|
||||
export type paymentFormMethod = {
|
||||
_: 'paymentFormMethod',
|
||||
url: string,
|
||||
title: string
|
||||
};
|
||||
}
|
||||
|
||||
export interface ConstructorDeclMap {
|
||||
'error': Error.error,
|
||||
'inputPeerEmpty': InputPeer.inputPeerEmpty,
|
||||
@ -10857,6 +10971,19 @@ export interface ConstructorDeclMap {
|
||||
'messages.transcribedAudio': MessagesTranscribedAudio.messagesTranscribedAudio,
|
||||
'dialogFilterDefault': DialogFilter.dialogFilterDefault,
|
||||
'help.premiumPromo': HelpPremiumPromo.helpPremiumPromo,
|
||||
'messageEntityCustomEmoji': MessageEntity.messageEntityCustomEmoji,
|
||||
'documentAttributeCustomEmoji': DocumentAttribute.documentAttributeCustomEmoji,
|
||||
'stickerSetFullCovered': StickerSetCovered.stickerSetFullCovered,
|
||||
'inputStorePaymentPremiumSubscription': InputStorePaymentPurpose.inputStorePaymentPremiumSubscription,
|
||||
'inputStorePaymentGiftPremium': InputStorePaymentPurpose.inputStorePaymentGiftPremium,
|
||||
'messageActionGiftPremium': MessageAction.messageActionGiftPremium,
|
||||
'premiumGiftOption': PremiumGiftOption.premiumGiftOption,
|
||||
'inputStickerSetPremiumGifts': InputStickerSet.inputStickerSetPremiumGifts,
|
||||
'updateReadFeaturedEmojiStickers': Update.updateReadFeaturedEmojiStickers,
|
||||
'inputPrivacyKeyVoiceMessages': InputPrivacyKey.inputPrivacyKeyVoiceMessages,
|
||||
'privacyKeyVoiceMessages': PrivacyKey.privacyKeyVoiceMessages,
|
||||
'paymentFormMethod': PaymentFormMethod.paymentFormMethod,
|
||||
'inputWebFileAudioAlbumThumbLocation': InputWebFileLocation.inputWebFileAudioAlbumThumbLocation,
|
||||
'messageEntityEmoji': MessageEntity.messageEntityEmoji,
|
||||
'messageEntityHighlight': MessageEntity.messageEntityHighlight,
|
||||
'messageEntityLinebreak': MessageEntity.messageEntityLinebreak,
|
||||
@ -13403,27 +13530,33 @@ export type MessagesRateTranscribedAudio = {
|
||||
};
|
||||
|
||||
export type PaymentsAssignAppStoreTransaction = {
|
||||
flags?: number,
|
||||
restore?: boolean,
|
||||
receipt: Uint8Array
|
||||
receipt: Uint8Array,
|
||||
purpose: InputStorePaymentPurpose
|
||||
};
|
||||
|
||||
export type PaymentsAssignPlayMarketTransaction = {
|
||||
purchase_token: string
|
||||
receipt: DataJSON,
|
||||
purpose: InputStorePaymentPurpose
|
||||
};
|
||||
|
||||
export type PaymentsCanPurchasePremium = {
|
||||
|
||||
purpose: InputStorePaymentPurpose
|
||||
};
|
||||
|
||||
export type HelpGetPremiumPromo = {
|
||||
|
||||
};
|
||||
|
||||
export type PaymentsRequestRecurringPayment = {
|
||||
user_id: InputUser,
|
||||
recurring_init_charge: string,
|
||||
invoice_media: InputMedia
|
||||
export type MessagesGetCustomEmojiDocuments = {
|
||||
document_id: Array<string | number>
|
||||
};
|
||||
|
||||
export type MessagesGetEmojiStickers = {
|
||||
hash: string | number
|
||||
};
|
||||
|
||||
export type MessagesGetFeaturedEmojiStickers = {
|
||||
hash: string | number
|
||||
};
|
||||
|
||||
export interface MethodDeclMap {
|
||||
@ -13871,6 +14004,8 @@ export interface MethodDeclMap {
|
||||
'payments.assignPlayMarketTransaction': {req: PaymentsAssignPlayMarketTransaction, res: Updates},
|
||||
'payments.canPurchasePremium': {req: PaymentsCanPurchasePremium, res: boolean},
|
||||
'help.getPremiumPromo': {req: HelpGetPremiumPromo, res: HelpPremiumPromo},
|
||||
'payments.requestRecurringPayment': {req: PaymentsRequestRecurringPayment, res: Updates},
|
||||
'messages.getCustomEmojiDocuments': {req: MessagesGetCustomEmojiDocuments, res: Array<Document>},
|
||||
'messages.getEmojiStickers': {req: MessagesGetEmojiStickers, res: MessagesAllStickers},
|
||||
'messages.getFeaturedEmojiStickers': {req: MessagesGetFeaturedEmojiStickers, res: MessagesFeaturedStickers},
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
import type {DownloadMediaOptions, DownloadOptions} from '../mtproto/apiFileManager';
|
||||
import type {AppMessagesManager} from './appMessagesManager';
|
||||
import type {MyDocument} from './appDocsManager';
|
||||
import deferredPromise, {CancellablePromise} from '../../helpers/cancellablePromise';
|
||||
import {InputFile, Photo, PhotoSize} from '../../layer';
|
||||
import getFileNameForUpload from '../../helpers/getFileNameForUpload';
|
||||
@ -17,6 +18,11 @@ import getDownloadMediaDetails from './utils/download/getDownloadMediaDetails';
|
||||
import getDownloadFileNameFromOptions from './utils/download/getDownloadFileNameFromOptions';
|
||||
import indexOfAndSplice from '../../helpers/array/indexOfAndSplice';
|
||||
import makeError from '../../helpers/makeError';
|
||||
import createDownloadAnchor from '../../helpers/dom/createDownloadAnchor';
|
||||
import {getFileNameByLocation} from '../../helpers/fileName';
|
||||
import getDocumentDownloadOptions from './utils/docs/getDocumentDownloadOptions';
|
||||
import getPhotoDownloadOptions from './utils/photos/getPhotoDownloadOptions';
|
||||
import apiManagerProxy from '../mtproto/mtprotoworker';
|
||||
|
||||
export type ResponseMethodBlob = 'blob';
|
||||
export type ResponseMethodJson = 'json';
|
||||
@ -167,19 +173,23 @@ export class AppDownloadManager {
|
||||
return this.d(fileName, () => this.managers.apiFileManager.download(options), 'blob') as any;
|
||||
}
|
||||
|
||||
public downloadMedia(options: DownloadMediaOptions, type: DownloadType = 'blob'): DownloadBlob {
|
||||
public downloadMedia(options: DownloadMediaOptions, type: DownloadType = 'blob', promiseBefore?: Promise<any>): DownloadBlob {
|
||||
const {downloadOptions, fileName} = getDownloadMediaDetails(options);
|
||||
|
||||
return this.d(fileName, () => {
|
||||
let cb: any;
|
||||
if(type === 'url') {
|
||||
cb = this.managers.apiFileManager.downloadMediaURL;
|
||||
} else if(type === 'void' || type === 'disc') {
|
||||
} else if(type === 'void'/* || type === 'disc' */) {
|
||||
cb = this.managers.apiFileManager.downloadMediaVoid;
|
||||
} else if(type === 'blob') {
|
||||
} else /* if(type === 'blob') */ {
|
||||
cb = this.managers.apiFileManager.downloadMedia;
|
||||
}
|
||||
|
||||
if(promiseBefore) {
|
||||
return promiseBefore.then(() => cb(options));
|
||||
}
|
||||
|
||||
return cb(options);
|
||||
}, type) as any;
|
||||
}
|
||||
@ -241,19 +251,23 @@ export class AppDownloadManager {
|
||||
const url = `download/${id}`;
|
||||
options.downloadId = id;
|
||||
|
||||
const promise = this.downloadMedia(options, 'disc');
|
||||
const pingPromise = apiManagerProxy.pingServiceWorkerWithIframe();
|
||||
|
||||
const promise = this.downloadMedia(options, 'disc', pingPromise);
|
||||
// this.downloadsToDisc[cacheFileName] = promise;
|
||||
|
||||
if(justAttach) {
|
||||
// * force SW to keep alive
|
||||
fetch(url, {headers: {'Cache-Control': 'no-cache'}}).then((response) => response.status);
|
||||
return promise;
|
||||
}
|
||||
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.hidden = true;
|
||||
iframe.src = url;
|
||||
document.body.append(iframe);
|
||||
|
||||
pingPromise.then(() => {
|
||||
iframe.src = url;
|
||||
document.body.append(iframe);
|
||||
});
|
||||
|
||||
// createDownloadAnchor(url, 'asd.txt');
|
||||
|
||||
// const events = [
|
||||
@ -282,7 +296,20 @@ export class AppDownloadManager {
|
||||
};
|
||||
|
||||
promise.addNotifyListener(onProgress);
|
||||
promise.catch(noop).finally(() => {
|
||||
promise.then((blob) => {
|
||||
if(!blob) {
|
||||
return;
|
||||
}
|
||||
|
||||
const url = URL.createObjectURL(blob);
|
||||
const downloadOptions = isDocument ?
|
||||
getDocumentDownloadOptions(media) :
|
||||
getPhotoDownloadOptions(media as any, options.thumb as PhotoSize.photoSize);
|
||||
const fileName = (options.media as MyDocument).file_name || getFileNameByLocation(downloadOptions.location);
|
||||
createDownloadAnchor(url, downloadOptions.fileName || fileName, () => {
|
||||
URL.revokeObjectURL(url);
|
||||
});
|
||||
}).catch(noop).finally(() => {
|
||||
if(!hadProgress) {
|
||||
onProgress();
|
||||
}
|
||||
@ -297,30 +324,6 @@ export class AppDownloadManager {
|
||||
});
|
||||
|
||||
return promise;
|
||||
// } else {
|
||||
// const promise = this.downloadMedia(options, 'blob');
|
||||
// promise.then((blob) => {
|
||||
// const url = URL.createObjectURL(blob);
|
||||
// createDownloadAnchor(url, downloadOptions.fileName || fileName, () => {
|
||||
// URL.revokeObjectURL(url);
|
||||
// });
|
||||
// });
|
||||
// return promise;
|
||||
// }
|
||||
|
||||
// const promise = this.downloadMedia(options);
|
||||
// promise.then((blob) => {
|
||||
// const url = URL.createObjectURL(blob);
|
||||
// const downloadOptions = isDocument ?
|
||||
// getDocumentDownloadOptions(media) :
|
||||
// getPhotoDownloadOptions(media as any, options.thumb);
|
||||
// const fileName = (options.media as Document.document).file_name || getFileNameByLocation(downloadOptions.location);
|
||||
// createDownloadAnchor(url, fileName, () => {
|
||||
// URL.revokeObjectURL(url);
|
||||
// });
|
||||
// }, noop);
|
||||
|
||||
// return promise;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import fileNameRFC from '../../helpers/string/fileNameRFC';
|
||||
import {getServiceMessagePort} from '../mtproto/mtproto.worker';
|
||||
import DownloadWriter from './downloadWriter';
|
||||
import FileStorage from './fileStorage';
|
||||
import StreamWriter from './streamWriter';
|
||||
|
||||
export default class DownloadStorage implements FileStorage {
|
||||
public getFile(fileName: string): Promise<any> {
|
||||
|
@ -41,6 +41,7 @@ import DownloadStorage from '../files/downloadStorage';
|
||||
import copy from '../../helpers/object/copy';
|
||||
import indexOfAndSplice from '../../helpers/array/indexOfAndSplice';
|
||||
import {MIME_TYPE_EXTENSION_MAP} from '../../environment/mimeTypeMap';
|
||||
import {getServiceMessagePort} from './mtproto.worker';
|
||||
|
||||
type Delayed = {
|
||||
offset: number,
|
||||
@ -465,7 +466,12 @@ export class ApiFileManager extends AppManager {
|
||||
|
||||
public download(options: DownloadOptions): DownloadPromise {
|
||||
const size = options.size ?? 0;
|
||||
const {dcId, location, downloadId} = options;
|
||||
const {dcId, location} = options;
|
||||
let {downloadId} = options;
|
||||
if(downloadId && !getServiceMessagePort()) {
|
||||
this.log.error('download fallback to blob', options);
|
||||
downloadId = undefined;
|
||||
}
|
||||
|
||||
const originalMimeType = options.mimeType;
|
||||
const convertMethod = this.getConvertMethod(originalMimeType);
|
||||
|
@ -28,6 +28,7 @@ import toggleStorages from '../../helpers/toggleStorages';
|
||||
import idleController from '../../helpers/idleController';
|
||||
import ServiceMessagePort from '../serviceWorker/serviceMessagePort';
|
||||
import App from '../../config/app';
|
||||
import deferredPromise, {CancellablePromise} from '../../helpers/cancellablePromise';
|
||||
|
||||
export type Mirrors = {
|
||||
state: State
|
||||
@ -64,6 +65,8 @@ class ApiManagerProxy extends MTProtoMessagePort {
|
||||
public serviceMessagePort: ServiceMessagePort<true>;
|
||||
private lastServiceWorker: ServiceWorker;
|
||||
|
||||
private pingServiceWorkerPromise: CancellablePromise<void>;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@ -199,6 +202,34 @@ class ApiManagerProxy extends MTProtoMessagePort {
|
||||
// this.sendState();
|
||||
}
|
||||
|
||||
public pingServiceWorkerWithIframe() {
|
||||
if(this.pingServiceWorkerPromise) {
|
||||
return this.pingServiceWorkerPromise;
|
||||
}
|
||||
|
||||
const promise = this.pingServiceWorkerPromise = deferredPromise<void>();
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.hidden = true;
|
||||
const onLoad = () => {
|
||||
setTimeout(() => { // ping once in 10 seconds
|
||||
this.pingServiceWorkerPromise = undefined;
|
||||
}, 10e3);
|
||||
|
||||
clearTimeout(timeout);
|
||||
iframe.remove();
|
||||
iframe.removeEventListener('load', onLoad);
|
||||
iframe.removeEventListener('error', onLoad);
|
||||
promise.resolve();
|
||||
};
|
||||
iframe.addEventListener('load', onLoad);
|
||||
iframe.addEventListener('error', onLoad);
|
||||
iframe.src = 'ping/' + (Math.random() * 0xFFFFFFFF);
|
||||
document.body.append(iframe);
|
||||
|
||||
const timeout = window.setTimeout(onLoad, 1e3);
|
||||
return promise;
|
||||
}
|
||||
|
||||
private attachServiceWorker(serviceWorker: ServiceWorker) {
|
||||
this.lastServiceWorker && this.serviceMessagePort.detachPort(this.lastServiceWorker);
|
||||
this.serviceMessagePort.attachSendPort(this.lastServiceWorker = serviceWorker);
|
||||
|
File diff suppressed because one or more lines are too long
@ -139,7 +139,7 @@ export default function handleDownload(serviceMessagePort: ServiceMessagePort<fa
|
||||
}
|
||||
|
||||
function onDownloadFetch(event: FetchEvent, params: string) {
|
||||
event.respondWith(pause(100).then(() => {
|
||||
const promise = pause(100).then(() => {
|
||||
const item = downloadMap.get(params);
|
||||
if(!item || (item.used && !DOWNLOAD_TEST)) {
|
||||
return;
|
||||
@ -149,9 +149,9 @@ function onDownloadFetch(event: FetchEvent, params: string) {
|
||||
const stream = item.readableStream;
|
||||
const response = new Response(stream, {headers: item.headers});
|
||||
return response;
|
||||
}));
|
||||
});
|
||||
|
||||
// event.respondWith(response);
|
||||
event.respondWith(promise);
|
||||
}
|
||||
|
||||
function cancelAllDownloads() {
|
||||
|
@ -132,6 +132,11 @@ const onFetch = (event: FetchEvent): void => {
|
||||
onDownloadFetch(event, params);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'ping': {
|
||||
event.respondWith(new Response('pong'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
log.error('fetch error', err);
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user