diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-04-15 12:20:48 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-04-15 12:20:48 +0900 |
| commit | 772063aade67b43545098751b8dc0dbfb7af4ba0 (patch) | |
| tree | 55bfe2e2ae3208c1eee5c4cfe252d95131a02599 /src/server/api/kinds.ts | |
| parent | Merge branch 'develop' of https://github.com/syuilo/misskey into develop (diff) | |
| download | sharkey-772063aade67b43545098751b8dc0dbfb7af4ba0.tar.gz sharkey-772063aade67b43545098751b8dc0dbfb7af4ba0.tar.bz2 sharkey-772063aade67b43545098751b8dc0dbfb7af4ba0.zip | |
Refactor
Diffstat (limited to 'src/server/api/kinds.ts')
| -rw-r--r-- | src/server/api/kinds.ts | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/src/server/api/kinds.ts b/src/server/api/kinds.ts index d496fa6919..03ed3e7cd8 100644 --- a/src/server/api/kinds.ts +++ b/src/server/api/kinds.ts @@ -1,8 +1,4 @@ -import endpoints from './endpoints'; -import * as locale from '../../../locales/'; -import { fromEntries } from '../../prelude/array'; - -export const kindsList = [ +export const kinds = [ 'read:account', 'write:account', 'read:blocks', @@ -24,35 +20,3 @@ export const kindsList = [ 'write:reactions', 'write:votes' ]; - -export interface IKindInfo { - endpoints: string[]; - descs: { [x: string]: string; }; -} - -export function kinds() { - const kinds = fromEntries( - kindsList - .map(k => [k, { - endpoints: [], - descs: fromEntries( - Object.keys(locale) - .map(l => [l, locale[l].common.permissions[k] as string] as [string, string]) - ) as { [x: string]: string; } - }] as [ string, IKindInfo ]) - ) as { [x: string]: IKindInfo; }; - - const errors = [] as string[][]; - - for (const endpoint of endpoints.filter(ep => !ep.meta.secure)) { - if (endpoint.meta.kind) { - const kind = endpoint.meta.kind; - if (kind in kinds) kinds[kind].endpoints.push(endpoint.name); - else errors.push([kind, endpoint.name]); - } - } - - if (errors.length > 0) throw Error('\n ' + errors.map((e) => `Unknown kind (permission) "${e[0]}" found at ${e[1]}.`).join('\n ')); - - return kinds; -} |