This commit is contained in:
syuilo 2018-07-28 07:52:48 +09:00
parent e46c494651
commit 5995b83f0d
2 changed files with 26 additions and 14 deletions

View file

@ -50,6 +50,7 @@ type IUserBase = {
avatarUrl?: string;
bannerUrl?: string;
wallpaperId: mongo.ObjectID;
wallpaperUrl?: string;
data: any;
description: string;
pinnedNoteId: mongo.ObjectID;
@ -400,21 +401,19 @@ export const pack = (
}
if (_user.avatarUrl == null) {
_user.avatarUrl = _user.avatarId != null
? `${config.drive_url}/${_user.avatarId}`
: `${config.drive_url}/default-avatar.jpg`;
_user.avatarUrl = `${config.drive_url}/default-avatar.jpg`;
// 互換性のため
if (_user.avatarId) {
_user.avatarUrl = `${config.drive_url}/${_user.avatarId}`;
}
}
if (_user.bannerUrl == null) {
_user.bannerUrl = _user.bannerId != null
? `${config.drive_url}/${_user.bannerId}`
: null;
// 互換性のため
if (_user.bannerId && _user.bannerUrl == null) {
_user.bannerUrl = `${config.drive_url}/${_user.bannerId}`;
}
_user.wallpaperUrl = _user.wallpaperId != null
? `${config.drive_url}/${_user.wallpaperId}`
: null;
if (!meId || !meId.equals(_user.id) || !opts.detail) {
delete _user.avatarId;
delete _user.bannerId;

View file

@ -4,6 +4,7 @@ import event from '../../../../stream';
import DriveFile from '../../../../models/drive-file';
import acceptAllFollowRequests from '../../../../services/following/requests/accept-all';
import { IApp } from '../../../../models/app';
import config from '../../../../config';
export const meta = {
desc: {
@ -81,7 +82,11 @@ export default async (params: any, user: ILocalUser, app: IApp) => new Promise(a
_id: avatarId
});
if (avatar != null && avatar.metadata.properties.avgColor) {
if (avatar == null) return rej('avatar not found');
updates.avatarUrl = avatar.metadata.url || `${config.drive_url}/${avatar._id}`;
if (avatar.metadata.properties.avgColor) {
updates.avatarColor = avatar.metadata.properties.avgColor;
}
}
@ -91,7 +96,11 @@ export default async (params: any, user: ILocalUser, app: IApp) => new Promise(a
_id: bannerId
});
if (banner != null && banner.metadata.properties.avgColor) {
if (banner == null) return rej('banner not found');
updates.bannerUrl = banner.metadata.url || `${config.drive_url}/${banner._id}`;
if (banner.metadata.properties.avgColor) {
updates.bannerColor = banner.metadata.properties.avgColor;
}
}
@ -101,7 +110,11 @@ export default async (params: any, user: ILocalUser, app: IApp) => new Promise(a
_id: wallpaperId
});
if (wallpaper != null && wallpaper.metadata.properties.avgColor) {
if (wallpaper == null) return rej('wallpaper not found');
updates.wallpaperUrl = wallpaper.metadata.url || `${config.drive_url}/${wallpaper._id}`;
if (wallpaper.metadata.properties.avgColor) {
updates.wallpaperColor = wallpaper.metadata.properties.avgColor;
}
}