diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-11-12 02:02:25 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-11-12 02:02:25 +0900 |
| commit | 0e4a111f81cceed275d9bec2695f6e401fb654d8 (patch) | |
| tree | 40874799472fa07416f17b50a398ac33b7771905 /src/server/api/endpoints/admin/relays | |
| parent | update deps (diff) | |
| download | sharkey-0e4a111f81cceed275d9bec2695f6e401fb654d8.tar.gz sharkey-0e4a111f81cceed275d9bec2695f6e401fb654d8.tar.bz2 sharkey-0e4a111f81cceed275d9bec2695f6e401fb654d8.zip | |
refactoring
Resolve #7779
Diffstat (limited to 'src/server/api/endpoints/admin/relays')
| -rw-r--r-- | src/server/api/endpoints/admin/relays/add.ts | 63 | ||||
| -rw-r--r-- | src/server/api/endpoints/admin/relays/list.ts | 47 | ||||
| -rw-r--r-- | src/server/api/endpoints/admin/relays/remove.ts | 20 |
3 files changed, 0 insertions, 130 deletions
diff --git a/src/server/api/endpoints/admin/relays/add.ts b/src/server/api/endpoints/admin/relays/add.ts deleted file mode 100644 index 567035fd3a..0000000000 --- a/src/server/api/endpoints/admin/relays/add.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { URL } from 'url'; -import $ from 'cafy'; -import define from '../../../define'; -import { addRelay } from '@/services/relay'; -import { ApiError } from '../../../error'; - -export const meta = { - tags: ['admin'], - - requireCredential: true as const, - requireModerator: true as const, - - params: { - inbox: { - validator: $.str - }, - }, - - errors: { - invalidUrl: { - message: 'Invalid URL', - code: 'INVALID_URL', - id: 'fb8c92d3-d4e5-44e7-b3d4-800d5cef8b2c' - }, - }, - - res: { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id' - }, - inbox: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'url' - }, - status: { - type: 'string' as const, - optional: false as const, nullable: false as const, - default: 'requesting', - enum: [ - 'requesting', - 'accepted', - 'rejected' - ] - } - } - } -}; - -export default define(meta, async (ps, user) => { - try { - if (new URL(ps.inbox).protocol !== 'https:') throw 'https only'; - } catch { - throw new ApiError(meta.errors.invalidUrl); - } - - return await addRelay(ps.inbox); -}); diff --git a/src/server/api/endpoints/admin/relays/list.ts b/src/server/api/endpoints/admin/relays/list.ts deleted file mode 100644 index 031ebe85d0..0000000000 --- a/src/server/api/endpoints/admin/relays/list.ts +++ /dev/null @@ -1,47 +0,0 @@ -import define from '../../../define'; -import { listRelay } from '@/services/relay'; - -export const meta = { - tags: ['admin'], - - requireCredential: true as const, - requireModerator: true as const, - - params: { - }, - - res: { - type: 'array' as const, - optional: false as const, nullable: false as const, - items: { - type: 'object' as const, - optional: false as const, nullable: false as const, - properties: { - id: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'id' - }, - inbox: { - type: 'string' as const, - optional: false as const, nullable: false as const, - format: 'url' - }, - status: { - type: 'string' as const, - optional: false as const, nullable: false as const, - default: 'requesting', - enum: [ - 'requesting', - 'accepted', - 'rejected' - ] - } - } - } - } -}; - -export default define(meta, async (ps, user) => { - return await listRelay(); -}); diff --git a/src/server/api/endpoints/admin/relays/remove.ts b/src/server/api/endpoints/admin/relays/remove.ts deleted file mode 100644 index c1c50f5dc0..0000000000 --- a/src/server/api/endpoints/admin/relays/remove.ts +++ /dev/null @@ -1,20 +0,0 @@ -import $ from 'cafy'; -import define from '../../../define'; -import { removeRelay } from '@/services/relay'; - -export const meta = { - tags: ['admin'], - - requireCredential: true as const, - requireModerator: true as const, - - params: { - inbox: { - validator: $.str - }, - }, -}; - -export default define(meta, async (ps, user) => { - return await removeRelay(ps.inbox); -}); |