fix(backend): アンテナ等がポリシーで定められた上限を超えている場合、変更や追加ができないように (MisskeyIO#646)

This commit is contained in:
kabo2468 2024-06-16 20:11:25 +09:00 committed by GitHub
parent 5ff34d2f8f
commit 2b2975c0dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 281 additions and 19 deletions

View file

@ -25,6 +25,18 @@ export const meta = {
code: 'NO_SUCH_CLIP',
id: 'b4d92d70-b216-46fa-9a3f-a8c811699257',
},
clipLimitExceeded: {
message: 'You cannot update the clip because you have exceeded the limit of clips.',
code: 'CLIP_LIMIT_EXCEEDED',
id: 'fed46dd9-d99a-4a88-b23f-8d31c80b5b25',
},
clipNotesLimitExceeded: {
message: 'You cannot update the clip because you have exceeded the limit of notes in a clip.',
code: 'CLIP_NOTES_LIMIT_EXCEEDED',
id: '6f02ab37-66a4-4285-afaf-a8b1000e8f3f',
},
},
res: {
@ -58,6 +70,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
} catch (e) {
if (e instanceof ClipService.NoSuchClipError) {
throw new ApiError(meta.errors.noSuchClip);
} else if (e instanceof ClipService.ClipLimitExceededError) {
throw new ApiError(meta.errors.clipLimitExceeded);
} else if (e instanceof ClipService.ClipNotesLimitExceededError) {
throw new ApiError(meta.errors.clipNotesLimitExceeded);
}
throw e;
}