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

View File

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

View File

@ -4,6 +4,7 @@ import event from '../../../../stream';
import DriveFile from '../../../../models/drive-file'; import DriveFile from '../../../../models/drive-file';
import acceptAllFollowRequests from '../../../../services/following/requests/accept-all'; import acceptAllFollowRequests from '../../../../services/following/requests/accept-all';
import { IApp } from '../../../../models/app'; import { IApp } from '../../../../models/app';
import config from '../../../../config';
export const meta = { export const meta = {
desc: { desc: {
@ -81,7 +82,11 @@ export default async (params: any, user: ILocalUser, app: IApp) => new Promise(a
_id: avatarId _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; updates.avatarColor = avatar.metadata.properties.avgColor;
} }
} }
@ -91,7 +96,11 @@ export default async (params: any, user: ILocalUser, app: IApp) => new Promise(a
_id: bannerId _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; updates.bannerColor = banner.metadata.properties.avgColor;
} }
} }
@ -101,7 +110,11 @@ export default async (params: any, user: ILocalUser, app: IApp) => new Promise(a
_id: wallpaperId _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; updates.wallpaperColor = wallpaper.metadata.properties.avgColor;
} }
} }