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: {
|
params: {
|
||||||
parseMode?: string | null
|
parseMode?: string | null
|
||||||
progressCallback?: (uploaded: number, total: number) => void
|
progressCallback?: (uploaded: number, total: number) => void
|
||||||
|
uploadPeer?: tl.TypeInputPeer
|
||||||
},
|
},
|
||||||
uploadMedia?: boolean
|
uploadMedia?: boolean
|
||||||
): Promise<tl.TypeInputMedia>
|
): Promise<tl.TypeInputMedia>
|
||||||
|
|
|
@ -29,6 +29,7 @@ export async function _normalizeInputMedia(
|
||||||
params: {
|
params: {
|
||||||
parseMode?: string | null
|
parseMode?: string | null
|
||||||
progressCallback?: (uploaded: number, total: number) => void
|
progressCallback?: (uploaded: number, total: number) => void
|
||||||
|
uploadPeer?: tl.TypeInputPeer
|
||||||
},
|
},
|
||||||
uploadMedia = false
|
uploadMedia = false
|
||||||
): Promise<tl.TypeInputMedia> {
|
): Promise<tl.TypeInputMedia> {
|
||||||
|
@ -216,6 +217,8 @@ export async function _normalizeInputMedia(
|
||||||
mime = uploaded.mime
|
mime = uploaded.mime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uploadPeer = params.uploadPeer ?? { _: 'inputPeerSelf' }
|
||||||
|
|
||||||
const uploadMediaIfNeeded = async (
|
const uploadMediaIfNeeded = async (
|
||||||
inputMedia: tl.TypeInputMedia,
|
inputMedia: tl.TypeInputMedia,
|
||||||
photo: boolean
|
photo: boolean
|
||||||
|
@ -224,7 +227,7 @@ export async function _normalizeInputMedia(
|
||||||
|
|
||||||
const res = await this.call({
|
const res = await this.call({
|
||||||
_: 'messages.uploadMedia',
|
_: 'messages.uploadMedia',
|
||||||
peer: { _: 'inputPeerSelf' },
|
peer: uploadPeer,
|
||||||
media: inputMedia,
|
media: inputMedia,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,11 @@ export async function sendMediaGroup(
|
||||||
|
|
||||||
const inputMedia = await this._normalizeInputMedia(media, {
|
const inputMedia = await this._normalizeInputMedia(media, {
|
||||||
progressCallback: params.progressCallback?.bind(null, i),
|
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(
|
const [message, entities] = await this._parseEntities(
|
||||||
// some types dont have `caption` field, and ts warns us,
|
// some types dont have `caption` field, and ts warns us,
|
||||||
|
|
Loading…
Reference in a new issue