From 09f67204b1f7e433e3309a7526adc3d9c03cb847 Mon Sep 17 00:00:00 2001 From: okayurisotto Date: Mon, 3 Jul 2023 20:22:59 +0900 Subject: [PATCH] =?UTF-8?q?WIP(`ApPersonService.ts`):=20=E5=8F=AF=E8=AA=AD?= =?UTF-8?q?=E6=80=A7=E3=81=AE=E4=BD=8E=E3=81=84=E4=B8=89=E9=A0=85=E6=BC=94?= =?UTF-8?q?=E7=AE=97=E5=AD=90=E3=82=92=E5=89=8A=E9=99=A4=E3=81=97=E3=81=A4?= =?UTF-8?q?=E3=81=A4non-null=20assertion=E3=82=92=E5=9B=9E=E9=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit エラーメッセージを考える必要がある。 --- .../activitypub/models/ApPersonService.ts | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index c52f223d5a..ad72dbba55 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -341,14 +341,11 @@ export class ApPersonService implements OnModuleInit { this.hashtagService.updateUsertags(user, tags); //#region アバターとヘッダー画像をフェッチ - const [avatar, banner] = await Promise.all([ - person.icon, - person.image, - ].map(img => - img == null - ? Promise.resolve(null) - : this.apImageService.resolveImage(user!, img).catch(() => null), - )); + const [avatar, banner] = await Promise.all([person.icon, person.image].map(img => { + if (img == null) return null; + if (user == null) throw new Error(''); // TODO + return this.apImageService.resolveImage(user, img).catch(() => null); + })); const avatarId = avatar ? avatar.id : null; const bannerId = banner ? banner.id : null; @@ -427,14 +424,10 @@ export class ApPersonService implements OnModuleInit { this.logger.info(`Updating the Person: ${person.id}`); // アバターとヘッダー画像をフェッチ - const [avatar, banner] = await Promise.all([ - person.icon, - person.image, - ].map(img => - img == null - ? Promise.resolve(null) - : this.apImageService.resolveImage(exist, img).catch(() => null), - )); + const [avatar, banner] = await Promise.all([person.icon, person.image].map(img => { + if (img == null) return null; + return this.apImageService.resolveImage(exist, img).catch(() => null); + })); // カスタム絵文字取得 const emojis = await this.apNoteService.extractEmojis(person.tag ?? [], exist.host).catch(e => {