From e13fe97ebb4c6e551dbce9cf1ad5581df1ced1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Sun, 24 Feb 2019 03:32:30 +0900 Subject: [PATCH] Update update.ts (#4357) * Update update.ts * Update update.ts * Update update.ts * Update update.ts --- src/server/api/endpoints/i/update.ts | 32 +++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index 22e76925b..099ef3399 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -159,7 +159,7 @@ export const meta = { message: 'The file specified as a banner is not an image.', code: 'BANNER_NOT_AN_IMAGE', id: '75aedb19-2afd-4e6d-87fc-67941256fa60' - }, + } } }; @@ -192,10 +192,14 @@ export default define(meta, async (ps, user, app) => { if (avatar == null) throw new ApiError(meta.errors.noSuchAvatar); if (!avatar.contentType.startsWith('image/')) throw new ApiError(meta.errors.avatarNotAnImage); - updates.avatarUrl = getDriveFileUrl(avatar, true); + if (avatar.metadata.deletedAt) { + updates.avatarUrl = null; + } else { + updates.avatarUrl = getDriveFileUrl(avatar, true); - if (avatar.metadata.properties.avgColor) { - updates.avatarColor = avatar.metadata.properties.avgColor; + if (avatar.metadata.properties.avgColor) { + updates.avatarColor = avatar.metadata.properties.avgColor; + } } } @@ -207,10 +211,14 @@ export default define(meta, async (ps, user, app) => { if (banner == null) throw new ApiError(meta.errors.noSuchBanner); if (!banner.contentType.startsWith('image/')) throw new ApiError(meta.errors.bannerNotAnImage); - updates.bannerUrl = getDriveFileUrl(banner, false); + if (banner.metadata.deletedAt) { + updates.bannerUrl = null; + } else { + updates.bannerUrl = getDriveFileUrl(banner, false); - if (banner.metadata.properties.avgColor) { - updates.bannerColor = banner.metadata.properties.avgColor; + if (banner.metadata.properties.avgColor) { + updates.bannerColor = banner.metadata.properties.avgColor; + } } } @@ -225,10 +233,14 @@ export default define(meta, async (ps, user, app) => { if (wallpaper == null) throw new Error('wallpaper not found'); - updates.wallpaperUrl = getDriveFileUrl(wallpaper); + if (wallpaper.metadata.deletedAt) { + updates.wallpaperUrl = null; + } else { + updates.wallpaperUrl = getDriveFileUrl(wallpaper); - if (wallpaper.metadata.properties.avgColor) { - updates.wallpaperColor = wallpaper.metadata.properties.avgColor; + if (wallpaper.metadata.properties.avgColor) { + updates.wallpaperColor = wallpaper.metadata.properties.avgColor; + } } } }