Message: Fix support for edited media
This commit is contained in:
parent
d1d463c7d2
commit
23b8312f02
@ -396,6 +396,7 @@ function buildAudio(media: GramJs.TypeMessageMedia): ApiAudio | undefined {
|
||||
.map((thumb) => buildApiPhotoSize(thumb));
|
||||
|
||||
return {
|
||||
id: String(media.document.id),
|
||||
fileName: getFilenameFromDocument(media.document, 'audio'),
|
||||
thumbnailSizes,
|
||||
...pick(media.document, ['size', 'mimeType']),
|
||||
@ -424,6 +425,7 @@ function buildVoice(media: GramJs.TypeMessageMedia): ApiVoice | undefined {
|
||||
const { duration, waveform } = audioAttribute;
|
||||
|
||||
return {
|
||||
id: String(media.document.id),
|
||||
duration,
|
||||
waveform: waveform ? Array.from(waveform) : undefined,
|
||||
};
|
||||
@ -981,6 +983,7 @@ function buildUploadingMedia(
|
||||
const { data: inputWaveform } = interpolateArray(waveform, INPUT_WAVEFORM_LENGTH);
|
||||
return {
|
||||
voice: {
|
||||
id: LOCAL_MEDIA_UPLOADING_TEMP_ID,
|
||||
duration,
|
||||
waveform: inputWaveform,
|
||||
},
|
||||
@ -988,6 +991,7 @@ function buildUploadingMedia(
|
||||
} else if (mimeType.startsWith('audio/')) {
|
||||
return {
|
||||
audio: {
|
||||
id: LOCAL_MEDIA_UPLOADING_TEMP_ID,
|
||||
mimeType,
|
||||
fileName,
|
||||
size,
|
||||
|
||||
@ -75,7 +75,7 @@ async function download(
|
||||
) {
|
||||
const mediaMatch = url.startsWith('webDocument')
|
||||
? url.match(/(webDocument):(.+)/)
|
||||
: url.match(/(avatar|profile|photo|msg|stickerSet|sticker|wallpaper|gif|file)([-\d\w./]+)(\?size=\w+)?/);
|
||||
: url.match(/(avatar|profile|photo|msg|stickerSet|sticker|wallpaper|gif|file)([-\d\w./]+)(?::\d+)?(\?size=\w+)?/);
|
||||
if (!mediaMatch) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -63,6 +63,7 @@ export interface ApiVideo {
|
||||
}
|
||||
|
||||
export interface ApiAudio {
|
||||
id: string;
|
||||
size: number;
|
||||
mimeType: string;
|
||||
fileName: string;
|
||||
@ -73,6 +74,7 @@ export interface ApiAudio {
|
||||
}
|
||||
|
||||
export interface ApiVoice {
|
||||
id: string;
|
||||
duration: number;
|
||||
waveform?: number[];
|
||||
}
|
||||
|
||||
@ -140,7 +140,8 @@ export function getMessageMediaHash(
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const base = getMessageKey(message);
|
||||
const mediaId = (messagePhoto || messageVideo || sticker || audio || voice || document)!.id;
|
||||
const base = `${getMessageKey(message)}${mediaId ? `:${mediaId}` : ''}`;
|
||||
|
||||
if (messageVideo) {
|
||||
switch (target) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user