fix: cover duplicated block

This commit is contained in:
Hazel Koehler 2024-05-03 01:01:56 -04:00
parent ccdf069cdd
commit 5518c2b7d4

View file

@ -214,15 +214,7 @@ export class ApNoteService {
}
// 添付ファイル
// TODO: attachmentは必ずしもImageではない
// TODO: attachmentは必ずしも配列ではない
const limit = promiseLimit<MiDriveFile>(2);
const files = (await Promise.all(toArray(note.attachment).map(attach => (
limit(() => this.apImageService.resolveImage(actor, {
...attach,
sensitive: note.sensitive, // Noteがsensitiveなら添付もsensitiveにする
}))
))));
const files = await this.getNoteFiles(note, actor);
// リプライ
const reply: MiNote | null = note.inReplyTo
@ -441,21 +433,7 @@ export class ApNoteService {
}
// 添付ファイル
const attachments = toArray(note.attachment);
if (note.image)
for (const image of toArray(note.image))
attachments.push(image);
const limit = promiseLimit<MiDriveFile>(2);
const filePromises = attachments
.filter(attach => typeof(attach.url) === 'string')
.map(attach => (
limit(() => this.apImageService.resolveImage(actor, {
...attach,
sensitive: note.sensitive, // Noteがsensitiveなら添付もsensitiveにする
}))
));
const files = await Promise.all(filePromises);
const files = await this.getNoteFiles(note, actor);
// リプライ
const reply: MiNote | null = note.inReplyTo
@ -566,6 +544,28 @@ export class ApNoteService {
}
}
/**
* Downloads all attachments from the note.
*/
private async getNoteFiles(note: IPost, actor: MiRemoteUser): Promise<MiDriveFile[]> {
const attachments = toArray(note.attachment);
if (note.image)
for (const image of toArray(note.image))
attachments.push(image);
const limit = promiseLimit<MiDriveFile>(2);
const filePromises = attachments
.filter(attach => typeof (attach.url) === 'string')
.map(attach => (
limit(() => this.apImageService.resolveImage(actor, {
...attach,
sensitive: note.sensitive, // Noteがsensitiveなら添付もsensitiveにする
}))
));
return await Promise.all(filePromises);
}
/**
* Noteを解決します
*