1
0
forked from mirror/misskey
This commit is contained in:
syuilo 2018-06-10 08:34:46 +09:00
parent 16d4b16872
commit bee77afb7f
2 changed files with 17 additions and 10 deletions

View File

@ -405,13 +405,17 @@ export const pack = (
delete _user.publicKey;
}
_user.avatarUrl = _user.avatarId != null
? `${config.drive_url}/${_user.avatarId}`
: `${config.drive_url}/default-avatar.jpg`;
if (_user.avatarUrl == null) {
_user.avatarUrl = _user.avatarId != null
? `${config.drive_url}/${_user.avatarId}`
: `${config.drive_url}/default-avatar.jpg`;
}
_user.bannerUrl = _user.bannerId != null
? `${config.drive_url}/${_user.bannerId}`
: null;
if (_user.bannerUrl == null) {
_user.bannerUrl = _user.bannerId != null
? `${config.drive_url}/${_user.bannerId}`
: null;
}
_user.wallpaperUrl = _user.wallpaperId != null
? `${config.drive_url}/${_user.wallpaperId}`

View File

@ -9,6 +9,7 @@ import webFinger from '../../webfinger';
import Resolver from '../resolver';
import { resolveImage } from './image';
import { isCollectionOrOrderedCollection, IObject, IPerson } from '../type';
import { IDriveFile } from '../../../models/drive-file';
const log = debug('misskey:activitypub');
@ -190,21 +191,23 @@ export async function updatePerson(value: string | IObject, resolver?: Resolver)
const summaryDOM = JSDOM.fragment(person.summary);
// アイコンとヘッダー画像をフェッチ
const [avatarId, bannerId] = (await Promise.all([
const [avatar, banner] = (await Promise.all<IDriveFile>([
person.icon,
person.image
].map(img =>
img == null
? Promise.resolve(null)
: resolveImage(exist, img)
))).map(file => file != null ? file._id : null);
)));
// Update user
await User.update({ _id: exist._id }, {
$set: {
updatedAt: new Date(),
avatarId,
bannerId,
avatarId: avatar ? avatar._id : null,
bannerId: banner ? banner._id : null,
avatarUrl: avatar && avatar.metadata.isMetaOnly ? avatar.metadata.url : null,
bannerUrl: banner && banner.metadata.isMetaOnly ? banner.metadata.url : null,
description: summaryDOM.textContent,
followersCount,
followingCount,