fix(client): correct sending of newly uploaded files in media groups
This commit is contained in:
parent
b38f2cd6ae
commit
a33548e790
3 changed files with 10 additions and 2 deletions
|
@ -1587,6 +1587,7 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
params: {
|
||||
parseMode?: string | null
|
||||
progressCallback?: (uploaded: number, total: number) => void
|
||||
uploadPeer?: tl.TypeInputPeer
|
||||
},
|
||||
uploadMedia?: boolean
|
||||
): Promise<tl.TypeInputMedia>
|
||||
|
|
|
@ -29,6 +29,7 @@ export async function _normalizeInputMedia(
|
|||
params: {
|
||||
parseMode?: string | null
|
||||
progressCallback?: (uploaded: number, total: number) => void
|
||||
uploadPeer?: tl.TypeInputPeer
|
||||
},
|
||||
uploadMedia = false
|
||||
): Promise<tl.TypeInputMedia> {
|
||||
|
@ -216,6 +217,8 @@ export async function _normalizeInputMedia(
|
|||
mime = uploaded.mime
|
||||
}
|
||||
|
||||
const uploadPeer = params.uploadPeer ?? { _: 'inputPeerSelf' }
|
||||
|
||||
const uploadMediaIfNeeded = async (
|
||||
inputMedia: tl.TypeInputMedia,
|
||||
photo: boolean
|
||||
|
@ -224,7 +227,7 @@ export async function _normalizeInputMedia(
|
|||
|
||||
const res = await this.call({
|
||||
_: 'messages.uploadMedia',
|
||||
peer: { _: 'inputPeerSelf' },
|
||||
peer: uploadPeer,
|
||||
media: inputMedia,
|
||||
})
|
||||
|
||||
|
|
|
@ -148,7 +148,11 @@ export async function sendMediaGroup(
|
|||
|
||||
const inputMedia = await this._normalizeInputMedia(media, {
|
||||
progressCallback: params.progressCallback?.bind(null, i),
|
||||
})
|
||||
// i have no fucking clue why we should upload it manually,
|
||||
// but otherwise Telegram throws MEDIA_INVALID
|
||||
// fuck my life
|
||||
uploadPeer: peer
|
||||
}, true)
|
||||
|
||||
const [message, entities] = await this._parseEntities(
|
||||
// some types dont have `caption` field, and ts warns us,
|
||||
|
|
Loading…
Reference in a new issue