fix: センシティブな画像をアイコン・バナーに指定できないように

This commit is contained in:
kakkokari-gtyih 2024-04-08 18:16:50 +09:00
parent 960c4df48e
commit fafe980315
1 changed files with 14 additions and 0 deletions

View File

@ -74,6 +74,18 @@ export const meta = {
id: '75aedb19-2afd-4e6d-87fc-67941256fa60', id: '75aedb19-2afd-4e6d-87fc-67941256fa60',
}, },
avatarIsSensitive: {
message: 'The file specified as an avatar is marked as sensitive.',
code: 'AVATAR_IS_SENSITIVE',
id: '71bb5e53-4742-4609-b465-36081e131208',
},
bannerIsSensitive: {
message: 'The file specified as a banner is marked as sensitive.',
code: 'BANNER_IS_SENSITIVE',
id: 'e148b34c-9f33-4300-93e0-7817008fb366',
},
noSuchPage: { noSuchPage: {
message: 'No such page.', message: 'No such page.',
code: 'NO_SUCH_PAGE', code: 'NO_SUCH_PAGE',
@ -326,6 +338,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (avatar == null || avatar.userId !== user.id) throw new ApiError(meta.errors.noSuchAvatar); if (avatar == null || avatar.userId !== user.id) throw new ApiError(meta.errors.noSuchAvatar);
if (!avatar.type.startsWith('image/')) throw new ApiError(meta.errors.avatarNotAnImage); if (!avatar.type.startsWith('image/')) throw new ApiError(meta.errors.avatarNotAnImage);
if (avatar.isSensitive) throw new ApiError(meta.errors.avatarIsSensitive);
updates.avatarId = avatar.id; updates.avatarId = avatar.id;
updates.avatarUrl = this.driveFileEntityService.getPublicUrl(avatar, 'avatar'); updates.avatarUrl = this.driveFileEntityService.getPublicUrl(avatar, 'avatar');
@ -341,6 +354,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (banner == null || banner.userId !== user.id) throw new ApiError(meta.errors.noSuchBanner); if (banner == null || banner.userId !== user.id) throw new ApiError(meta.errors.noSuchBanner);
if (!banner.type.startsWith('image/')) throw new ApiError(meta.errors.bannerNotAnImage); if (!banner.type.startsWith('image/')) throw new ApiError(meta.errors.bannerNotAnImage);
if (banner.isSensitive) throw new ApiError(meta.errors.bannerIsSensitive);
updates.bannerId = banner.id; updates.bannerId = banner.id;
updates.bannerUrl = this.driveFileEntityService.getPublicUrl(banner); updates.bannerUrl = this.driveFileEntityService.getPublicUrl(banner);