1
0
forked from mirror/misskey
This commit is contained in:
syuilo 2018-06-10 08:41:57 +09:00
parent bee77afb7f
commit 119d38ea08
2 changed files with 19 additions and 3 deletions

View File

@ -48,6 +48,8 @@ type IUserBase = {
usernameLower: string; usernameLower: string;
avatarId: mongo.ObjectID; avatarId: mongo.ObjectID;
bannerId: mongo.ObjectID; bannerId: mongo.ObjectID;
avatarUrl?: string;
bannerUrl?: string;
wallpaperId: mongo.ObjectID; wallpaperId: mongo.ObjectID;
data: any; data: any;
description: string; description: string;

View File

@ -118,19 +118,33 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
} }
//#region アイコンとヘッダー画像をフェッチ //#region アイコンとヘッダー画像をフェッチ
const [avatarId, bannerId] = (await Promise.all([ const [avatar, banner] = (await Promise.all<IDriveFile>([
person.icon, person.icon,
person.image person.image
].map(img => ].map(img =>
img == null img == null
? Promise.resolve(null) ? Promise.resolve(null)
: resolveImage(user, img) : 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.avatarId = avatarId;
user.bannerId = bannerId; user.bannerId = bannerId;
user.avatarUrl = avatarUrl;
user.bannerUrl = bannerUrl;
//#endregion //#endregion
return user; return user;