mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-25 07:25:12 +00:00
fix: revert previous change and filter in the note processing instead
This commit is contained in:
parent
182ddd2c49
commit
4b24cce2c5
2 changed files with 23 additions and 19 deletions
|
@ -48,21 +48,20 @@ export class ApImageService {
|
|||
}
|
||||
|
||||
const image = await this.apResolverService.createResolver().resolve(value);
|
||||
const imageUrl = image.url ?? image.href;
|
||||
|
||||
if (imageUrl == null) {
|
||||
if (image.url == null) {
|
||||
throw new Error('invalid image: url not provided');
|
||||
}
|
||||
|
||||
if (typeof imageUrl !== 'string') {
|
||||
throw new Error('invalid image: unexpected type of url: ' + JSON.stringify(imageUrl, null, 2));
|
||||
if (typeof image.url !== 'string') {
|
||||
throw new Error('invalid image: unexpected type of url: ' + JSON.stringify(image.url, null, 2));
|
||||
}
|
||||
|
||||
if (!checkHttps(imageUrl)) {
|
||||
throw new Error('invalid image: unexpected schema of url: ' + imageUrl);
|
||||
if (!checkHttps(image.url)) {
|
||||
throw new Error('invalid image: unexpected schema of url: ' + image.url);
|
||||
}
|
||||
|
||||
this.logger.info(`Creating the Image: ${imageUrl}`);
|
||||
this.logger.info(`Creating the Image: ${image.url}`);
|
||||
|
||||
const instance = await this.metaService.fetch();
|
||||
|
||||
|
@ -78,17 +77,17 @@ export class ApImageService {
|
|||
});
|
||||
|
||||
const file = await this.driveService.uploadFromUrl({
|
||||
url: imageUrl,
|
||||
url: image.url,
|
||||
user: actor,
|
||||
uri: imageUrl,
|
||||
uri: image.url,
|
||||
sensitive: image.sensitive,
|
||||
isLink: !shouldBeCached,
|
||||
comment: truncate(image.name ?? undefined, DB_MAX_IMAGE_COMMENT_LENGTH),
|
||||
});
|
||||
if (!file.isLink || file.url === imageUrl) return file;
|
||||
if (!file.isLink || file.url === image.url) return file;
|
||||
|
||||
// URLが異なっている場合、同じ画像が以前に異なるURLで登録されていたということなので、URLを更新する
|
||||
await this.driveFilesRepository.update({ id: file.id }, { url: imageUrl, uri: imageUrl });
|
||||
await this.driveFilesRepository.update({ id: file.id }, { url: image.url, uri: image.url });
|
||||
return await this.driveFilesRepository.findOneByOrFail({ id: file.id });
|
||||
}
|
||||
|
||||
|
|
|
@ -441,15 +441,20 @@ export class ApNoteService {
|
|||
}
|
||||
|
||||
// 添付ファイル
|
||||
// TODO: attachmentは必ずしもImageではない
|
||||
// TODO: attachmentは必ずしも配列ではない
|
||||
const attachments = toArray(note.attachment);
|
||||
if (note.image)
|
||||
attachments.push(note.image);
|
||||
|
||||
const limit = promiseLimit<MiDriveFile>(2);
|
||||
const files = (await Promise.all(toArray(note.attachment).map(attach => (
|
||||
const filePromises = attachments
|
||||
.filter(attach => toArray(attach.type)?.includes('Image'))
|
||||
.map(attach => (
|
||||
limit(() => this.apImageService.resolveImage(actor, {
|
||||
...attach,
|
||||
sensitive: note.sensitive, // Noteがsensitiveなら添付もsensitiveにする
|
||||
}))
|
||||
))));
|
||||
));
|
||||
const files = await Promise.all(filePromises);
|
||||
|
||||
// リプライ
|
||||
const reply: MiNote | null = note.inReplyTo
|
||||
|
|
Loading…
Reference in a new issue