Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend/ApiCallService): allow limited access for suspended accounts #11715

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions packages/backend/src/server/api/ApiCallService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ export interface IEndpointMeta {
* 引っ越し済みのユーザーによるリクエストを禁止するか
* 省略した場合は false として解釈されます。
*/
readonly prohibitMoved?: boolean;
readonly prohibitDeactivated?: boolean;

/**
* エンドポイントのリミテーションに関するやつ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:account',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:account',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:channels',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:channels',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:channels',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:channels',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:channels',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:account',

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/clips/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:account',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:clip-favorite',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:account',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:clip-favorite',

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/clips/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:account',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

limit: {
duration: ms('1hour'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:drive',
} as const;
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/flash/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:flash',

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/flash/like.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:flash-likes',

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/flash/unlike.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:flash-likes',

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/flash/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:flash',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:following',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:gallery',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:gallery-likes',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:gallery-likes',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:gallery',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ApiError } from '../../error.js';
export const meta = {
secure: true,
requireCredential: true,
prohibitMoved: true,
prohibitDeactivated: true,

limit: {
duration: ms('1hour'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ApiError } from '../../error.js';
export const meta = {
secure: true,
requireCredential: true,
prohibitMoved: true,
prohibitDeactivated: true,

limit: {
duration: ms('1hour'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ApiError } from '../../error.js';
export const meta = {
secure: true,
requireCredential: true,
prohibitMoved: true,
prohibitDeactivated: true,

limit: {
duration: ms('1hour'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/i/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const meta = {

secure: true,
requireCredential: true,
prohibitMoved: true,
prohibitDeactivated: true,
limit: {
duration: ms('1day'),
max: 5,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/i/pin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const meta = {
tags: ['account', 'notes'],

requireCredential: true,
prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:account',

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/mute/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const meta = {
tags: ['account'],

requireCredential: true,
prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:mutes',

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/notes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

limit: {
duration: ms('1hour'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const meta = {
tags: ['notes', 'favorites'],

requireCredential: true,
prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:favorites',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:votes',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:reactions',

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/pages/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:pages',

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/pages/like.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const meta = {

requireCredential: true,

prohibitMoved: true,
prohibitDeactivated: true,

kind: 'write:page-likes',

Expand Down
Loading
Loading