Fix bug: リモートユーザーのアイコンとバナーの色が取得されていない問題を修正

This commit is contained in:
syuilo 2018-11-24 17:29:32 +09:00
parent 9e5a2e5b17
commit 95ba7e43b1
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
2 changed files with 11 additions and 1 deletions

View file

@ -38,6 +38,8 @@ type IUserBase = {
bannerId: mongo.ObjectID; bannerId: mongo.ObjectID;
avatarUrl?: string; avatarUrl?: string;
bannerUrl?: string; bannerUrl?: string;
avatarColor?: any;
bannerColor?: any;
wallpaperId: mongo.ObjectID; wallpaperId: mongo.ObjectID;
wallpaperUrl?: string; wallpaperUrl?: string;
data: any; data: any;

View file

@ -212,13 +212,17 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<IU
const bannerId = banner ? banner._id : null; const bannerId = banner ? banner._id : null;
const avatarUrl = getDriveFileUrl(avatar, true); const avatarUrl = getDriveFileUrl(avatar, true);
const bannerUrl = getDriveFileUrl(banner, false); const bannerUrl = getDriveFileUrl(banner, false);
const avatarColor = avatar && avatar.metadata.properties.avgColor ? avatar.metadata.properties.avgColor : null;
const bannerColor = banner && avatar.metadata.properties.avgColor ? banner.metadata.properties.avgColor : null;
await User.update({ _id: user._id }, { await User.update({ _id: user._id }, {
$set: { $set: {
avatarId, avatarId,
bannerId, bannerId,
avatarUrl, avatarUrl,
bannerUrl bannerUrl,
avatarColor,
bannerColor
} }
}); });
@ -226,6 +230,8 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<IU
user.bannerId = bannerId; user.bannerId = bannerId;
user.avatarUrl = avatarUrl; user.avatarUrl = avatarUrl;
user.bannerUrl = bannerUrl; user.bannerUrl = bannerUrl;
user.avatarColor = avatarColor;
user.bannerColor = bannerColor;
//#endregion //#endregion
await updateFeatured(user._id).catch(err => console.log(err)); await updateFeatured(user._id).catch(err => console.log(err));
@ -306,6 +312,8 @@ export async function updatePerson(uri: string, resolver?: Resolver, hint?: obje
bannerId: banner ? banner._id : null, bannerId: banner ? banner._id : null,
avatarUrl: getDriveFileUrl(avatar, true), avatarUrl: getDriveFileUrl(avatar, true),
bannerUrl: getDriveFileUrl(banner, false), bannerUrl: getDriveFileUrl(banner, false),
avatarColor: avatar && avatar.metadata.properties.avgColor ? avatar.metadata.properties.avgColor : null,
bannerColor: banner && banner.metadata.properties.avgColor ? banner.metadata.properties.avgColor : null,
description: htmlToMFM(person.summary), description: htmlToMFM(person.summary),
followersCount, followersCount,
followingCount, followingCount,