Add migration

This commit is contained in:
syuilo 2019-03-01 11:35:04 +09:00
parent 528be133ff
commit 7cd2a9c9f2
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69

View file

@ -5,6 +5,7 @@ import resolveRemoteUser from '../../../../remote/resolve-user';
import define from '../../define';
import { apiLogger } from '../../logger';
import { ApiError } from '../../error';
import DriveFile from '../../../../models/drive-file';
const cursorOption = { fields: { data: false } };
@ -103,6 +104,33 @@ export default define(meta, async (ps, me) => {
}
}
// 後方互換性のため
// TODO: そのうち削除
if (user.avatarId) {
const avatar = await DriveFile.findOne({ _id: user.avatarId });
User.update({ _id: user._id }, {
$set: {
avatarUrl: avatar.metadata.thumbnailUrl,
}
});
}
if (user.bannerId) {
const banner = await DriveFile.findOne({ _id: user.bannerId });
User.update({ _id: user._id }, {
$set: {
bannerUrl: banner.metadata.webpublicUrl,
}
});
}
if (user.wallpaperId) {
const wallpaper = await DriveFile.findOne({ _id: user.wallpaperId });
User.update({ _id: user._id }, {
$set: {
wallpaperUrl: wallpaper.metadata.webpublicUrl,
}
});
}
return await pack(user, me, {
detail: true
});