From c28e0abb7546c58cdb1cbff210eb1959679ef9fa Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sun, 13 Aug 2023 15:30:19 +0200 Subject: [PATCH] feat(backend/ApiCallService): allow limited access for suspend accounts --- .../backend/src/server/api/ApiCallService.ts | 17 +++--- packages/backend/src/server/api/endpoints.ts | 2 +- .../server/api/endpoints/antennas/create.ts | 2 +- .../server/api/endpoints/antennas/update.ts | 2 +- .../server/api/endpoints/channels/create.ts | 2 +- .../server/api/endpoints/channels/favorite.ts | 2 +- .../server/api/endpoints/channels/follow.ts | 2 +- .../api/endpoints/channels/unfavorite.ts | 2 +- .../server/api/endpoints/channels/unfollow.ts | 2 +- .../server/api/endpoints/clips/add-note.ts | 2 +- .../src/server/api/endpoints/clips/create.ts | 2 +- .../server/api/endpoints/clips/favorite.ts | 2 +- .../server/api/endpoints/clips/remove-note.ts | 2 +- .../server/api/endpoints/clips/unfavorite.ts | 2 +- .../src/server/api/endpoints/clips/update.ts | 2 +- .../api/endpoints/drive/files/create.ts | 2 +- .../endpoints/drive/files/upload-from-url.ts | 2 +- .../src/server/api/endpoints/flash/create.ts | 2 +- .../src/server/api/endpoints/flash/like.ts | 2 +- .../src/server/api/endpoints/flash/unlike.ts | 2 +- .../src/server/api/endpoints/flash/update.ts | 2 +- .../server/api/endpoints/following/create.ts | 2 +- .../api/endpoints/gallery/posts/create.ts | 2 +- .../api/endpoints/gallery/posts/like.ts | 2 +- .../api/endpoints/gallery/posts/unlike.ts | 2 +- .../api/endpoints/gallery/posts/update.ts | 2 +- .../api/endpoints/i/claim-achievement.ts | 2 +- .../server/api/endpoints/i/import-antennas.ts | 2 +- .../server/api/endpoints/i/import-blocking.ts | 2 +- .../api/endpoints/i/import-following.ts | 2 +- .../server/api/endpoints/i/import-muting.ts | 2 +- .../api/endpoints/i/import-user-lists.ts | 2 +- .../src/server/api/endpoints/i/move.ts | 2 +- .../backend/src/server/api/endpoints/i/pin.ts | 2 +- .../src/server/api/endpoints/mute/create.ts | 2 +- .../src/server/api/endpoints/notes/create.ts | 2 +- .../api/endpoints/notes/favorites/create.ts | 2 +- .../server/api/endpoints/notes/polls/vote.ts | 2 +- .../api/endpoints/notes/reactions/create.ts | 2 +- .../src/server/api/endpoints/pages/create.ts | 2 +- .../src/server/api/endpoints/pages/like.ts | 2 +- .../src/server/api/endpoints/pages/unlike.ts | 2 +- .../src/server/api/endpoints/pages/update.ts | 2 +- .../api/endpoints/renote-mute/create.ts | 2 +- .../users/lists/create-from-public.ts | 2 +- .../api/endpoints/users/lists/create.ts | 2 +- .../server/api/endpoints/users/lists/pull.ts | 2 +- .../server/api/endpoints/users/lists/push.ts | 2 +- packages/backend/test/e2e/suspend.ts | 53 +++++++++++++++++++ 49 files changed, 109 insertions(+), 55 deletions(-) create mode 100644 packages/backend/test/e2e/suspend.ts diff --git a/packages/backend/src/server/api/ApiCallService.ts b/packages/backend/src/server/api/ApiCallService.ts index 774ad98b40..ce8d3e6d9c 100644 --- a/packages/backend/src/server/api/ApiCallService.ts +++ b/packages/backend/src/server/api/ApiCallService.ts @@ -276,17 +276,10 @@ export class ApiCallService implements OnApplicationShutdown { id: '1384574d-a912-4b81-8601-c7b1c4085df1', httpStatusCode: 401, }); - } else if (user!.isSuspended) { - throw new ApiError({ - message: 'Your account has been suspended.', - code: 'YOUR_ACCOUNT_SUSPENDED', - kind: 'permission', - id: 'a8c724b3-6e9c-4b46-b1a8-bc3ed6258370', - }); } } - if (ep.meta.prohibitMoved) { + if (ep.meta.prohibitDeactivated) { if (user?.movedToUri) { throw new ApiError({ message: 'You have moved your account.', @@ -295,6 +288,14 @@ export class ApiCallService implements OnApplicationShutdown { id: '56f20ec9-fd06-4fa5-841b-edd6d7d4fa31', }); } + if (user?.isSuspended) { + throw new ApiError({ + message: 'Your account has been suspended.', + code: 'YOUR_ACCOUNT_SUSPENDED', + kind: 'permission', + id: 'a8c724b3-6e9c-4b46-b1a8-bc3ed6258370', + }); + } } if ((ep.meta.requireModerator || ep.meta.requireAdmin) && !user!.isRoot) { diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 097f9c151c..ee26165547 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -729,7 +729,7 @@ export interface IEndpointMeta { * 引っ越し済みのユーザーによるリクエストを禁止するか * 省略した場合は false として解釈されます。 */ - readonly prohibitMoved?: boolean; + readonly prohibitDeactivated?: boolean; /** * エンドポイントのリミテーションに関するやつ diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts index 8924568440..d9656c5b4c 100644 --- a/packages/backend/src/server/api/endpoints/antennas/create.ts +++ b/packages/backend/src/server/api/endpoints/antennas/create.ts @@ -18,7 +18,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:account', diff --git a/packages/backend/src/server/api/endpoints/antennas/update.ts b/packages/backend/src/server/api/endpoints/antennas/update.ts index 1f381caeff..310712ec91 100644 --- a/packages/backend/src/server/api/endpoints/antennas/update.ts +++ b/packages/backend/src/server/api/endpoints/antennas/update.ts @@ -16,7 +16,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:account', diff --git a/packages/backend/src/server/api/endpoints/channels/create.ts b/packages/backend/src/server/api/endpoints/channels/create.ts index 8364fd65d1..8f6451bca8 100644 --- a/packages/backend/src/server/api/endpoints/channels/create.ts +++ b/packages/backend/src/server/api/endpoints/channels/create.ts @@ -18,7 +18,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:channels', diff --git a/packages/backend/src/server/api/endpoints/channels/favorite.ts b/packages/backend/src/server/api/endpoints/channels/favorite.ts index ef75af4960..65c4777f42 100644 --- a/packages/backend/src/server/api/endpoints/channels/favorite.ts +++ b/packages/backend/src/server/api/endpoints/channels/favorite.ts @@ -15,7 +15,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:channels', diff --git a/packages/backend/src/server/api/endpoints/channels/follow.ts b/packages/backend/src/server/api/endpoints/channels/follow.ts index 655ab39285..b18bbe49d3 100644 --- a/packages/backend/src/server/api/endpoints/channels/follow.ts +++ b/packages/backend/src/server/api/endpoints/channels/follow.ts @@ -15,7 +15,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:channels', diff --git a/packages/backend/src/server/api/endpoints/channels/unfavorite.ts b/packages/backend/src/server/api/endpoints/channels/unfavorite.ts index 7937ef690e..47da73e2d6 100644 --- a/packages/backend/src/server/api/endpoints/channels/unfavorite.ts +++ b/packages/backend/src/server/api/endpoints/channels/unfavorite.ts @@ -14,7 +14,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:channels', diff --git a/packages/backend/src/server/api/endpoints/channels/unfollow.ts b/packages/backend/src/server/api/endpoints/channels/unfollow.ts index 1b585d647f..a3b4e4ed40 100644 --- a/packages/backend/src/server/api/endpoints/channels/unfollow.ts +++ b/packages/backend/src/server/api/endpoints/channels/unfollow.ts @@ -14,7 +14,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:channels', diff --git a/packages/backend/src/server/api/endpoints/clips/add-note.ts b/packages/backend/src/server/api/endpoints/clips/add-note.ts index bf7c5e7543..004f672ce3 100644 --- a/packages/backend/src/server/api/endpoints/clips/add-note.ts +++ b/packages/backend/src/server/api/endpoints/clips/add-note.ts @@ -18,7 +18,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:account', diff --git a/packages/backend/src/server/api/endpoints/clips/create.ts b/packages/backend/src/server/api/endpoints/clips/create.ts index 12e3733e1c..6a0425d9c6 100644 --- a/packages/backend/src/server/api/endpoints/clips/create.ts +++ b/packages/backend/src/server/api/endpoints/clips/create.ts @@ -17,7 +17,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:account', diff --git a/packages/backend/src/server/api/endpoints/clips/favorite.ts b/packages/backend/src/server/api/endpoints/clips/favorite.ts index 012543e675..47b042b88b 100644 --- a/packages/backend/src/server/api/endpoints/clips/favorite.ts +++ b/packages/backend/src/server/api/endpoints/clips/favorite.ts @@ -15,7 +15,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:clip-favorite', diff --git a/packages/backend/src/server/api/endpoints/clips/remove-note.ts b/packages/backend/src/server/api/endpoints/clips/remove-note.ts index 197a90e7f1..399a2e4777 100644 --- a/packages/backend/src/server/api/endpoints/clips/remove-note.ts +++ b/packages/backend/src/server/api/endpoints/clips/remove-note.ts @@ -15,7 +15,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:account', diff --git a/packages/backend/src/server/api/endpoints/clips/unfavorite.ts b/packages/backend/src/server/api/endpoints/clips/unfavorite.ts index 47d44da2cb..24d216608e 100644 --- a/packages/backend/src/server/api/endpoints/clips/unfavorite.ts +++ b/packages/backend/src/server/api/endpoints/clips/unfavorite.ts @@ -14,7 +14,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:clip-favorite', diff --git a/packages/backend/src/server/api/endpoints/clips/update.ts b/packages/backend/src/server/api/endpoints/clips/update.ts index 5a50855542..26f79d4e32 100644 --- a/packages/backend/src/server/api/endpoints/clips/update.ts +++ b/packages/backend/src/server/api/endpoints/clips/update.ts @@ -15,7 +15,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:account', diff --git a/packages/backend/src/server/api/endpoints/drive/files/create.ts b/packages/backend/src/server/api/endpoints/drive/files/create.ts index c52d03f289..7bc72c2ee6 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/create.ts @@ -18,7 +18,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, limit: { duration: ms('1hour'), diff --git a/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts b/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts index 4bb690ab34..ee91ee1e1b 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts @@ -22,7 +22,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:drive', } as const; diff --git a/packages/backend/src/server/api/endpoints/flash/create.ts b/packages/backend/src/server/api/endpoints/flash/create.ts index 4a91ee2495..8a68b90e44 100644 --- a/packages/backend/src/server/api/endpoints/flash/create.ts +++ b/packages/backend/src/server/api/endpoints/flash/create.ts @@ -16,7 +16,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:flash', diff --git a/packages/backend/src/server/api/endpoints/flash/like.ts b/packages/backend/src/server/api/endpoints/flash/like.ts index 2a170bf1fb..c1d29b779b 100644 --- a/packages/backend/src/server/api/endpoints/flash/like.ts +++ b/packages/backend/src/server/api/endpoints/flash/like.ts @@ -15,7 +15,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:flash-likes', diff --git a/packages/backend/src/server/api/endpoints/flash/unlike.ts b/packages/backend/src/server/api/endpoints/flash/unlike.ts index f6fcdfdf93..e65cefa9bd 100644 --- a/packages/backend/src/server/api/endpoints/flash/unlike.ts +++ b/packages/backend/src/server/api/endpoints/flash/unlike.ts @@ -14,7 +14,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:flash-likes', diff --git a/packages/backend/src/server/api/endpoints/flash/update.ts b/packages/backend/src/server/api/endpoints/flash/update.ts index 90cf302ee0..4b3c025807 100644 --- a/packages/backend/src/server/api/endpoints/flash/update.ts +++ b/packages/backend/src/server/api/endpoints/flash/update.ts @@ -15,7 +15,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:flash', diff --git a/packages/backend/src/server/api/endpoints/following/create.ts b/packages/backend/src/server/api/endpoints/following/create.ts index 36b4e9fae4..6269eb2a8f 100644 --- a/packages/backend/src/server/api/endpoints/following/create.ts +++ b/packages/backend/src/server/api/endpoints/following/create.ts @@ -24,7 +24,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:following', diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts index 957623ab14..e9c8f24bc5 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts @@ -18,7 +18,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:gallery', diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/like.ts b/packages/backend/src/server/api/endpoints/gallery/posts/like.ts index f12456fbdb..2d9928f569 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/like.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/like.ts @@ -15,7 +15,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:gallery-likes', diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts b/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts index 339452cdef..40c1ff6c9e 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts @@ -14,7 +14,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:gallery-likes', diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts index c9bd21ab45..81508e9b11 100644 --- a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts +++ b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts @@ -16,7 +16,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:gallery', diff --git a/packages/backend/src/server/api/endpoints/i/claim-achievement.ts b/packages/backend/src/server/api/endpoints/i/claim-achievement.ts index b2a70f1681..a93358de8e 100644 --- a/packages/backend/src/server/api/endpoints/i/claim-achievement.ts +++ b/packages/backend/src/server/api/endpoints/i/claim-achievement.ts @@ -9,7 +9,7 @@ import { AchievementService, ACHIEVEMENT_TYPES } from '@/core/AchievementService export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/i/import-antennas.ts b/packages/backend/src/server/api/endpoints/i/import-antennas.ts index 4bae2d1562..864ed9bfb5 100644 --- a/packages/backend/src/server/api/endpoints/i/import-antennas.ts +++ b/packages/backend/src/server/api/endpoints/i/import-antennas.ts @@ -16,7 +16,7 @@ import { ApiError } from '../../error.js'; export const meta = { secure: true, requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, limit: { duration: ms('1hour'), diff --git a/packages/backend/src/server/api/endpoints/i/import-blocking.ts b/packages/backend/src/server/api/endpoints/i/import-blocking.ts index 37d550c330..4ccac716ea 100644 --- a/packages/backend/src/server/api/endpoints/i/import-blocking.ts +++ b/packages/backend/src/server/api/endpoints/i/import-blocking.ts @@ -15,7 +15,7 @@ import { ApiError } from '../../error.js'; export const meta = { secure: true, requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, limit: { duration: ms('1hour'), diff --git a/packages/backend/src/server/api/endpoints/i/import-following.ts b/packages/backend/src/server/api/endpoints/i/import-following.ts index b29a361d0d..309f58ec0c 100644 --- a/packages/backend/src/server/api/endpoints/i/import-following.ts +++ b/packages/backend/src/server/api/endpoints/i/import-following.ts @@ -15,7 +15,7 @@ import { ApiError } from '../../error.js'; export const meta = { secure: true, requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, limit: { duration: ms('1hour'), max: 1, diff --git a/packages/backend/src/server/api/endpoints/i/import-muting.ts b/packages/backend/src/server/api/endpoints/i/import-muting.ts index b148f60d86..df78101c1f 100644 --- a/packages/backend/src/server/api/endpoints/i/import-muting.ts +++ b/packages/backend/src/server/api/endpoints/i/import-muting.ts @@ -15,7 +15,7 @@ import { ApiError } from '../../error.js'; export const meta = { secure: true, requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, limit: { duration: ms('1hour'), diff --git a/packages/backend/src/server/api/endpoints/i/import-user-lists.ts b/packages/backend/src/server/api/endpoints/i/import-user-lists.ts index 9cf54d17bf..cd967bf2c0 100644 --- a/packages/backend/src/server/api/endpoints/i/import-user-lists.ts +++ b/packages/backend/src/server/api/endpoints/i/import-user-lists.ts @@ -15,7 +15,7 @@ import { ApiError } from '../../error.js'; export const meta = { secure: true, requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, limit: { duration: ms('1hour'), max: 1, diff --git a/packages/backend/src/server/api/endpoints/i/move.ts b/packages/backend/src/server/api/endpoints/i/move.ts index 62d7116ba2..49c8c66f39 100644 --- a/packages/backend/src/server/api/endpoints/i/move.ts +++ b/packages/backend/src/server/api/endpoints/i/move.ts @@ -25,7 +25,7 @@ export const meta = { secure: true, requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, limit: { duration: ms('1day'), max: 5, diff --git a/packages/backend/src/server/api/endpoints/i/pin.ts b/packages/backend/src/server/api/endpoints/i/pin.ts index 4407a1008c..feed915183 100644 --- a/packages/backend/src/server/api/endpoints/i/pin.ts +++ b/packages/backend/src/server/api/endpoints/i/pin.ts @@ -13,7 +13,7 @@ export const meta = { tags: ['account', 'notes'], requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:account', diff --git a/packages/backend/src/server/api/endpoints/mute/create.ts b/packages/backend/src/server/api/endpoints/mute/create.ts index b74eb6733e..1786d550ba 100644 --- a/packages/backend/src/server/api/endpoints/mute/create.ts +++ b/packages/backend/src/server/api/endpoints/mute/create.ts @@ -16,7 +16,7 @@ export const meta = { tags: ['account'], requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:mutes', diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 75c837b502..5dd85e9481 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -23,7 +23,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, limit: { duration: ms('1hour'), diff --git a/packages/backend/src/server/api/endpoints/notes/favorites/create.ts b/packages/backend/src/server/api/endpoints/notes/favorites/create.ts index fee398fb83..e9831e813f 100644 --- a/packages/backend/src/server/api/endpoints/notes/favorites/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/favorites/create.ts @@ -17,7 +17,7 @@ export const meta = { tags: ['notes', 'favorites'], requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:favorites', diff --git a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts index c1ce443679..57b65eece0 100644 --- a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts +++ b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts @@ -22,7 +22,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:votes', diff --git a/packages/backend/src/server/api/endpoints/notes/reactions/create.ts b/packages/backend/src/server/api/endpoints/notes/reactions/create.ts index 245157921b..c078f226ab 100644 --- a/packages/backend/src/server/api/endpoints/notes/reactions/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/reactions/create.ts @@ -14,7 +14,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:reactions', diff --git a/packages/backend/src/server/api/endpoints/pages/create.ts b/packages/backend/src/server/api/endpoints/pages/create.ts index 559f97b2d3..a77057b4f7 100644 --- a/packages/backend/src/server/api/endpoints/pages/create.ts +++ b/packages/backend/src/server/api/endpoints/pages/create.ts @@ -18,7 +18,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:pages', diff --git a/packages/backend/src/server/api/endpoints/pages/like.ts b/packages/backend/src/server/api/endpoints/pages/like.ts index 0504be20ed..a88d523a6f 100644 --- a/packages/backend/src/server/api/endpoints/pages/like.ts +++ b/packages/backend/src/server/api/endpoints/pages/like.ts @@ -15,7 +15,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:page-likes', diff --git a/packages/backend/src/server/api/endpoints/pages/unlike.ts b/packages/backend/src/server/api/endpoints/pages/unlike.ts index b913fc7249..b9a2666fb7 100644 --- a/packages/backend/src/server/api/endpoints/pages/unlike.ts +++ b/packages/backend/src/server/api/endpoints/pages/unlike.ts @@ -14,7 +14,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:page-likes', diff --git a/packages/backend/src/server/api/endpoints/pages/update.ts b/packages/backend/src/server/api/endpoints/pages/update.ts index 679b1ed464..975137cb0c 100644 --- a/packages/backend/src/server/api/endpoints/pages/update.ts +++ b/packages/backend/src/server/api/endpoints/pages/update.ts @@ -16,7 +16,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:pages', diff --git a/packages/backend/src/server/api/endpoints/renote-mute/create.ts b/packages/backend/src/server/api/endpoints/renote-mute/create.ts index e32771c031..934a2c6a09 100644 --- a/packages/backend/src/server/api/endpoints/renote-mute/create.ts +++ b/packages/backend/src/server/api/endpoints/renote-mute/create.ts @@ -17,7 +17,7 @@ export const meta = { tags: ['account'], requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:mutes', diff --git a/packages/backend/src/server/api/endpoints/users/lists/create-from-public.ts b/packages/backend/src/server/api/endpoints/users/lists/create-from-public.ts index 9ce040546b..fe32009eb3 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/create-from-public.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/create-from-public.ts @@ -17,7 +17,7 @@ import { UserListService } from '@/core/UserListService.js'; export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, res: { type: 'object', optional: false, nullable: false, diff --git a/packages/backend/src/server/api/endpoints/users/lists/create.ts b/packages/backend/src/server/api/endpoints/users/lists/create.ts index 90f07f13f8..425b05a3ad 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/create.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/create.ts @@ -18,7 +18,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:account', diff --git a/packages/backend/src/server/api/endpoints/users/lists/pull.ts b/packages/backend/src/server/api/endpoints/users/lists/pull.ts index 59e765d5d0..94f2d0a526 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/pull.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/pull.ts @@ -17,7 +17,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:account', diff --git a/packages/backend/src/server/api/endpoints/users/lists/push.ts b/packages/backend/src/server/api/endpoints/users/lists/push.ts index 831c0f6837..da51f23281 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/push.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/push.ts @@ -17,7 +17,7 @@ export const meta = { requireCredential: true, - prohibitMoved: true, + prohibitDeactivated: true, kind: 'write:account', diff --git a/packages/backend/test/e2e/suspend.ts b/packages/backend/test/e2e/suspend.ts new file mode 100644 index 0000000000..8cefb97ed6 --- /dev/null +++ b/packages/backend/test/e2e/suspend.ts @@ -0,0 +1,53 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +process.env.NODE_ENV = 'test'; + +import * as assert from 'assert'; +import { loadConfig } from '@/config.js'; +import { User, UsersRepository } from '@/models/index.js'; +import { jobQueue } from '@/boot/common.js'; +import { secureRndstr } from '@/misc/secure-rndstr.js'; +import { uploadFile, signup, startServer, initTestDb, api, sleep, successfulApiCall } from '../utils.js'; +import type { INestApplicationContext } from '@nestjs/common'; +import type * as misskey from 'misskey-js'; + +describe('Account Suspension', () => { + let app: INestApplicationContext; + + let root: misskey.entities.MeSignup; + let alice: misskey.entities.MeSignup; + + beforeAll(async () => { + app = await startServer(); + root = await signup({ username: 'root' }); + alice = await signup({ username: 'alice' }); + + await api('admin/suspend-user', { userId: alice.id }, root); + }, 1000 * 60 * 2); + + afterAll(async () => { + await app.close(); + }); + + it('Cannot create notes', async () => { + const res = await api('notes/create', { text: 'foo' }, alice); + + assert.strictEqual(res.status, 403); + assert.strictEqual(res.body.error.code, 'YOUR_ACCOUNT_SUSPENDED'); + assert.strictEqual(res.body.error.id, 'a8c724b3-6e9c-4b46-b1a8-bc3ed6258370'); + }); + + it('Can see notes', async () => { + const createRes = await api('notes/create', { text: 'bar' }, root); + assert.strictEqual(createRes.status, 200); + assert.strictEqual(createRes.body.createdNote.text, 'bar'); + + const showRes = await api('notes/show', { noteId: createRes.body.createdNote.id }, alice); + assert.strictEqual(showRes.status, 200); + assert.strictEqual(showRes.body.text, 'bar'); + assert.strictEqual(showRes.body.id, createRes.body.createdNote.id); + }); +});