From 119d38ea08114427450eec11265b76bb27862bf5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 10 Jun 2018 08:41:57 +0900 Subject: [PATCH] Fix bug --- src/models/user.ts | 2 ++ src/remote/activitypub/models/person.ts | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/models/user.ts b/src/models/user.ts index c389f477ab..f0620a6cfd 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -48,6 +48,8 @@ type IUserBase = { usernameLower: string; avatarId: mongo.ObjectID; bannerId: mongo.ObjectID; + avatarUrl?: string; + bannerUrl?: string; wallpaperId: mongo.ObjectID; data: any; description: string; diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index 3bc04b8cbe..96e73406b2 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -118,19 +118,33 @@ export async function createPerson(value: any, resolver?: Resolver): Promise([ person.icon, person.image ].map(img => img == null ? Promise.resolve(null) : resolveImage(user, img) - ))).map(file => file != null ? file._id : null); + ))); - User.update({ _id: user._id }, { $set: { avatarId, bannerId } }); + const avatarId = avatar ? avatar._id : null; + const bannerId = banner ? banner._id : null; + const avatarUrl = avatar && avatar.metadata.isMetaOnly ? avatar.metadata.url : null; + const bannerUrl = banner && banner.metadata.isMetaOnly ? banner.metadata.url : null; + + await User.update({ _id: user._id }, { + $set: { + avatarId, + bannerId, + avatarUrl, + bannerUrl + } + }); user.avatarId = avatarId; user.bannerId = bannerId; + user.avatarUrl = avatarUrl; + user.bannerUrl = bannerUrl; //#endregion return user;