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; delete _user.publicKey;
} }
_user.avatarUrl = _user.avatarId != null if (_user.avatarUrl == null) {
? `${config.drive_url}/${_user.avatarId}` _user.avatarUrl = _user.avatarId != null
: `${config.drive_url}/default-avatar.jpg`; ? `${config.drive_url}/${_user.avatarId}`
: `${config.drive_url}/default-avatar.jpg`;
}
_user.bannerUrl = _user.bannerId != null if (_user.bannerUrl == null) {
? `${config.drive_url}/${_user.bannerId}` _user.bannerUrl = _user.bannerId != null
: null; ? `${config.drive_url}/${_user.bannerId}`
: null;
}
_user.wallpaperUrl = _user.wallpaperId != null _user.wallpaperUrl = _user.wallpaperId != null
? `${config.drive_url}/${_user.wallpaperId}` ? `${config.drive_url}/${_user.wallpaperId}`

View File

@ -9,6 +9,7 @@ import webFinger from '../../webfinger';
import Resolver from '../resolver'; import Resolver from '../resolver';
import { resolveImage } from './image'; import { resolveImage } from './image';
import { isCollectionOrOrderedCollection, IObject, IPerson } from '../type'; import { isCollectionOrOrderedCollection, IObject, IPerson } from '../type';
import { IDriveFile } from '../../../models/drive-file';
const log = debug('misskey:activitypub'); 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 summaryDOM = JSDOM.fragment(person.summary);
// アイコンとヘッダー画像をフェッチ // アイコンとヘッダー画像をフェッチ
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(exist, img) : resolveImage(exist, img)
))).map(file => file != null ? file._id : null); )));
// Update user // Update user
await User.update({ _id: exist._id }, { await User.update({ _id: exist._id }, {
$set: { $set: {
updatedAt: new Date(), updatedAt: new Date(),
avatarId, avatarId: avatar ? avatar._id : null,
bannerId, 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, description: summaryDOM.textContent,
followersCount, followersCount,
followingCount, followingCount,