diff --git a/src/models/user.ts b/src/models/user.ts index 2d4d7dc18..c389f477a 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -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}` diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index b720c445c..3bc04b8cb 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -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([ 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,