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));
|
.map((thumb) => buildApiPhotoSize(thumb));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
id: String(media.document.id),
|
||||||
fileName: getFilenameFromDocument(media.document, 'audio'),
|
fileName: getFilenameFromDocument(media.document, 'audio'),
|
||||||
thumbnailSizes,
|
thumbnailSizes,
|
||||||
...pick(media.document, ['size', 'mimeType']),
|
...pick(media.document, ['size', 'mimeType']),
|
||||||
@ -424,6 +425,7 @@ function buildVoice(media: GramJs.TypeMessageMedia): ApiVoice | undefined {
|
|||||||
const { duration, waveform } = audioAttribute;
|
const { duration, waveform } = audioAttribute;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
id: String(media.document.id),
|
||||||
duration,
|
duration,
|
||||||
waveform: waveform ? Array.from(waveform) : undefined,
|
waveform: waveform ? Array.from(waveform) : undefined,
|
||||||
};
|
};
|
||||||
@ -981,6 +983,7 @@ function buildUploadingMedia(
|
|||||||
const { data: inputWaveform } = interpolateArray(waveform, INPUT_WAVEFORM_LENGTH);
|
const { data: inputWaveform } = interpolateArray(waveform, INPUT_WAVEFORM_LENGTH);
|
||||||
return {
|
return {
|
||||||
voice: {
|
voice: {
|
||||||
|
id: LOCAL_MEDIA_UPLOADING_TEMP_ID,
|
||||||
duration,
|
duration,
|
||||||
waveform: inputWaveform,
|
waveform: inputWaveform,
|
||||||
},
|
},
|
||||||
@ -988,6 +991,7 @@ function buildUploadingMedia(
|
|||||||
} else if (mimeType.startsWith('audio/')) {
|
} else if (mimeType.startsWith('audio/')) {
|
||||||
return {
|
return {
|
||||||
audio: {
|
audio: {
|
||||||
|
id: LOCAL_MEDIA_UPLOADING_TEMP_ID,
|
||||||
mimeType,
|
mimeType,
|
||||||
fileName,
|
fileName,
|
||||||
size,
|
size,
|
||||||
|
|||||||
@ -75,7 +75,7 @@ async function download(
|
|||||||
) {
|
) {
|
||||||
const mediaMatch = url.startsWith('webDocument')
|
const mediaMatch = url.startsWith('webDocument')
|
||||||
? url.match(/(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) {
|
if (!mediaMatch) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,6 +63,7 @@ export interface ApiVideo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiAudio {
|
export interface ApiAudio {
|
||||||
|
id: string;
|
||||||
size: number;
|
size: number;
|
||||||
mimeType: string;
|
mimeType: string;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
@ -73,6 +74,7 @@ export interface ApiAudio {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiVoice {
|
export interface ApiVoice {
|
||||||
|
id: string;
|
||||||
duration: number;
|
duration: number;
|
||||||
waveform?: number[];
|
waveform?: number[];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,7 +140,8 @@ export function getMessageMediaHash(
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const base = getMessageKey(message);
|
const mediaId = (messagePhoto || messageVideo || sticker || audio || voice || document)!.id;
|
||||||
|
const base = `${getMessageKey(message)}${mediaId ? `:${mediaId}` : ''}`;
|
||||||
|
|
||||||
if (messageVideo) {
|
if (messageVideo) {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user