Merge branch 'develop' into sonic
This commit is contained in:
commit
77cfb35496
351 changed files with 5370 additions and 7323 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -10,6 +10,18 @@
|
||||||
You should also include the user name that made the change.
|
You should also include the user name that made the change.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
## 12.x.x (unreleased)
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
- ノートの最大文字数を設定できる機能が廃止され、デフォルトで一律3000文字になりました
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
- プロフィールの追加情報を最大16まで保存できるように
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
- Client: リアクションピッカーの高さが低くなったまま戻らないことがあるのを修正 @syuilo
|
||||||
|
- Client: タッチ操作だとウィジェットの編集がしにくいのを修正 @xianonn
|
||||||
|
|
||||||
## 12.107.0 (2022/02/12)
|
## 12.107.0 (2022/02/12)
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|
|
@ -422,7 +422,6 @@ next: "次"
|
||||||
retype: "再入力"
|
retype: "再入力"
|
||||||
noteOf: "{user}のノート"
|
noteOf: "{user}のノート"
|
||||||
inviteToGroup: "グループに招待"
|
inviteToGroup: "グループに招待"
|
||||||
maxNoteTextLength: "ノートの文字数制限"
|
|
||||||
quoteAttached: "引用付き"
|
quoteAttached: "引用付き"
|
||||||
quoteQuestion: "引用として添付しますか?"
|
quoteQuestion: "引用として添付しますか?"
|
||||||
noMessagesYet: "まだチャットはありません"
|
noMessagesYet: "まだチャットはありません"
|
||||||
|
@ -1291,7 +1290,7 @@ _profile:
|
||||||
youCanIncludeHashtags: "ハッシュタグを含めることができます。"
|
youCanIncludeHashtags: "ハッシュタグを含めることができます。"
|
||||||
metadata: "追加情報"
|
metadata: "追加情報"
|
||||||
metadataEdit: "追加情報を編集"
|
metadataEdit: "追加情報を編集"
|
||||||
metadataDescription: "プロフィールに表として4つまでの追加情報を表示することができます。"
|
metadataDescription: "プロフィールに表として追加情報を表示することができます。"
|
||||||
metadataLabel: "ラベル"
|
metadataLabel: "ラベル"
|
||||||
metadataContent: "内容"
|
metadataContent: "内容"
|
||||||
changeAvatar: "アバター画像を変更"
|
changeAvatar: "アバター画像を変更"
|
||||||
|
|
|
@ -42,11 +42,9 @@
|
||||||
"js-yaml": "4.1.0"
|
"js-yaml": "4.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@redocly/openapi-core": "1.0.0-beta.79",
|
"@typescript-eslint/parser": "5.12.0",
|
||||||
"@types/fluent-ffmpeg": "2.1.20",
|
|
||||||
"@typescript-eslint/parser": "5.10.0",
|
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"cypress": "9.4.1",
|
"cypress": "9.5.0",
|
||||||
"start-server-and-test": "1.14.0",
|
"start-server-and-test": "1.14.0",
|
||||||
"typescript": "4.5.5"
|
"typescript": "4.5.5"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
const { MigrationInterface, QueryRunner } = require("typeorm");
|
||||||
|
|
||||||
|
module.exports = class removeMaxNoteTextLength1645340161439 {
|
||||||
|
name = 'removeMaxNoteTextLength1645340161439'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "maxNoteTextLength"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD "maxNoteTextLength" integer NOT NULL DEFAULT '500'`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,7 +22,7 @@
|
||||||
"@sinonjs/fake-timers": "9.1.0",
|
"@sinonjs/fake-timers": "9.1.0",
|
||||||
"@syuilo/aiscript": "0.11.1",
|
"@syuilo/aiscript": "0.11.1",
|
||||||
"@types/bcryptjs": "2.4.2",
|
"@types/bcryptjs": "2.4.2",
|
||||||
"@types/bull": "3.15.7",
|
"@types/bull": "3.15.8",
|
||||||
"@types/cbor": "6.0.0",
|
"@types/cbor": "6.0.0",
|
||||||
"@types/escape-regexp": "0.0.1",
|
"@types/escape-regexp": "0.0.1",
|
||||||
"@types/glob": "7.2.0",
|
"@types/glob": "7.2.0",
|
||||||
|
@ -41,8 +41,8 @@
|
||||||
"@types/koa__cors": "3.1.1",
|
"@types/koa__cors": "3.1.1",
|
||||||
"@types/koa__multer": "2.0.4",
|
"@types/koa__multer": "2.0.4",
|
||||||
"@types/koa__router": "8.0.11",
|
"@types/koa__router": "8.0.11",
|
||||||
"@types/mocha": "8.2.3",
|
"@types/mocha": "9.1.0",
|
||||||
"@types/node": "17.0.14",
|
"@types/node": "17.0.18",
|
||||||
"@types/node-fetch": "3.0.3",
|
"@types/node-fetch": "3.0.3",
|
||||||
"@types/nodemailer": "6.4.4",
|
"@types/nodemailer": "6.4.4",
|
||||||
"@types/oauth": "0.9.1",
|
"@types/oauth": "0.9.1",
|
||||||
|
@ -67,28 +67,28 @@
|
||||||
"@types/web-push": "3.3.2",
|
"@types/web-push": "3.3.2",
|
||||||
"@types/websocket": "1.0.5",
|
"@types/websocket": "1.0.5",
|
||||||
"@types/ws": "8.2.2",
|
"@types/ws": "8.2.2",
|
||||||
"@typescript-eslint/eslint-plugin": "5.10.2",
|
"@typescript-eslint/eslint-plugin": "5.12.0",
|
||||||
"@typescript-eslint/parser": "5.10.2",
|
"@typescript-eslint/parser": "5.12.0",
|
||||||
"abort-controller": "3.0.0",
|
"abort-controller": "3.0.0",
|
||||||
|
"ajv": "8.10.0",
|
||||||
"archiver": "5.3.0",
|
"archiver": "5.3.0",
|
||||||
"autobind-decorator": "2.4.0",
|
"autobind-decorator": "2.4.0",
|
||||||
"autwh": "0.1.0",
|
"autwh": "0.1.0",
|
||||||
"aws-sdk": "2.1067.0",
|
"aws-sdk": "2.1067.0",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"blurhash": "1.1.4",
|
"blurhash": "1.1.5",
|
||||||
"broadcast-channel": "4.9.0",
|
"broadcast-channel": "4.10.0",
|
||||||
"bull": "4.5.0",
|
"bull": "4.5.5",
|
||||||
"cacheable-lookup": "6.0.4",
|
"cacheable-lookup": "6.0.4",
|
||||||
"cafy": "15.2.1",
|
"cafy": "15.2.1",
|
||||||
"cbor": "8.1.0",
|
"cbor": "8.1.0",
|
||||||
"chalk": "4.1.2",
|
"chalk": "4.1.2",
|
||||||
"cli-highlight": "2.1.11",
|
"cli-highlight": "2.1.11",
|
||||||
"content-disposition": "0.5.4",
|
"content-disposition": "0.5.4",
|
||||||
"crc-32": "1.2.1",
|
|
||||||
"date-fns": "2.28.0",
|
"date-fns": "2.28.0",
|
||||||
"deep-email-validator": "0.1.21",
|
"deep-email-validator": "0.1.21",
|
||||||
"escape-regexp": "0.0.1",
|
"escape-regexp": "0.0.1",
|
||||||
"eslint": "8.8.0",
|
"eslint": "8.9.0",
|
||||||
"eslint-plugin-import": "2.25.4",
|
"eslint-plugin-import": "2.25.4",
|
||||||
"eventemitter3": "4.0.7",
|
"eventemitter3": "4.0.7",
|
||||||
"feed": "4.2.2",
|
"feed": "4.2.2",
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
"mfm-js": "0.21.0",
|
"mfm-js": "0.21.0",
|
||||||
"mime-types": "2.1.34",
|
"mime-types": "2.1.34",
|
||||||
"misskey-js": "0.0.14",
|
"misskey-js": "0.0.14",
|
||||||
"mocha": "8.4.0",
|
"mocha": "9.2.0",
|
||||||
"ms": "3.0.0-canary.1",
|
"ms": "3.0.0-canary.1",
|
||||||
"multer": "1.4.4",
|
"multer": "1.4.4",
|
||||||
"nested-property": "4.0.0",
|
"nested-property": "4.0.0",
|
||||||
|
@ -127,7 +127,7 @@
|
||||||
"nodemailer": "6.7.2",
|
"nodemailer": "6.7.2",
|
||||||
"os-utils": "0.0.14",
|
"os-utils": "0.0.14",
|
||||||
"parse5": "6.0.1",
|
"parse5": "6.0.1",
|
||||||
"pg": "8.7.1",
|
"pg": "8.7.3",
|
||||||
"portscanner": "2.2.0",
|
"portscanner": "2.2.0",
|
||||||
"private-ip": "2.3.3",
|
"private-ip": "2.3.3",
|
||||||
"probe-image-size": "7.2.3",
|
"probe-image-size": "7.2.3",
|
||||||
|
@ -146,39 +146,40 @@
|
||||||
"require-all": "3.0.0",
|
"require-all": "3.0.0",
|
||||||
"rndstr": "1.0.0",
|
"rndstr": "1.0.0",
|
||||||
"s-age": "1.1.2",
|
"s-age": "1.1.2",
|
||||||
"sanitize-html": "2.6.1",
|
"sanitize-html": "2.7.0",
|
||||||
"seedrandom": "3.0.5",
|
"seedrandom": "3.0.5",
|
||||||
"sharp": "0.30.0",
|
"sharp": "0.30.0",
|
||||||
"sonic-channel": "1.2.6",
|
"sonic-channel": "1.2.6",
|
||||||
|
"sharp": "0.30.1",
|
||||||
"speakeasy": "2.0.0",
|
"speakeasy": "2.0.0",
|
||||||
"strict-event-emitter-types": "2.0.0",
|
"strict-event-emitter-types": "2.0.0",
|
||||||
"stringz": "2.1.0",
|
"stringz": "2.1.0",
|
||||||
"style-loader": "3.3.1",
|
"style-loader": "3.3.1",
|
||||||
"summaly": "2.5.0",
|
"summaly": "2.5.0",
|
||||||
"syslog-pro": "1.0.0",
|
"syslog-pro": "1.0.0",
|
||||||
"systeminformation": "5.11.0",
|
"systeminformation": "5.11.3",
|
||||||
"throttle-debounce": "3.0.1",
|
"throttle-debounce": "3.0.1",
|
||||||
"tinycolor2": "1.4.2",
|
"tinycolor2": "1.4.2",
|
||||||
"tmp": "0.2.1",
|
"tmp": "0.2.1",
|
||||||
"ts-loader": "9.2.6",
|
"ts-loader": "9.2.6",
|
||||||
"ts-node": "10.4.0",
|
"ts-node": "10.5.0",
|
||||||
"tsc-alias": "1.4.1",
|
"tsc-alias": "1.4.1",
|
||||||
"tsconfig-paths": "3.12.0",
|
"tsconfig-paths": "3.12.0",
|
||||||
"twemoji-parser": "13.1.0",
|
"twemoji-parser": "13.1.0",
|
||||||
"typeorm": "0.2.41",
|
"typeorm": "0.2.43",
|
||||||
"typescript": "4.5.5",
|
"typescript": "4.5.5",
|
||||||
"ulid": "2.3.0",
|
"ulid": "2.3.0",
|
||||||
"unzipper": "0.10.11",
|
"unzipper": "0.10.11",
|
||||||
"uuid": "8.3.2",
|
"uuid": "8.3.2",
|
||||||
"web-push": "3.4.5",
|
"web-push": "3.4.5",
|
||||||
"websocket": "1.0.34",
|
"websocket": "1.0.34",
|
||||||
"ws": "8.4.2",
|
"ws": "8.5.0",
|
||||||
"xev": "2.0.1"
|
"xev": "2.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@redocly/openapi-core": "1.0.0-beta.79",
|
"@redocly/openapi-core": "1.0.0-beta.82",
|
||||||
"@types/fluent-ffmpeg": "2.1.20",
|
"@types/fluent-ffmpeg": "2.1.20",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"execa": "6.0.0"
|
"execa": "6.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
export const MAX_NOTE_TEXT_LENGTH = 3000;
|
||||||
|
|
||||||
export const USER_ONLINE_THRESHOLD = 1000 * 60 * 10; // 10min
|
export const USER_ONLINE_THRESHOLD = 1000 * 60 * 10; // 10min
|
||||||
export const USER_ACTIVE_THRESHOLD = 1000 * 60 * 60 * 24 * 3; // 3days
|
export const USER_ACTIVE_THRESHOLD = 1000 * 60 * 60 * 24 * 3; // 3days
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ export default function() {
|
||||||
tx: round(Math.max(0, netStats.tx_sec)),
|
tx: round(Math.max(0, netStats.tx_sec)),
|
||||||
},
|
},
|
||||||
fs: {
|
fs: {
|
||||||
r: round(Math.max(0, fsStats.rIO_sec)),
|
r: round(Math.max(0, fsStats.rIO_sec ?? 0)),
|
||||||
w: round(Math.max(0, fsStats.wIO_sec)),
|
w: round(Math.max(0, fsStats.wIO_sec ?? 0)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
ev.emit('serverStats', stats);
|
ev.emit('serverStats', stats);
|
||||||
|
@ -51,9 +51,9 @@ export default function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPU STAT
|
// CPU STAT
|
||||||
function cpuUsage() {
|
function cpuUsage(): Promise<number> {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
osUtils.cpuUsage((cpuUsage: number) => {
|
osUtils.cpuUsage((cpuUsage) => {
|
||||||
res(cpuUsage);
|
res(cpuUsage);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -63,18 +63,13 @@ export const refs = {
|
||||||
Emoji: packedEmojiSchema,
|
Emoji: packedEmojiSchema,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Packed = SchemaTypeDef<typeof refs[x]>; とすると展開されてマウスホバー時に型表示が使い物にならなくなる
|
export type Packed<x extends keyof typeof refs> = SchemaType<typeof refs[x]>;
|
||||||
// ObjType<r['properties']>を指定すると(なぜか)展開されずにPacked<'Hoge'>と表示される
|
|
||||||
type PackedDef<r extends { properties?: Obj; oneOf?: ReadonlyArray<MinimumSchema>; allOf?: ReadonlyArray<MinimumSchema> }> =
|
|
||||||
r['allOf'] extends ReadonlyArray<MinimumSchema> ? UnionToIntersection<UnionSchemaType<r['allOf']>> :
|
|
||||||
r['oneOf'] extends ReadonlyArray<MinimumSchema> ? UnionSchemaType<r['oneOf']> :
|
|
||||||
r['properties'] extends Obj ? ObjType<r['properties']> :
|
|
||||||
never;
|
|
||||||
export type Packed<x extends keyof typeof refs> = PackedDef<typeof refs[x]>;
|
|
||||||
|
|
||||||
type TypeStringef = 'boolean' | 'number' | 'string' | 'array' | 'object' | 'any';
|
type TypeStringef = 'null' | 'boolean' | 'integer' | 'number' | 'string' | 'array' | 'object' | 'any';
|
||||||
type StringDefToType<T extends TypeStringef> =
|
type StringDefToType<T extends TypeStringef> =
|
||||||
|
T extends 'null' ? null :
|
||||||
T extends 'boolean' ? boolean :
|
T extends 'boolean' ? boolean :
|
||||||
|
T extends 'integer' ? number :
|
||||||
T extends 'number' ? number :
|
T extends 'number' ? number :
|
||||||
T extends 'string' ? string | Date :
|
T extends 'string' ? string | Date :
|
||||||
T extends 'array' ? ReadonlyArray<any> :
|
T extends 'array' ? ReadonlyArray<any> :
|
||||||
|
@ -83,17 +78,18 @@ type StringDefToType<T extends TypeStringef> =
|
||||||
|
|
||||||
// https://swagger.io/specification/?sbsearch=optional#schema-object
|
// https://swagger.io/specification/?sbsearch=optional#schema-object
|
||||||
type OfSchema = {
|
type OfSchema = {
|
||||||
readonly anyOf?: ReadonlyArray<MinimumSchema>;
|
readonly anyOf?: ReadonlyArray<Schema>;
|
||||||
readonly oneOf?: ReadonlyArray<MinimumSchema>;
|
readonly oneOf?: ReadonlyArray<Schema>;
|
||||||
readonly allOf?: ReadonlyArray<MinimumSchema>;
|
readonly allOf?: ReadonlyArray<Schema>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MinimumSchema extends OfSchema {
|
export interface Schema extends OfSchema {
|
||||||
readonly type?: TypeStringef;
|
readonly type?: TypeStringef;
|
||||||
readonly nullable?: boolean;
|
readonly nullable?: boolean;
|
||||||
readonly optional?: boolean;
|
readonly optional?: boolean;
|
||||||
readonly items?: MinimumSchema;
|
readonly items?: Schema;
|
||||||
readonly properties?: Obj;
|
readonly properties?: Obj;
|
||||||
|
readonly required?: ReadonlyArray<keyof NonNullable<this['properties']>>;
|
||||||
readonly description?: string;
|
readonly description?: string;
|
||||||
readonly example?: any;
|
readonly example?: any;
|
||||||
readonly format?: string;
|
readonly format?: string;
|
||||||
|
@ -104,26 +100,22 @@ export interface MinimumSchema extends OfSchema {
|
||||||
readonly minLength?: number;
|
readonly minLength?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Schema extends MinimumSchema {
|
type RequiredPropertyNames<s extends Obj> = {
|
||||||
readonly nullable: boolean;
|
[K in keyof s]:
|
||||||
readonly optional: boolean;
|
// K is not optional
|
||||||
}
|
s[K]['optional'] extends false ? K :
|
||||||
|
// K has default value
|
||||||
type NonUndefinedPropertyNames<T extends Obj> = {
|
s[K]['default'] extends null | string | number | boolean | Record<string, unknown> ? K : never
|
||||||
[K in keyof T]: T[K]['optional'] extends true ? never : K
|
}[keyof s];
|
||||||
}[keyof T];
|
|
||||||
|
|
||||||
type UndefinedPropertyNames<T extends Obj> = {
|
|
||||||
[K in keyof T]: T[K]['optional'] extends true ? K : never
|
|
||||||
}[keyof T];
|
|
||||||
|
|
||||||
export interface Obj { [key: string]: Schema; }
|
export interface Obj { [key: string]: Schema; }
|
||||||
|
|
||||||
export type ObjType<s extends Obj> =
|
export type ObjType<s extends Obj, RequiredProps extends keyof s> =
|
||||||
{ -readonly [P in UndefinedPropertyNames<s>]?: SchemaType<s[P]> } &
|
{ -readonly [P in keyof s]?: SchemaType<s[P]> } &
|
||||||
{ -readonly [P in NonUndefinedPropertyNames<s>]: SchemaType<s[P]> };
|
{ -readonly [P in RequiredProps]: SchemaType<s[P]> } &
|
||||||
|
{ -readonly [P in RequiredPropertyNames<s>]: SchemaType<s[P]> };
|
||||||
|
|
||||||
type NullOrUndefined<p extends MinimumSchema, T> =
|
type NullOrUndefined<p extends Schema, T> =
|
||||||
p['nullable'] extends true
|
p['nullable'] extends true
|
||||||
? p['optional'] extends true
|
? p['optional'] extends true
|
||||||
? (T | null | undefined)
|
? (T | null | undefined)
|
||||||
|
@ -132,15 +124,18 @@ type NullOrUndefined<p extends MinimumSchema, T> =
|
||||||
? (T | undefined)
|
? (T | undefined)
|
||||||
: T;
|
: T;
|
||||||
|
|
||||||
// 共用体型を交差型にする型 https://stackoverflow.com/questions/54938141/typescript-convert-union-to-intersection
|
// https://stackoverflow.com/questions/54938141/typescript-convert-union-to-intersection
|
||||||
|
// Get intersection from union
|
||||||
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
||||||
|
|
||||||
// https://github.com/misskey-dev/misskey/pull/8144#discussion_r785287552
|
// https://github.com/misskey-dev/misskey/pull/8144#discussion_r785287552
|
||||||
// 単純にSchemaTypeDef<X>で判定するだけではダメ
|
// To get union, we use `Foo extends any ? Hoge<Foo> : never`
|
||||||
type UnionSchemaType<a extends readonly any[], X extends MinimumSchema = a[number]> = X extends any ? SchemaType<X> : never;
|
type UnionSchemaType<a extends readonly any[], X extends Schema = a[number]> = X extends any ? SchemaType<X> : never;
|
||||||
type ArrayUnion<T> = T extends any ? Array<T> : never;
|
type ArrayUnion<T> = T extends any ? Array<T> : never;
|
||||||
|
|
||||||
export type SchemaTypeDef<p extends MinimumSchema> =
|
export type SchemaTypeDef<p extends Schema> =
|
||||||
|
p['type'] extends 'null' ? null :
|
||||||
|
p['type'] extends 'integer' ? number :
|
||||||
p['type'] extends 'number' ? number :
|
p['type'] extends 'number' ? number :
|
||||||
p['type'] extends 'string' ? (
|
p['type'] extends 'string' ? (
|
||||||
p['enum'] extends readonly string[] ?
|
p['enum'] extends readonly string[] ?
|
||||||
|
@ -151,22 +146,22 @@ export type SchemaTypeDef<p extends MinimumSchema> =
|
||||||
p['type'] extends 'boolean' ? boolean :
|
p['type'] extends 'boolean' ? boolean :
|
||||||
p['type'] extends 'object' ? (
|
p['type'] extends 'object' ? (
|
||||||
p['ref'] extends keyof typeof refs ? Packed<p['ref']> :
|
p['ref'] extends keyof typeof refs ? Packed<p['ref']> :
|
||||||
p['properties'] extends NonNullable<Obj> ? ObjType<p['properties']> :
|
p['properties'] extends NonNullable<Obj> ? ObjType<p['properties'], NonNullable<p['required']>[number]> :
|
||||||
p['anyOf'] extends ReadonlyArray<MinimumSchema> ? UnionSchemaType<p['anyOf']> & Partial<UnionToIntersection<UnionSchemaType<p['anyOf']>>> :
|
p['anyOf'] extends ReadonlyArray<Schema> ? UnionSchemaType<p['anyOf']> & Partial<UnionToIntersection<UnionSchemaType<p['anyOf']>>> :
|
||||||
p['allOf'] extends ReadonlyArray<MinimumSchema> ? UnionToIntersection<UnionSchemaType<p['allOf']>> :
|
p['allOf'] extends ReadonlyArray<Schema> ? UnionToIntersection<UnionSchemaType<p['allOf']>> :
|
||||||
any
|
any
|
||||||
) :
|
) :
|
||||||
p['type'] extends 'array' ? (
|
p['type'] extends 'array' ? (
|
||||||
p['items'] extends OfSchema ? (
|
p['items'] extends OfSchema ? (
|
||||||
p['items']['anyOf'] extends ReadonlyArray<MinimumSchema> ? UnionSchemaType<NonNullable<p['items']['anyOf']>>[] :
|
p['items']['anyOf'] extends ReadonlyArray<Schema> ? UnionSchemaType<NonNullable<p['items']['anyOf']>>[] :
|
||||||
p['items']['oneOf'] extends ReadonlyArray<MinimumSchema> ? ArrayUnion<UnionSchemaType<NonNullable<p['items']['oneOf']>>> :
|
p['items']['oneOf'] extends ReadonlyArray<Schema> ? ArrayUnion<UnionSchemaType<NonNullable<p['items']['oneOf']>>> :
|
||||||
p['items']['allOf'] extends ReadonlyArray<MinimumSchema> ? UnionToIntersection<UnionSchemaType<NonNullable<p['items']['allOf']>>>[] :
|
p['items']['allOf'] extends ReadonlyArray<Schema> ? UnionToIntersection<UnionSchemaType<NonNullable<p['items']['allOf']>>>[] :
|
||||||
never
|
never
|
||||||
) :
|
) :
|
||||||
p['items'] extends NonNullable<MinimumSchema> ? SchemaTypeDef<p['items']>[] :
|
p['items'] extends NonNullable<Schema> ? SchemaTypeDef<p['items']>[] :
|
||||||
any[]
|
any[]
|
||||||
) :
|
) :
|
||||||
p['oneOf'] extends ReadonlyArray<MinimumSchema> ? UnionSchemaType<p['oneOf']> :
|
p['oneOf'] extends ReadonlyArray<Schema> ? UnionSchemaType<p['oneOf']> :
|
||||||
any;
|
any;
|
||||||
|
|
||||||
export type SchemaType<p extends MinimumSchema> = NullOrUndefined<p, SchemaTypeDef<p>>;
|
export type SchemaType<p extends Schema> = NullOrUndefined<p, SchemaTypeDef<p>>;
|
||||||
|
|
|
@ -205,12 +205,6 @@ export class Meta {
|
||||||
})
|
})
|
||||||
public remoteDriveCapacityMb: number;
|
public remoteDriveCapacityMb: number;
|
||||||
|
|
||||||
@Column('integer', {
|
|
||||||
default: 500,
|
|
||||||
comment: 'Max allowed note text length in characters',
|
|
||||||
})
|
|
||||||
public maxNoteTextLength: number;
|
|
||||||
|
|
||||||
@Column('varchar', {
|
@Column('varchar', {
|
||||||
length: 128,
|
length: 128,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
|
@ -61,6 +61,7 @@ import { RegistryItem } from './entities/registry-item';
|
||||||
import { Ad } from './entities/ad';
|
import { Ad } from './entities/ad';
|
||||||
import { PasswordResetRequest } from './entities/password-reset-request';
|
import { PasswordResetRequest } from './entities/password-reset-request';
|
||||||
import { UserPending } from './entities/user-pending';
|
import { UserPending } from './entities/user-pending';
|
||||||
|
import { InstanceRepository } from './repositories/instance';
|
||||||
|
|
||||||
export const Announcements = getRepository(Announcement);
|
export const Announcements = getRepository(Announcement);
|
||||||
export const AnnouncementReads = getRepository(AnnouncementRead);
|
export const AnnouncementReads = getRepository(AnnouncementRead);
|
||||||
|
@ -89,7 +90,7 @@ export const UserNotePinings = getRepository(UserNotePining);
|
||||||
export const UsedUsernames = getRepository(UsedUsername);
|
export const UsedUsernames = getRepository(UsedUsername);
|
||||||
export const Followings = getCustomRepository(FollowingRepository);
|
export const Followings = getCustomRepository(FollowingRepository);
|
||||||
export const FollowRequests = getCustomRepository(FollowRequestRepository);
|
export const FollowRequests = getCustomRepository(FollowRequestRepository);
|
||||||
export const Instances = getRepository(Instance);
|
export const Instances = getCustomRepository(InstanceRepository);
|
||||||
export const Emojis = getCustomRepository(EmojiRepository);
|
export const Emojis = getCustomRepository(EmojiRepository);
|
||||||
export const DriveFiles = getCustomRepository(DriveFileRepository);
|
export const DriveFiles = getCustomRepository(DriveFileRepository);
|
||||||
export const DriveFolders = getCustomRepository(DriveFolderRepository);
|
export const DriveFolders = getCustomRepository(DriveFolderRepository);
|
||||||
|
|
|
@ -32,7 +32,7 @@ export class AppRepository extends Repository<App> {
|
||||||
...(me ? {
|
...(me ? {
|
||||||
isAuthorized: await AccessTokens.count({
|
isAuthorized: await AccessTokens.count({
|
||||||
appId: app.id,
|
appId: app.id,
|
||||||
userId: me,
|
userId: me.id,
|
||||||
}).then(count => count > 0),
|
}).then(count => count > 0),
|
||||||
} : {}),
|
} : {}),
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,13 +6,6 @@ import { Packed } from '@/misc/schema';
|
||||||
|
|
||||||
@EntityRepository(DriveFolder)
|
@EntityRepository(DriveFolder)
|
||||||
export class DriveFolderRepository extends Repository<DriveFolder> {
|
export class DriveFolderRepository extends Repository<DriveFolder> {
|
||||||
public validateFolderName(name: string): boolean {
|
|
||||||
return (
|
|
||||||
(name.trim().length > 0) &&
|
|
||||||
(name.length <= 200)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async pack(
|
public async pack(
|
||||||
src: DriveFolder['id'] | DriveFolder,
|
src: DriveFolder['id'] | DriveFolder,
|
||||||
options?: {
|
options?: {
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
import config from '@/config/index';
|
|
||||||
|
|
39
packages/backend/src/models/repositories/instance.ts
Normal file
39
packages/backend/src/models/repositories/instance.ts
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
import { EntityRepository, Repository } from 'typeorm';
|
||||||
|
import { Instance } from '@/models/entities/instance';
|
||||||
|
import { Packed } from '@/misc/schema';
|
||||||
|
|
||||||
|
@EntityRepository(Instance)
|
||||||
|
export class InstanceRepository extends Repository<Instance> {
|
||||||
|
public async pack(
|
||||||
|
instance: Instance,
|
||||||
|
): Promise<Packed<'FederationInstance'>> {
|
||||||
|
return {
|
||||||
|
id: instance.id,
|
||||||
|
caughtAt: instance.caughtAt.toISOString(),
|
||||||
|
host: instance.host,
|
||||||
|
usersCount: instance.usersCount,
|
||||||
|
notesCount: instance.notesCount,
|
||||||
|
followingCount: instance.followingCount,
|
||||||
|
followersCount: instance.followersCount,
|
||||||
|
latestRequestSentAt: instance.latestRequestSentAt ? instance.latestRequestSentAt.toISOString() : null,
|
||||||
|
lastCommunicatedAt: instance.lastCommunicatedAt.toISOString(),
|
||||||
|
isNotResponding: instance.isNotResponding,
|
||||||
|
isSuspended: instance.isSuspended,
|
||||||
|
softwareName: instance.softwareName,
|
||||||
|
softwareVersion: instance.softwareVersion,
|
||||||
|
openRegistrations: instance.openRegistrations,
|
||||||
|
name: instance.name,
|
||||||
|
description: instance.description,
|
||||||
|
maintainerName: instance.maintainerName,
|
||||||
|
maintainerEmail: instance.maintainerEmail,
|
||||||
|
iconUrl: instance.iconUrl,
|
||||||
|
infoUpdatedAt: instance.infoUpdatedAt ? instance.infoUpdatedAt.toISOString() : null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public packMany(
|
||||||
|
instances: Instance[],
|
||||||
|
) {
|
||||||
|
return Promise.all(instances.map(x => this.pack(x)));
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,10 +6,6 @@ import { User } from '@/models/entities/user';
|
||||||
|
|
||||||
@EntityRepository(MessagingMessage)
|
@EntityRepository(MessagingMessage)
|
||||||
export class MessagingMessageRepository extends Repository<MessagingMessage> {
|
export class MessagingMessageRepository extends Repository<MessagingMessage> {
|
||||||
public validateText(text: string): boolean {
|
|
||||||
return text.trim().length <= 1000 && text.trim() != '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public async pack(
|
public async pack(
|
||||||
src: MessagingMessage['id'] | MessagingMessage,
|
src: MessagingMessage['id'] | MessagingMessage,
|
||||||
me?: { id: User['id'] } | null | undefined,
|
me?: { id: User['id'] } | null | undefined,
|
||||||
|
|
|
@ -12,10 +12,6 @@ import { aggregateNoteEmojis, populateEmojis, prefetchEmojis } from '@/misc/popu
|
||||||
|
|
||||||
@EntityRepository(Note)
|
@EntityRepository(Note)
|
||||||
export class NoteRepository extends Repository<Note> {
|
export class NoteRepository extends Repository<Note> {
|
||||||
public validateCw(x: string) {
|
|
||||||
return x.trim().length <= 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async isVisibleForMe(note: Note, meId: User['id'] | null): Promise<boolean> {
|
public async isVisibleForMe(note: Note, meId: User['id'] | null): Promise<boolean> {
|
||||||
// visibility が specified かつ自分が指定されていなかったら非表示
|
// visibility が specified かつ自分が指定されていなかったら非表示
|
||||||
if (note.visibility === 'specified') {
|
if (note.visibility === 'specified') {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { EntityRepository, Repository, In, Not } from 'typeorm';
|
import { EntityRepository, Repository, In, Not } from 'typeorm';
|
||||||
|
import * as Ajv from 'ajv';
|
||||||
import { User, ILocalUser, IRemoteUser } from '@/models/entities/user';
|
import { User, ILocalUser, IRemoteUser } from '@/models/entities/user';
|
||||||
import { Notes, NoteUnreads, FollowRequests, Notifications, MessagingMessages, UserNotePinings, Followings, Blockings, Mutings, UserProfiles, UserSecurityKeys, UserGroupJoinings, Pages, Announcements, AnnouncementReads, Antennas, AntennaNotes, ChannelFollowings, Instances } from '../index';
|
import { Notes, NoteUnreads, FollowRequests, Notifications, MessagingMessages, UserNotePinings, Followings, Blockings, Mutings, UserProfiles, UserSecurityKeys, UserGroupJoinings, Pages, Announcements, AnnouncementReads, Antennas, AntennaNotes, ChannelFollowings, Instances } from '../index';
|
||||||
import config from '@/config/index';
|
import config from '@/config/index';
|
||||||
|
@ -17,8 +17,26 @@ type IsMeAndIsUserDetailed<ExpectsMe extends boolean | null, Detailed extends bo
|
||||||
Packed<'UserDetailed'> :
|
Packed<'UserDetailed'> :
|
||||||
Packed<'UserLite'>;
|
Packed<'UserLite'>;
|
||||||
|
|
||||||
|
const ajv = new Ajv();
|
||||||
|
|
||||||
@EntityRepository(User)
|
@EntityRepository(User)
|
||||||
export class UserRepository extends Repository<User> {
|
export class UserRepository extends Repository<User> {
|
||||||
|
public localUsernameSchema = { type: 'string', pattern: /^\w{1,20}$/.toString().slice(1, -1) } as const;
|
||||||
|
public passwordSchema = { type: 'string', minLength: 1 } as const;
|
||||||
|
public nameSchema = { type: 'string', minLength: 1, maxLength: 50 } as const;
|
||||||
|
public descriptionSchema = { type: 'string', minLength: 1, maxLength: 500 } as const;
|
||||||
|
public locationSchema = { type: 'string', minLength: 1, maxLength: 50 } as const;
|
||||||
|
public birthdaySchema = { type: 'string', pattern: /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/.toString().slice(1, -1) } as const;
|
||||||
|
|
||||||
|
//#region Validators
|
||||||
|
public validateLocalUsername = ajv.compile(this.localUsernameSchema);
|
||||||
|
public validatePassword = ajv.compile(this.passwordSchema);
|
||||||
|
public validateName = ajv.compile(this.nameSchema);
|
||||||
|
public validateDescription = ajv.compile(this.descriptionSchema);
|
||||||
|
public validateLocation = ajv.compile(this.locationSchema);
|
||||||
|
public validateBirthday = ajv.compile(this.birthdaySchema);
|
||||||
|
//#endregion
|
||||||
|
|
||||||
public async getRelation(me: User['id'], target: User['id']) {
|
public async getRelation(me: User['id'], target: User['id']) {
|
||||||
const [following1, following2, followReq1, followReq2, toBlocking, fromBlocked, mute] = await Promise.all([
|
const [following1, following2, followReq1, followReq2, toBlocking, fromBlocked, mute] = await Promise.all([
|
||||||
Followings.findOne({
|
Followings.findOne({
|
||||||
|
@ -351,13 +369,4 @@ export class UserRepository extends Repository<User> {
|
||||||
public isRemoteUser(user: User | { host: User['host'] }): boolean {
|
public isRemoteUser(user: User | { host: User['host'] }): boolean {
|
||||||
return !this.isLocalUser(user);
|
return !this.isLocalUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
//#region Validators
|
|
||||||
public validateLocalUsername = $.str.match(/^\w{1,20}$/);
|
|
||||||
public validatePassword = $.str.min(1);
|
|
||||||
public validateName = $.str.min(1).max(50);
|
|
||||||
public validateDescription = $.str.min(1).max(500);
|
|
||||||
public validateLocation = $.str.min(1).max(50);
|
|
||||||
public validateBirthday = $.str.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/);
|
|
||||||
//#endregion
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,6 @@ export const packedFederationInstanceSchema = {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
},
|
},
|
||||||
driveUsage: {
|
|
||||||
type: 'number',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
driveFiles: {
|
|
||||||
type: 'number',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
latestRequestSentAt: {
|
latestRequestSentAt: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: true,
|
optional: false, nullable: true,
|
||||||
|
|
|
@ -31,7 +31,7 @@ export async function deleteAccount(job: Bull.Job<DbUserDeleteJobData>): Promise
|
||||||
order: {
|
order: {
|
||||||
id: 1,
|
id: 1,
|
||||||
},
|
},
|
||||||
});
|
}) as Note[];
|
||||||
|
|
||||||
if (notes.length === 0) {
|
if (notes.length === 0) {
|
||||||
break;
|
break;
|
||||||
|
@ -58,7 +58,7 @@ export async function deleteAccount(job: Bull.Job<DbUserDeleteJobData>): Promise
|
||||||
order: {
|
order: {
|
||||||
id: 1,
|
id: 1,
|
||||||
},
|
},
|
||||||
});
|
}) as DriveFile[];
|
||||||
|
|
||||||
if (files.length === 0) {
|
if (files.length === 0) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -75,7 +75,7 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi
|
||||||
await downloadUrl(emoji.originalUrl, emojiPath);
|
await downloadUrl(emoji.originalUrl, emojiPath);
|
||||||
downloaded = true;
|
downloaded = true;
|
||||||
} catch (e) { // TODO: 何度か再試行
|
} catch (e) { // TODO: 何度か再試行
|
||||||
logger.error(e);
|
logger.error(e instanceof Error ? e : new Error(e as string));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!downloaded) {
|
if (!downloaded) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ export async function exportFollowing(job: Bull.Job<DbUserJobData>, done: () =>
|
||||||
order: {
|
order: {
|
||||||
id: 1,
|
id: 1,
|
||||||
},
|
},
|
||||||
});
|
}) as Following[];
|
||||||
|
|
||||||
if (followings.length === 0) {
|
if (followings.length === 0) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -62,7 +62,7 @@ export async function exportNotes(job: Bull.Job<DbUserJobData>, done: any): Prom
|
||||||
order: {
|
order: {
|
||||||
id: 1,
|
id: 1,
|
||||||
},
|
},
|
||||||
});
|
}) as Note[];
|
||||||
|
|
||||||
if (notes.length === 0) {
|
if (notes.length === 0) {
|
||||||
job.progress(100);
|
job.progress(100);
|
||||||
|
|
|
@ -199,7 +199,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us
|
||||||
throw new Error('already registered');
|
throw new Error('already registered');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.error(e);
|
logger.error(e instanceof Error ? e : new Error(e as string));
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import authenticate, { AuthenticationError } from './authenticate';
|
||||||
import call from './call';
|
import call from './call';
|
||||||
import { ApiError } from './error';
|
import { ApiError } from './error';
|
||||||
|
|
||||||
export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise((res) => {
|
export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise<void>((res) => {
|
||||||
const body = ctx.request.body;
|
const body = ctx.request.body;
|
||||||
|
|
||||||
const reply = (x?: any, y?: ApiError) => {
|
const reply = (x?: any, y?: ApiError) => {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as Koa from 'koa';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { limiter } from './limiter';
|
import { limiter } from './limiter';
|
||||||
import { User } from '@/models/entities/user';
|
import { User } from '@/models/entities/user';
|
||||||
import endpoints from './endpoints';
|
import endpoints, { IEndpoint } from './endpoints';
|
||||||
import { ApiError } from './error';
|
import { ApiError } from './error';
|
||||||
import { apiLogger } from './logger';
|
import { apiLogger } from './logger';
|
||||||
import { AccessToken } from '@/models/entities/access-token';
|
import { AccessToken } from '@/models/entities/access-token';
|
||||||
|
@ -67,7 +67,7 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
|
||||||
|
|
||||||
if (ep.meta.requireCredential && ep.meta.limit && !user!.isAdmin && !user!.isModerator) {
|
if (ep.meta.requireCredential && ep.meta.limit && !user!.isAdmin && !user!.isModerator) {
|
||||||
// Rate limit
|
// Rate limit
|
||||||
await limiter(ep, user!).catch(e => {
|
await limiter(ep as IEndpoint & { meta: { limit: NonNullable<IEndpoint['meta']['limit']> } }, user!).catch(e => {
|
||||||
throw new ApiError({
|
throw new ApiError({
|
||||||
message: 'Rate limit exceeded. Please try again later.',
|
message: 'Rate limit exceeded. Please try again later.',
|
||||||
code: 'RATE_LIMIT_EXCEEDED',
|
code: 'RATE_LIMIT_EXCEEDED',
|
||||||
|
@ -78,10 +78,10 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cast non JSON input
|
// Cast non JSON input
|
||||||
if (ep.meta.requireFile && ep.meta.params) {
|
if (ep.meta.requireFile && ep.params.properties) {
|
||||||
for (const k of Object.keys(ep.meta.params)) {
|
for (const k of Object.keys(ep.params.properties)) {
|
||||||
const param = ep.meta.params[k];
|
const param = ep.params.properties![k];
|
||||||
if (['Boolean', 'Number'].includes(param.validator.name) && typeof data[k] === 'string') {
|
if (['boolean', 'number', 'integer'].includes(param.type ?? '') && typeof data[k] === 'string') {
|
||||||
try {
|
try {
|
||||||
data[k] = JSON.parse(data[k]);
|
data[k] = JSON.parse(data[k]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -91,8 +91,8 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
|
||||||
id: '0b5f1631-7c1a-41a6-b399-cce335f34d85',
|
id: '0b5f1631-7c1a-41a6-b399-cce335f34d85',
|
||||||
}, {
|
}, {
|
||||||
param: k,
|
param: k,
|
||||||
reason: `cannot cast to ${param.validator.name}`,
|
reason: `cannot cast to ${param.type}`,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ export function generateRepliesQuery(q: SelectQueryBuilder<any>, me?: Pick<User,
|
||||||
.andWhere('note.replyUserId = note.userId');
|
.andWhere('note.replyUserId = note.userId');
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
} else if(!me.showTimelineReplies) {
|
} else if (!me.showTimelineReplies) {
|
||||||
q.andWhere(new Brackets(qb => { qb
|
q.andWhere(new Brackets(qb => { qb
|
||||||
.where(`note.replyId IS NULL`) // 返信ではない
|
.where(`note.replyId IS NULL`) // 返信ではない
|
||||||
.orWhere('note.replyUserId = :meId', { meId: me.id }) // 返信だけど自分のノートへの返信
|
.orWhere('note.replyUserId = :meId', { meId: me.id }) // 返信だけど自分のノートへの返信
|
||||||
|
|
|
@ -21,13 +21,13 @@ export async function signup(opts: {
|
||||||
let hash = passwordHash;
|
let hash = passwordHash;
|
||||||
|
|
||||||
// Validate username
|
// Validate username
|
||||||
if (!Users.validateLocalUsername.ok(username)) {
|
if (!Users.validateLocalUsername(username)) {
|
||||||
throw new Error('INVALID_USERNAME');
|
throw new Error('INVALID_USERNAME');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (password != null && passwordHash == null) {
|
if (password != null && passwordHash == null) {
|
||||||
// Validate password
|
// Validate password
|
||||||
if (!Users.validatePassword.ok(password)) {
|
if (!Users.validatePassword(password)) {
|
||||||
throw new Error('INVALID_PASSWORD');
|
throw new Error('INVALID_PASSWORD');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import Ajv from 'ajv';
|
||||||
import { ILocalUser } from '@/models/entities/user';
|
import { ILocalUser } from '@/models/entities/user';
|
||||||
import { IEndpointMeta } from './endpoints';
|
import { IEndpointMeta } from './endpoints';
|
||||||
import { ApiError } from './error';
|
import { ApiError } from './error';
|
||||||
import { SchemaType } from '@/misc/schema';
|
import { Schema, SchemaType } from '@/misc/schema';
|
||||||
import { AccessToken } from '@/models/entities/access-token';
|
import { AccessToken } from '@/models/entities/access-token';
|
||||||
|
|
||||||
type NonOptional<T> = T extends undefined ? never : T;
|
|
||||||
|
|
||||||
type SimpleUserInfo = {
|
type SimpleUserInfo = {
|
||||||
id: ILocalUser['id'];
|
id: ILocalUser['id'];
|
||||||
createdAt: ILocalUser['createdAt'];
|
createdAt: ILocalUser['createdAt'];
|
||||||
|
@ -18,24 +17,27 @@ type SimpleUserInfo = {
|
||||||
isAdmin: ILocalUser['isAdmin'];
|
isAdmin: ILocalUser['isAdmin'];
|
||||||
isModerator: ILocalUser['isModerator'];
|
isModerator: ILocalUser['isModerator'];
|
||||||
isSilenced: ILocalUser['isSilenced'];
|
isSilenced: ILocalUser['isSilenced'];
|
||||||
};
|
showTimelineReplies: ILocalUser['showTimelineReplies'];
|
||||||
|
|
||||||
type Params<T extends IEndpointMeta> = {
|
|
||||||
[P in keyof T['params']]: NonNullable<T['params']>[P]['transform'] extends () => any
|
|
||||||
? ReturnType<NonNullable<T['params']>[P]['transform']>
|
|
||||||
: NonNullable<T['params']>[P]['default'] extends null | number | string
|
|
||||||
? NonOptional<ReturnType<NonNullable<T['params']>[P]['validator']['get']>[0]>
|
|
||||||
: ReturnType<NonNullable<T['params']>[P]['validator']['get']>[0];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Response = Record<string, any> | void;
|
export type Response = Record<string, any> | void;
|
||||||
|
|
||||||
type executor<T extends IEndpointMeta> =
|
// TODO: paramsの型をT['params']のスキーマ定義から推論する
|
||||||
(params: Params<T>, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any, cleanup?: () => any) =>
|
type executor<T extends IEndpointMeta, Ps extends Schema> =
|
||||||
|
(params: SchemaType<Ps>, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any, cleanup?: () => any) =>
|
||||||
Promise<T['res'] extends undefined ? Response : SchemaType<NonNullable<T['res']>>>;
|
Promise<T['res'] extends undefined ? Response : SchemaType<NonNullable<T['res']>>>;
|
||||||
|
|
||||||
export default function <T extends IEndpointMeta>(meta: T, cb: executor<T>)
|
const ajv = new Ajv({
|
||||||
|
useDefaults: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
ajv.addFormat('misskey:id', /^[a-z0-9]+$/);
|
||||||
|
|
||||||
|
export default function <T extends IEndpointMeta, Ps extends Schema>(meta: T, paramDef: Ps, cb: executor<T, Ps>)
|
||||||
: (params: any, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any) => Promise<any> {
|
: (params: any, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any) => Promise<any> {
|
||||||
|
|
||||||
|
const validate = ajv.compile(paramDef);
|
||||||
|
|
||||||
return (params: any, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any) => {
|
return (params: any, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any) => {
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
fs.unlink(file.path, () => {});
|
fs.unlink(file.path, () => {});
|
||||||
|
@ -47,42 +49,22 @@ export default function <T extends IEndpointMeta>(meta: T, cb: executor<T>)
|
||||||
id: '4267801e-70d1-416a-b011-4ee502885d8b',
|
id: '4267801e-70d1-416a-b011-4ee502885d8b',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const [ps, pserr] = getParams(meta, params);
|
const valid = validate(params);
|
||||||
if (pserr) {
|
if (!valid) {
|
||||||
if (file) cleanup();
|
if (file) cleanup();
|
||||||
return Promise.reject(pserr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cb(ps, user, token, file, cleanup);
|
const errors = validate.errors!;
|
||||||
};
|
const err = new ApiError({
|
||||||
}
|
|
||||||
|
|
||||||
function getParams<T extends IEndpointMeta>(defs: T, params: any): [Params<T>, ApiError | null] {
|
|
||||||
if (defs.params == null) return [params, null];
|
|
||||||
|
|
||||||
const x: any = {};
|
|
||||||
let err: ApiError | null = null;
|
|
||||||
Object.entries(defs.params).some(([k, def]) => {
|
|
||||||
const [v, e] = def.validator.get(params[k]);
|
|
||||||
if (e) {
|
|
||||||
err = new ApiError({
|
|
||||||
message: 'Invalid param.',
|
message: 'Invalid param.',
|
||||||
code: 'INVALID_PARAM',
|
code: 'INVALID_PARAM',
|
||||||
id: '3d81ceae-475f-4600-b2a8-2bc116157532',
|
id: '3d81ceae-475f-4600-b2a8-2bc116157532',
|
||||||
}, {
|
}, {
|
||||||
param: k,
|
param: errors[0].schemaPath,
|
||||||
reason: e.message,
|
reason: errors[0].message,
|
||||||
});
|
});
|
||||||
return true;
|
return Promise.reject(err);
|
||||||
} else {
|
|
||||||
if (v === undefined && Object.prototype.hasOwnProperty.call(def, 'default')) {
|
|
||||||
x[k] = def.default;
|
|
||||||
} else {
|
|
||||||
x[k] = v;
|
|
||||||
}
|
}
|
||||||
if (def.transform) x[k] = def.transform(x[k]);
|
|
||||||
return false;
|
return cb(params as SchemaType<Ps>, user, token, file, cleanup);
|
||||||
}
|
};
|
||||||
});
|
|
||||||
return [x, err];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
import { dirname } from 'path';
|
import { dirname } from 'path';
|
||||||
import { Context } from 'cafy';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as glob from 'glob';
|
import * as glob from 'glob';
|
||||||
import { Schema } from '@/misc/schema';
|
import { Schema } from '@/misc/schema';
|
||||||
|
@ -9,23 +7,11 @@ import { Schema } from '@/misc/schema';
|
||||||
const _filename = __filename;
|
const _filename = __filename;
|
||||||
const _dirname = dirname(_filename);
|
const _dirname = dirname(_filename);
|
||||||
|
|
||||||
export type Param = {
|
|
||||||
validator: Context<any>;
|
|
||||||
transform?: any;
|
|
||||||
default?: any;
|
|
||||||
deprecated?: boolean;
|
|
||||||
ref?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface IEndpointMeta {
|
export interface IEndpointMeta {
|
||||||
readonly stability?: 'deprecated' | 'experimental' | 'stable';
|
readonly stability?: 'deprecated' | 'experimental' | 'stable';
|
||||||
|
|
||||||
readonly tags?: ReadonlyArray<string>;
|
readonly tags?: ReadonlyArray<string>;
|
||||||
|
|
||||||
readonly params?: {
|
|
||||||
readonly [key: string]: Param;
|
|
||||||
};
|
|
||||||
|
|
||||||
readonly errors?: {
|
readonly errors?: {
|
||||||
readonly [key: string]: {
|
readonly [key: string]: {
|
||||||
readonly message: string;
|
readonly message: string;
|
||||||
|
@ -99,12 +85,15 @@ export interface IEndpointMeta {
|
||||||
* パーミッションの実現に利用されます。
|
* パーミッションの実現に利用されます。
|
||||||
*/
|
*/
|
||||||
readonly kind?: string;
|
readonly kind?: string;
|
||||||
|
|
||||||
|
readonly description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IEndpoint {
|
export interface IEndpoint {
|
||||||
name: string;
|
name: string;
|
||||||
exec: any;
|
exec: any;
|
||||||
meta: IEndpointMeta;
|
meta: IEndpointMeta;
|
||||||
|
params: Schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = glob.sync('**/*.js', {
|
const files = glob.sync('**/*.js', {
|
||||||
|
@ -118,6 +107,7 @@ const endpoints: IEndpoint[] = files.map(f => {
|
||||||
name: f.replace('.js', ''),
|
name: f.replace('.js', ''),
|
||||||
exec: ep.default,
|
exec: ep.default,
|
||||||
meta: ep.meta || {},
|
meta: ep.meta || {},
|
||||||
|
params: ep.paramDef,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { AbuseUserReports } from '@/models/index';
|
import { AbuseUserReports } from '@/models/index';
|
||||||
import { makePaginationQuery } from '../../common/make-pagination-query';
|
import { makePaginationQuery } from '../../common/make-pagination-query';
|
||||||
|
@ -10,49 +8,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
limit: {
|
|
||||||
validator: $.optional.num.range(1, 100),
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
|
|
||||||
sinceId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
untilId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
state: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
|
|
||||||
reporterOrigin: {
|
|
||||||
validator: $.optional.str.or([
|
|
||||||
'combined',
|
|
||||||
'local',
|
|
||||||
'remote',
|
|
||||||
]),
|
|
||||||
default: 'combined',
|
|
||||||
},
|
|
||||||
|
|
||||||
targetUserOrigin: {
|
|
||||||
validator: $.optional.str.or([
|
|
||||||
'combined',
|
|
||||||
'local',
|
|
||||||
'remote',
|
|
||||||
]),
|
|
||||||
default: 'combined',
|
|
||||||
},
|
|
||||||
|
|
||||||
forwarded: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -115,8 +70,22 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
|
state: { type: 'string', nullable: true, default: null },
|
||||||
|
reporterOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "combined" },
|
||||||
|
targetUserOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "combined" },
|
||||||
|
forwarded: { type: 'boolean', default: false },
|
||||||
|
},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const query = makePaginationQuery(AbuseUserReports.createQueryBuilder('report'), ps.sinceId, ps.untilId);
|
const query = makePaginationQuery(AbuseUserReports.createQueryBuilder('report'), ps.sinceId, ps.untilId);
|
||||||
|
|
||||||
switch (ps.state) {
|
switch (ps.state) {
|
||||||
|
@ -134,7 +103,7 @@ export default define(meta, async (ps) => {
|
||||||
case 'remote': query.andWhere('report.targetUserHost IS NOT NULL'); break;
|
case 'remote': query.andWhere('report.targetUserHost IS NOT NULL'); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const reports = await query.take(ps.limit!).getMany();
|
const reports = await query.take(ps.limit).getMany();
|
||||||
|
|
||||||
return await AbuseUserReports.packMany(reports);
|
return await AbuseUserReports.packMany(reports);
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,16 +5,6 @@ import { signup } from '../../../common/signup';
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
||||||
params: {
|
|
||||||
username: {
|
|
||||||
validator: Users.validateLocalUsername,
|
|
||||||
},
|
|
||||||
|
|
||||||
password: {
|
|
||||||
validator: Users.validatePassword,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -28,8 +18,17 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
username: Users.localUsernameSchema,
|
||||||
|
password: Users.passwordSchema,
|
||||||
|
},
|
||||||
|
required: ['username', 'password'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, _me) => {
|
export default define(meta, paramDef, async (ps, _me) => {
|
||||||
const me = _me ? await Users.findOneOrFail(_me.id) : null;
|
const me = _me ? await Users.findOneOrFail(_me.id) : null;
|
||||||
const noUsers = (await Users.count({
|
const noUsers = (await Users.count({
|
||||||
host: null,
|
host: null,
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Users } from '@/models/index';
|
import { Users } from '@/models/index';
|
||||||
import { doPostSuspend } from '@/services/suspend-user';
|
import { doPostSuspend } from '@/services/suspend-user';
|
||||||
import { publishUserEvent } from '@/services/stream';
|
import { publishUserEvent } from '@/services/stream';
|
||||||
import { createDeleteAccountJob } from '@/queue';
|
import { createDeleteAccountJob } from '@/queue';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
userId: {
|
type: 'object',
|
||||||
validator: $.type(ID),
|
properties: {
|
||||||
},
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
},
|
},
|
||||||
|
required: ['userId'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const user = await Users.findOne(ps.userId);
|
const user = await Users.findOne(ps.userId);
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Ads } from '@/models/index';
|
import { Ads } from '@/models/index';
|
||||||
import { genId } from '@/misc/gen-id';
|
import { genId } from '@/misc/gen-id';
|
||||||
|
@ -8,34 +7,24 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
url: {
|
type: 'object',
|
||||||
validator: $.str.min(1),
|
properties: {
|
||||||
},
|
url: { type: 'string', minLength: 1 },
|
||||||
memo: {
|
memo: { type: 'string' },
|
||||||
validator: $.str,
|
place: { type: 'string' },
|
||||||
},
|
priority: { type: 'string' },
|
||||||
place: {
|
ratio: { type: 'integer' },
|
||||||
validator: $.str,
|
expiresAt: { type: 'integer' },
|
||||||
},
|
imageUrl: { type: 'string', minLength: 1 },
|
||||||
priority: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
ratio: {
|
|
||||||
validator: $.num.int().min(0),
|
|
||||||
},
|
|
||||||
expiresAt: {
|
|
||||||
validator: $.num.int(),
|
|
||||||
},
|
|
||||||
imageUrl: {
|
|
||||||
validator: $.str.min(1),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
required: ['url', 'memo', 'place', 'priority', 'ratio', 'expiresAt', 'imageUrl'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
await Ads.insert({
|
await Ads.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Ads } from '@/models/index';
|
import { Ads } from '@/models/index';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
|
|
||||||
|
@ -10,12 +8,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
id: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchAd: {
|
noSuchAd: {
|
||||||
message: 'No such ad.',
|
message: 'No such ad.',
|
||||||
|
@ -25,8 +17,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
id: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['id'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const ad = await Ads.findOne(ps.id);
|
const ad = await Ads.findOne(ps.id);
|
||||||
|
|
||||||
if (ad == null) throw new ApiError(meta.errors.noSuchAd);
|
if (ad == null) throw new ApiError(meta.errors.noSuchAd);
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Ads } from '@/models/index';
|
import { Ads } from '@/models/index';
|
||||||
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
||||||
|
@ -9,29 +7,24 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
limit: {
|
type: 'object',
|
||||||
validator: $.optional.num.range(1, 100),
|
properties: {
|
||||||
default: 10,
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
},
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
sinceId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
untilId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
required: [],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const query = makePaginationQuery(Ads.createQueryBuilder('ad'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(Ads.createQueryBuilder('ad'), ps.sinceId, ps.untilId)
|
||||||
.andWhere('ad.expiresAt > :now', { now: new Date() });
|
.andWhere('ad.expiresAt > :now', { now: new Date() });
|
||||||
|
|
||||||
const ads = await query.take(ps.limit!).getMany();
|
const ads = await query.take(ps.limit).getMany();
|
||||||
|
|
||||||
return ads;
|
return ads;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Ads } from '@/models/index';
|
import { Ads } from '@/models/index';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
|
|
||||||
|
@ -10,33 +8,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
id: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
memo: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
url: {
|
|
||||||
validator: $.str.min(1),
|
|
||||||
},
|
|
||||||
imageUrl: {
|
|
||||||
validator: $.str.min(1),
|
|
||||||
},
|
|
||||||
place: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
priority: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
ratio: {
|
|
||||||
validator: $.num.int().min(0),
|
|
||||||
},
|
|
||||||
expiresAt: {
|
|
||||||
validator: $.num.int(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchAd: {
|
noSuchAd: {
|
||||||
message: 'No such ad.',
|
message: 'No such ad.',
|
||||||
|
@ -46,8 +17,23 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
id: { type: 'string', format: 'misskey:id' },
|
||||||
|
memo: { type: 'string' },
|
||||||
|
url: { type: 'string', minLength: 1 },
|
||||||
|
imageUrl: { type: 'string', minLength: 1 },
|
||||||
|
place: { type: 'string' },
|
||||||
|
priority: { type: 'string' },
|
||||||
|
ratio: { type: 'integer' },
|
||||||
|
expiresAt: { type: 'integer' },
|
||||||
|
},
|
||||||
|
required: ['id', 'memo', 'url', 'imageUrl', 'place', 'priority', 'ratio', 'expiresAt'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const ad = await Ads.findOne(ps.id);
|
const ad = await Ads.findOne(ps.id);
|
||||||
|
|
||||||
if (ad == null) throw new ApiError(meta.errors.noSuchAd);
|
if (ad == null) throw new ApiError(meta.errors.noSuchAd);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Announcements } from '@/models/index';
|
import { Announcements } from '@/models/index';
|
||||||
import { genId } from '@/misc/gen-id';
|
import { genId } from '@/misc/gen-id';
|
||||||
|
@ -9,18 +8,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
title: {
|
|
||||||
validator: $.str.min(1),
|
|
||||||
},
|
|
||||||
text: {
|
|
||||||
validator: $.str.min(1),
|
|
||||||
},
|
|
||||||
imageUrl: {
|
|
||||||
validator: $.nullable.str.min(1),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -57,8 +44,18 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
title: { type: 'string', minLength: 1 },
|
||||||
|
text: { type: 'string', minLength: 1 },
|
||||||
|
imageUrl: { type: 'string', nullable: true, minLength: 1 },
|
||||||
|
},
|
||||||
|
required: ['title', 'text', 'imageUrl'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const announcement = await Announcements.insert({
|
const announcement = await Announcements.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
|
@ -68,5 +65,5 @@ export default define(meta, async (ps) => {
|
||||||
imageUrl: ps.imageUrl,
|
imageUrl: ps.imageUrl,
|
||||||
}).then(x => Announcements.findOneOrFail(x.identifiers[0]));
|
}).then(x => Announcements.findOneOrFail(x.identifiers[0]));
|
||||||
|
|
||||||
return announcement;
|
return Object.assign({}, announcement, { createdAt: announcement.createdAt.toISOString(), updatedAt: null });
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Announcements } from '@/models/index';
|
import { Announcements } from '@/models/index';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
|
|
||||||
|
@ -10,12 +8,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
id: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchAnnouncement: {
|
noSuchAnnouncement: {
|
||||||
message: 'No such announcement.',
|
message: 'No such announcement.',
|
||||||
|
@ -25,8 +17,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
id: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['id'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const announcement = await Announcements.findOne(ps.id);
|
const announcement = await Announcements.findOne(ps.id);
|
||||||
|
|
||||||
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
|
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Announcements, AnnouncementReads } from '@/models/index';
|
import { Announcements, AnnouncementReads } from '@/models/index';
|
||||||
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
||||||
|
@ -10,21 +8,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
limit: {
|
|
||||||
validator: $.optional.num.range(1, 100),
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
|
|
||||||
sinceId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
untilId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -69,11 +52,21 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const query = makePaginationQuery(Announcements.createQueryBuilder('announcement'), ps.sinceId, ps.untilId);
|
const query = makePaginationQuery(Announcements.createQueryBuilder('announcement'), ps.sinceId, ps.untilId);
|
||||||
|
|
||||||
const announcements = await query.take(ps.limit!).getMany();
|
const announcements = await query.take(ps.limit).getMany();
|
||||||
|
|
||||||
for (const announcement of announcements) {
|
for (const announcement of announcements) {
|
||||||
(announcement as any).reads = await AnnouncementReads.count({
|
(announcement as any).reads = await AnnouncementReads.count({
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Announcements } from '@/models/index';
|
import { Announcements } from '@/models/index';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
|
|
||||||
|
@ -10,21 +8,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
id: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
validator: $.str.min(1),
|
|
||||||
},
|
|
||||||
text: {
|
|
||||||
validator: $.str.min(1),
|
|
||||||
},
|
|
||||||
imageUrl: {
|
|
||||||
validator: $.nullable.str.min(1),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchAnnouncement: {
|
noSuchAnnouncement: {
|
||||||
message: 'No such announcement.',
|
message: 'No such announcement.',
|
||||||
|
@ -34,8 +17,19 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
id: { type: 'string', format: 'misskey:id' },
|
||||||
|
title: { type: 'string', minLength: 1 },
|
||||||
|
text: { type: 'string', minLength: 1 },
|
||||||
|
imageUrl: { type: 'string', nullable: true, minLength: 1 },
|
||||||
|
},
|
||||||
|
required: ['id', 'title', 'text', 'imageUrl'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const announcement = await Announcements.findOne(ps.id);
|
const announcement = await Announcements.findOne(ps.id);
|
||||||
|
|
||||||
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
|
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { deleteFile } from '@/services/drive/delete-file';
|
import { deleteFile } from '@/services/drive/delete-file';
|
||||||
import { DriveFiles } from '@/models/index';
|
import { DriveFiles } from '@/models/index';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
userId: {
|
type: 'object',
|
||||||
validator: $.type(ID),
|
properties: {
|
||||||
},
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
},
|
},
|
||||||
|
required: ['userId'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const files = await DriveFiles.find({
|
const files = await DriveFiles.find({
|
||||||
userId: ps.userId,
|
userId: ps.userId,
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,13 @@ export const meta = {
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
createCleanRemoteFilesJob();
|
createCleanRemoteFilesJob();
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,8 +10,14 @@ export const meta = {
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const files = await DriveFiles.find({
|
const files = await DriveFiles.find({
|
||||||
userId: IsNull(),
|
userId: IsNull(),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { DriveFiles } from '@/models/index';
|
import { DriveFiles } from '@/models/index';
|
||||||
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -10,39 +8,6 @@ export const meta = {
|
||||||
requireCredential: false,
|
requireCredential: false,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
limit: {
|
|
||||||
validator: $.optional.num.range(1, 100),
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
|
|
||||||
sinceId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
untilId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
type: {
|
|
||||||
validator: $.optional.nullable.str.match(/^[a-zA-Z0-9\/\-*]+$/),
|
|
||||||
},
|
|
||||||
|
|
||||||
origin: {
|
|
||||||
validator: $.optional.str.or([
|
|
||||||
'combined',
|
|
||||||
'local',
|
|
||||||
'remote',
|
|
||||||
]),
|
|
||||||
default: 'local',
|
|
||||||
},
|
|
||||||
|
|
||||||
hostname: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -54,8 +19,21 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
|
type: { type: 'string', nullable: true, pattern: /^[a-zA-Z0-9\/\-*]+$/.toString().slice(1, -1) },
|
||||||
|
origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "local" },
|
||||||
|
hostname: { type: 'string', nullable: true, default: null },
|
||||||
|
},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const query = makePaginationQuery(DriveFiles.createQueryBuilder('file'), ps.sinceId, ps.untilId);
|
const query = makePaginationQuery(DriveFiles.createQueryBuilder('file'), ps.sinceId, ps.untilId);
|
||||||
|
|
||||||
if (ps.origin === 'local') {
|
if (ps.origin === 'local') {
|
||||||
|
@ -76,7 +54,7 @@ export default define(meta, async (ps, me) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = await query.take(ps.limit!).getMany();
|
const files = await query.take(ps.limit).getMany();
|
||||||
|
|
||||||
return await DriveFiles.packMany(files, { detail: true, withUser: true, self: true });
|
return await DriveFiles.packMany(files, { detail: true, withUser: true, self: true });
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
import { DriveFiles } from '@/models/index';
|
import { DriveFiles } from '@/models/index';
|
||||||
|
@ -10,16 +8,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
fileId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
url: {
|
|
||||||
validator: $.optional.str,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchFile: {
|
noSuchFile: {
|
||||||
message: 'No such file.',
|
message: 'No such file.',
|
||||||
|
@ -161,8 +149,17 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
fileId: { type: 'string', format: 'misskey:id' },
|
||||||
|
url: { type: 'string' },
|
||||||
|
},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const file = ps.fileId ? await DriveFiles.findOne(ps.fileId) : await DriveFiles.findOne({
|
const file = ps.fileId ? await DriveFiles.findOne(ps.fileId) : await DriveFiles.findOne({
|
||||||
where: [{
|
where: [{
|
||||||
url: ps.url,
|
url: ps.url,
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Emojis } from '@/models/index';
|
import { Emojis } from '@/models/index';
|
||||||
import { getConnection, In } from 'typeorm';
|
import { getConnection, In } from 'typeorm';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
|
@ -10,20 +8,23 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
ids: {
|
type: 'object',
|
||||||
validator: $.arr($.type(ID)),
|
properties: {
|
||||||
},
|
ids: { type: 'array', items: {
|
||||||
|
type: 'string', format: 'misskey:id',
|
||||||
aliases: {
|
} },
|
||||||
validator: $.arr($.str),
|
aliases: { type: 'array', items: {
|
||||||
},
|
type: 'string',
|
||||||
|
} },
|
||||||
},
|
},
|
||||||
|
required: ['ids', 'aliases'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const emojis = await Emojis.find({
|
const emojis = await Emojis.find({
|
||||||
id: In(ps.ids),
|
id: In(ps.ids),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Emojis, DriveFiles } from '@/models/index';
|
import { Emojis, DriveFiles } from '@/models/index';
|
||||||
import { genId } from '@/misc/gen-id';
|
import { genId } from '@/misc/gen-id';
|
||||||
import { getConnection } from 'typeorm';
|
import { getConnection } from 'typeorm';
|
||||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import rndstr from 'rndstr';
|
import rndstr from 'rndstr';
|
||||||
import { publishBroadcastStream } from '@/services/stream';
|
import { publishBroadcastStream } from '@/services/stream';
|
||||||
|
|
||||||
|
@ -15,12 +13,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
fileId: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchFile: {
|
noSuchFile: {
|
||||||
message: 'No such file.',
|
message: 'No such file.',
|
||||||
|
@ -30,8 +22,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
fileId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['fileId'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const file = await DriveFiles.findOne(ps.fileId);
|
const file = await DriveFiles.findOne(ps.fileId);
|
||||||
|
|
||||||
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
if (file == null) throw new ApiError(meta.errors.noSuchFile);
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Emojis } from '@/models/index';
|
import { Emojis } from '@/models/index';
|
||||||
import { genId } from '@/misc/gen-id';
|
import { genId } from '@/misc/gen-id';
|
||||||
import { getConnection } from 'typeorm';
|
import { getConnection } from 'typeorm';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
import { DriveFile } from '@/models/entities/drive-file';
|
import { DriveFile } from '@/models/entities/drive-file';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { uploadFromUrl } from '@/services/drive/upload-from-url';
|
import { uploadFromUrl } from '@/services/drive/upload-from-url';
|
||||||
import { publishBroadcastStream } from '@/services/stream';
|
import { publishBroadcastStream } from '@/services/stream';
|
||||||
|
|
||||||
|
@ -15,12 +13,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
emojiId: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchEmoji: {
|
noSuchEmoji: {
|
||||||
message: 'No such emoji.',
|
message: 'No such emoji.',
|
||||||
|
@ -42,8 +34,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
emojiId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['emojiId'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const emoji = await Emojis.findOne(ps.emojiId);
|
const emoji = await Emojis.findOne(ps.emojiId);
|
||||||
|
|
||||||
if (emoji == null) {
|
if (emoji == null) {
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Emojis } from '@/models/index';
|
import { Emojis } from '@/models/index';
|
||||||
import { getConnection, In } from 'typeorm';
|
import { getConnection, In } from 'typeorm';
|
||||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||||
|
@ -11,16 +9,20 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
ids: {
|
type: 'object',
|
||||||
validator: $.arr($.type(ID)),
|
properties: {
|
||||||
},
|
ids: { type: 'array', items: {
|
||||||
|
type: 'string', format: 'misskey:id',
|
||||||
|
} },
|
||||||
},
|
},
|
||||||
|
required: ['ids'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const emojis = await Emojis.find({
|
const emojis = await Emojis.find({
|
||||||
id: In(ps.ids),
|
id: In(ps.ids),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Emojis } from '@/models/index';
|
import { Emojis } from '@/models/index';
|
||||||
import { getConnection } from 'typeorm';
|
import { getConnection } from 'typeorm';
|
||||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||||
|
@ -12,12 +10,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
id: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchEmoji: {
|
noSuchEmoji: {
|
||||||
message: 'No such emoji.',
|
message: 'No such emoji.',
|
||||||
|
@ -27,8 +19,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
id: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['id'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const emoji = await Emojis.findOne(ps.id);
|
const emoji = await Emojis.findOne(ps.id);
|
||||||
|
|
||||||
if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji);
|
if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji);
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { createImportCustomEmojisJob } from '@/queue/index';
|
import { createImportCustomEmojisJob } from '@/queue/index';
|
||||||
import ms from 'ms';
|
import ms from 'ms';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
secure: true,
|
secure: true,
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
params: {
|
} as const;
|
||||||
fileId: {
|
|
||||||
validator: $.type(ID),
|
export const paramDef = {
|
||||||
},
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
fileId: { type: 'string', format: 'misskey:id' },
|
||||||
},
|
},
|
||||||
|
required: ['fileId'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
createImportCustomEmojisJob(user, ps.fileId);
|
createImportCustomEmojisJob(user, ps.fileId);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Emojis } from '@/models/index';
|
import { Emojis } from '@/models/index';
|
||||||
import { toPuny } from '@/misc/convert-host';
|
import { toPuny } from '@/misc/convert-host';
|
||||||
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -11,31 +9,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
query: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
|
|
||||||
host: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
|
|
||||||
limit: {
|
|
||||||
validator: $.optional.num.range(1, 100),
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
|
|
||||||
sinceId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
untilId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -77,8 +50,20 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
query: { type: 'string', nullable: true, default: null },
|
||||||
|
host: { type: 'string', nullable: true, default: null },
|
||||||
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId);
|
const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId);
|
||||||
|
|
||||||
if (ps.host == null) {
|
if (ps.host == null) {
|
||||||
|
@ -93,7 +78,7 @@ export default define(meta, async (ps) => {
|
||||||
|
|
||||||
const emojis = await q
|
const emojis = await q
|
||||||
.orderBy('emoji.id', 'DESC')
|
.orderBy('emoji.id', 'DESC')
|
||||||
.take(ps.limit!)
|
.take(ps.limit)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
return Emojis.packMany(emojis);
|
return Emojis.packMany(emojis);
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Emojis } from '@/models/index';
|
import { Emojis } from '@/models/index';
|
||||||
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
import { makePaginationQuery } from '../../../common/make-pagination-query';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Emoji } from '@/models/entities/emoji';
|
import { Emoji } from '@/models/entities/emoji';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
@ -11,26 +9,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
query: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
|
|
||||||
limit: {
|
|
||||||
validator: $.optional.num.range(1, 100),
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
|
|
||||||
sinceId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
untilId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -72,8 +50,19 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
query: { type: 'string', nullable: true, default: null },
|
||||||
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId)
|
const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId)
|
||||||
.andWhere(`emoji.host IS NULL`);
|
.andWhere(`emoji.host IS NULL`);
|
||||||
|
|
||||||
|
@ -81,7 +70,7 @@ export default define(meta, async (ps) => {
|
||||||
|
|
||||||
if (ps.query) {
|
if (ps.query) {
|
||||||
//q.andWhere('emoji.name ILIKE :q', { q: `%${ps.query}%` });
|
//q.andWhere('emoji.name ILIKE :q', { q: `%${ps.query}%` });
|
||||||
//const emojis = await q.take(ps.limit!).getMany();
|
//const emojis = await q.take(ps.limit).getMany();
|
||||||
|
|
||||||
emojis = await q.getMany();
|
emojis = await q.getMany();
|
||||||
|
|
||||||
|
@ -90,9 +79,9 @@ export default define(meta, async (ps) => {
|
||||||
emoji.aliases.some(a => a.includes(ps.query!)) ||
|
emoji.aliases.some(a => a.includes(ps.query!)) ||
|
||||||
emoji.category?.includes(ps.query!));
|
emoji.category?.includes(ps.query!));
|
||||||
|
|
||||||
emojis.splice(ps.limit! + 1);
|
emojis.splice(ps.limit + 1);
|
||||||
} else {
|
} else {
|
||||||
emojis = await q.take(ps.limit!).getMany();
|
emojis = await q.take(ps.limit).getMany();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Emojis.packMany(emojis);
|
return Emojis.packMany(emojis);
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Emojis } from '@/models/index';
|
import { Emojis } from '@/models/index';
|
||||||
import { getConnection, In } from 'typeorm';
|
import { getConnection, In } from 'typeorm';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
|
@ -10,20 +8,23 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
ids: {
|
type: 'object',
|
||||||
validator: $.arr($.type(ID)),
|
properties: {
|
||||||
},
|
ids: { type: 'array', items: {
|
||||||
|
type: 'string', format: 'misskey:id',
|
||||||
aliases: {
|
} },
|
||||||
validator: $.arr($.str),
|
aliases: { type: 'array', items: {
|
||||||
},
|
type: 'string',
|
||||||
|
} },
|
||||||
},
|
},
|
||||||
|
required: ['ids', 'aliases'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const emojis = await Emojis.find({
|
const emojis = await Emojis.find({
|
||||||
id: In(ps.ids),
|
id: In(ps.ids),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Emojis } from '@/models/index';
|
import { Emojis } from '@/models/index';
|
||||||
import { getConnection, In } from 'typeorm';
|
import { getConnection, In } from 'typeorm';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
|
@ -10,20 +8,23 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
ids: {
|
type: 'object',
|
||||||
validator: $.arr($.type(ID)),
|
properties: {
|
||||||
},
|
ids: { type: 'array', items: {
|
||||||
|
type: 'string', format: 'misskey:id',
|
||||||
aliases: {
|
} },
|
||||||
validator: $.arr($.str),
|
aliases: { type: 'array', items: {
|
||||||
},
|
type: 'string',
|
||||||
|
} },
|
||||||
},
|
},
|
||||||
|
required: ['ids', 'aliases'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
await Emojis.update({
|
await Emojis.update({
|
||||||
id: In(ps.ids),
|
id: In(ps.ids),
|
||||||
}, {
|
}, {
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Emojis } from '@/models/index';
|
import { Emojis } from '@/models/index';
|
||||||
import { getConnection, In } from 'typeorm';
|
import { getConnection, In } from 'typeorm';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
|
@ -10,20 +8,21 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
ids: {
|
type: 'object',
|
||||||
validator: $.arr($.type(ID)),
|
properties: {
|
||||||
},
|
ids: { type: 'array', items: {
|
||||||
|
type: 'string', format: 'misskey:id',
|
||||||
category: {
|
} },
|
||||||
validator: $.optional.nullable.str,
|
category: { type: 'string', nullable: true },
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
required: ['ids'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
await Emojis.update({
|
await Emojis.update({
|
||||||
id: In(ps.ids),
|
id: In(ps.ids),
|
||||||
}, {
|
}, {
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { Emojis } from '@/models/index';
|
import { Emojis } from '@/models/index';
|
||||||
import { getConnection } from 'typeorm';
|
import { getConnection } from 'typeorm';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
|
@ -11,24 +9,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
id: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
name: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
category: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
aliases: {
|
|
||||||
validator: $.arr($.str),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchEmoji: {
|
noSuchEmoji: {
|
||||||
message: 'No such emoji.',
|
message: 'No such emoji.',
|
||||||
|
@ -38,8 +18,21 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
id: { type: 'string', format: 'misskey:id' },
|
||||||
|
name: { type: 'string' },
|
||||||
|
category: { type: 'string', nullable: true },
|
||||||
|
aliases: { type: 'array', items: {
|
||||||
|
type: 'string',
|
||||||
|
} },
|
||||||
|
},
|
||||||
|
required: ['id', 'name', 'aliases'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const emoji = await Emojis.findOne(ps.id);
|
const emoji = await Emojis.findOne(ps.id);
|
||||||
|
|
||||||
if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji);
|
if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { deleteFile } from '@/services/drive/delete-file';
|
import { deleteFile } from '@/services/drive/delete-file';
|
||||||
import { DriveFiles } from '@/models/index';
|
import { DriveFiles } from '@/models/index';
|
||||||
|
@ -8,16 +7,18 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
host: {
|
type: 'object',
|
||||||
validator: $.str,
|
properties: {
|
||||||
},
|
host: { type: 'string' },
|
||||||
},
|
},
|
||||||
|
required: ['host'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const files = await DriveFiles.find({
|
const files = await DriveFiles.find({
|
||||||
userHost: ps.host,
|
userHost: ps.host,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Instances } from '@/models/index';
|
import { Instances } from '@/models/index';
|
||||||
import { toPuny } from '@/misc/convert-host';
|
import { toPuny } from '@/misc/convert-host';
|
||||||
|
@ -9,16 +8,18 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
host: {
|
type: 'object',
|
||||||
validator: $.str,
|
properties: {
|
||||||
},
|
host: { type: 'string' },
|
||||||
},
|
},
|
||||||
|
required: ['host'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const instance = await Instances.findOne({ host: toPuny(ps.host) });
|
const instance = await Instances.findOne({ host: toPuny(ps.host) });
|
||||||
|
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import deleteFollowing from '@/services/following/delete';
|
import deleteFollowing from '@/services/following/delete';
|
||||||
import { Followings, Users } from '@/models/index';
|
import { Followings, Users } from '@/models/index';
|
||||||
|
@ -8,16 +7,18 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
host: {
|
type: 'object',
|
||||||
validator: $.str,
|
properties: {
|
||||||
},
|
host: { type: 'string' },
|
||||||
},
|
},
|
||||||
|
required: ['host'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const followings = await Followings.find({
|
const followings = await Followings.find({
|
||||||
followerHost: ps.host,
|
followerHost: ps.host,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Instances } from '@/models/index';
|
import { Instances } from '@/models/index';
|
||||||
import { toPuny } from '@/misc/convert-host';
|
import { toPuny } from '@/misc/convert-host';
|
||||||
|
@ -8,20 +7,19 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
host: {
|
type: 'object',
|
||||||
validator: $.str,
|
properties: {
|
||||||
},
|
host: { type: 'string' },
|
||||||
|
isSuspended: { type: 'boolean' },
|
||||||
isSuspended: {
|
|
||||||
validator: $.bool,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
required: ['host', 'isSuspended'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const instance = await Instances.findOne({ host: toPuny(ps.host) });
|
const instance = await Instances.findOne({ host: toPuny(ps.host) });
|
||||||
|
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
|
|
|
@ -6,13 +6,16 @@ export const meta = {
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
},
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async () => {
|
export default define(meta, paramDef, async () => {
|
||||||
const stats = await
|
const stats = await
|
||||||
getConnection().query(`SELECT * FROM pg_indexes;`)
|
getConnection().query(`SELECT * FROM pg_indexes;`)
|
||||||
.then(recs => {
|
.then(recs => {
|
||||||
|
|
|
@ -7,9 +7,6 @@ export const meta = {
|
||||||
|
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
||||||
params: {
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -22,8 +19,14 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async () => {
|
export default define(meta, paramDef, async () => {
|
||||||
const sizes = await
|
const sizes = await
|
||||||
getConnection().query(`
|
getConnection().query(`
|
||||||
SELECT relname AS "table", reltuples as "count", pg_total_relation_size(C.oid) AS "size"
|
SELECT relname AS "table", reltuples as "count", pg_total_relation_size(C.oid) AS "size"
|
||||||
|
|
|
@ -9,8 +9,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -26,8 +24,14 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async () => {
|
export default define(meta, paramDef, async () => {
|
||||||
const code = rndstr({
|
const code = rndstr({
|
||||||
length: 8,
|
length: 8,
|
||||||
chars: '2-9A-HJ-NP-Z', // [0-9A-Z] w/o [01IO] (32 patterns)
|
chars: '2-9A-HJ-NP-Z', // [0-9A-Z] w/o [01IO] (32 patterns)
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Users } from '@/models/index';
|
import { Users } from '@/models/index';
|
||||||
|
|
||||||
|
@ -8,16 +6,18 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireAdmin: true,
|
requireAdmin: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
userId: {
|
type: 'object',
|
||||||
validator: $.type(ID),
|
properties: {
|
||||||
},
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
},
|
},
|
||||||
|
required: ['userId'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const user = await Users.findOne(ps.userId as string);
|
const user = await Users.findOne(ps.userId as string);
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Users } from '@/models/index';
|
import { Users } from '@/models/index';
|
||||||
|
|
||||||
|
@ -8,16 +6,18 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireAdmin: true,
|
requireAdmin: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
userId: {
|
type: 'object',
|
||||||
validator: $.type(ID),
|
properties: {
|
||||||
},
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
},
|
},
|
||||||
|
required: ['userId'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const user = await Users.findOne(ps.userId as string);
|
const user = await Users.findOne(ps.userId as string);
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
import { getNote } from '../../../common/getters';
|
import { getNote } from '../../../common/getters';
|
||||||
|
@ -11,16 +9,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
noteId: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
expiresAt: {
|
|
||||||
validator: $.num.int(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchNote: {
|
noSuchNote: {
|
||||||
message: 'No such note.',
|
message: 'No such note.',
|
||||||
|
@ -36,8 +24,17 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
noteId: { type: 'string', format: 'misskey:id' },
|
||||||
|
expiresAt: { type: 'integer' },
|
||||||
|
},
|
||||||
|
required: ['noteId', 'expiresAt'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
const note = await getNote(ps.noteId).catch(e => {
|
const note = await getNote(ps.noteId).catch(e => {
|
||||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -51,7 +48,6 @@ export default define(meta, async (ps, user) => {
|
||||||
|
|
||||||
await PromoNotes.insert({
|
await PromoNotes.insert({
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
createdAt: new Date(),
|
|
||||||
expiresAt: new Date(ps.expiresAt),
|
expiresAt: new Date(ps.expiresAt),
|
||||||
userId: note.userId,
|
userId: note.userId,
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,12 +7,16 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {},
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
destroy();
|
destroy();
|
||||||
|
|
||||||
insertModerationLog(me, 'clearQueue');
|
insertModerationLog(me, 'clearQueue');
|
||||||
|
|
|
@ -8,9 +8,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -35,8 +32,14 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const jobs = await deliverQueue.getJobs(['delayed']);
|
const jobs = await deliverQueue.getJobs(['delayed']);
|
||||||
|
|
||||||
const res = [] as [string, number][];
|
const res = [] as [string, number][];
|
||||||
|
|
|
@ -8,9 +8,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -35,8 +32,14 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const jobs = await inboxQueue.getJobs(['delayed']);
|
const jobs = await inboxQueue.getJobs(['delayed']);
|
||||||
|
|
||||||
const res = [] as [string, number][];
|
const res = [] as [string, number][];
|
||||||
|
|
|
@ -1,82 +0,0 @@
|
||||||
import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '@/queue/queues';
|
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
|
||||||
|
|
||||||
export const meta = {
|
|
||||||
tags: ['admin'],
|
|
||||||
|
|
||||||
requireCredential: true,
|
|
||||||
requireModerator: true,
|
|
||||||
|
|
||||||
params: {
|
|
||||||
domain: {
|
|
||||||
validator: $.str.or(['deliver', 'inbox', 'db', 'objectStorage']),
|
|
||||||
},
|
|
||||||
|
|
||||||
state: {
|
|
||||||
validator: $.str.or(['active', 'waiting', 'delayed']),
|
|
||||||
},
|
|
||||||
|
|
||||||
limit: {
|
|
||||||
validator: $.optional.num,
|
|
||||||
default: 50,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
|
||||||
type: 'array',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
items: {
|
|
||||||
type: 'object',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
properties: {
|
|
||||||
id: {
|
|
||||||
type: 'string',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
format: 'id',
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
type: 'object',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
attempts: {
|
|
||||||
type: 'number',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
maxAttempts: {
|
|
||||||
type: 'number',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
timestamp: {
|
|
||||||
type: 'number',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
|
||||||
export default define(meta, async (ps) => {
|
|
||||||
const queue =
|
|
||||||
ps.domain === 'deliver' ? deliverQueue :
|
|
||||||
ps.domain === 'inbox' ? inboxQueue :
|
|
||||||
ps.domain === 'db' ? dbQueue :
|
|
||||||
ps.domain === 'objectStorage' ? objectStorageQueue :
|
|
||||||
null as never;
|
|
||||||
|
|
||||||
const jobs = await queue.getJobs([ps.state], 0, ps.limit!);
|
|
||||||
|
|
||||||
return jobs.map(job => {
|
|
||||||
const data = job.data;
|
|
||||||
delete data.content;
|
|
||||||
delete data.user;
|
|
||||||
return {
|
|
||||||
id: job.id,
|
|
||||||
data,
|
|
||||||
attempts: job.attemptsMade,
|
|
||||||
maxAttempts: job.opts ? job.opts.attempts : 0,
|
|
||||||
timestamp: job.timestamp,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -7,8 +7,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -33,8 +31,14 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const deliverJobCounts = await deliverQueue.getJobCounts();
|
const deliverJobCounts = await deliverQueue.getJobCounts();
|
||||||
const inboxJobCounts = await inboxQueue.getJobCounts();
|
const inboxJobCounts = await inboxQueue.getJobCounts();
|
||||||
const dbJobCounts = await dbQueue.getJobCounts();
|
const dbJobCounts = await dbQueue.getJobCounts();
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { URL } from 'url';
|
import { URL } from 'url';
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { addRelay } from '@/services/relay';
|
import { addRelay } from '@/services/relay';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
|
@ -10,12 +9,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
inbox: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
invalidUrl: {
|
invalidUrl: {
|
||||||
message: 'Invalid URL',
|
message: 'Invalid URL',
|
||||||
|
@ -52,8 +45,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
inbox: { type: 'string' },
|
||||||
|
},
|
||||||
|
required: ['inbox'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
try {
|
try {
|
||||||
if (new URL(ps.inbox).protocol !== 'https:') throw 'https only';
|
if (new URL(ps.inbox).protocol !== 'https:') throw 'https only';
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -7,9 +7,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -42,7 +39,13 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
return await listRelay();
|
return await listRelay();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { removeRelay } from '@/services/relay';
|
import { removeRelay } from '@/services/relay';
|
||||||
|
|
||||||
|
@ -7,15 +6,17 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
inbox: {
|
type: 'object',
|
||||||
validator: $.str,
|
properties: {
|
||||||
},
|
inbox: { type: 'string' },
|
||||||
},
|
},
|
||||||
|
required: ['inbox'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
return await removeRelay(ps.inbox);
|
return await removeRelay(ps.inbox);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import * as bcrypt from 'bcryptjs';
|
import * as bcrypt from 'bcryptjs';
|
||||||
import rndstr from 'rndstr';
|
import rndstr from 'rndstr';
|
||||||
|
@ -11,12 +9,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
userId: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -31,8 +23,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['userId'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const user = await Users.findOne(ps.userId as string);
|
const user = await Users.findOne(ps.userId as string);
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { AbuseUserReports, Users } from '@/models/index';
|
import { AbuseUserReports, Users } from '@/models/index';
|
||||||
import { getInstanceActor } from '@/services/instance-actor';
|
import { getInstanceActor } from '@/services/instance-actor';
|
||||||
|
@ -12,22 +10,19 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
reportId: {
|
type: 'object',
|
||||||
validator: $.type(ID),
|
properties: {
|
||||||
},
|
reportId: { type: 'string', format: 'misskey:id' },
|
||||||
|
forward: { type: 'boolean', default: false },
|
||||||
forward: {
|
|
||||||
validator: $.optional.boolean,
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
required: ['reportId'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const report = await AbuseUserReports.findOne(ps.reportId);
|
const report = await AbuseUserReports.findOne(ps.reportId);
|
||||||
|
|
||||||
if (report == null) {
|
if (report == null) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { sendEmail } from '@/services/send-email';
|
import { sendEmail } from '@/services/send-email';
|
||||||
|
|
||||||
|
@ -7,21 +6,19 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
to: {
|
type: 'object',
|
||||||
validator: $.str,
|
properties: {
|
||||||
},
|
to: { type: 'string' },
|
||||||
subject: {
|
subject: { type: 'string' },
|
||||||
validator: $.str,
|
text: { type: 'string' },
|
||||||
},
|
|
||||||
text: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
required: ['to', 'subject', 'text'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
await sendEmail(ps.to, ps.subject, ps.text, ps.text);
|
await sendEmail(ps.to, ps.subject, ps.text, ps.text);
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,9 +10,6 @@ export const meta = {
|
||||||
|
|
||||||
tags: ['admin', 'meta'],
|
tags: ['admin', 'meta'],
|
||||||
|
|
||||||
params: {
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -90,8 +87,14 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async () => {
|
export default define(meta, paramDef, async () => {
|
||||||
const memStats = await si.mem();
|
const memStats = await si.mem();
|
||||||
const fsStats = await si.fsSize();
|
const fsStats = await si.fsSize();
|
||||||
const netInterface = await si.networkInterfaceDefault();
|
const netInterface = await si.networkInterfaceDefault();
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { ModerationLogs } from '@/models/index';
|
import { ModerationLogs } from '@/models/index';
|
||||||
import { makePaginationQuery } from '../../common/make-pagination-query';
|
import { makePaginationQuery } from '../../common/make-pagination-query';
|
||||||
|
@ -10,21 +8,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
limit: {
|
|
||||||
validator: $.optional.num.range(1, 100),
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
|
|
||||||
sinceId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
untilId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -65,11 +48,21 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const query = makePaginationQuery(ModerationLogs.createQueryBuilder('report'), ps.sinceId, ps.untilId);
|
const query = makePaginationQuery(ModerationLogs.createQueryBuilder('report'), ps.sinceId, ps.untilId);
|
||||||
|
|
||||||
const reports = await query.take(ps.limit!).getMany();
|
const reports = await query.take(ps.limit).getMany();
|
||||||
|
|
||||||
return await ModerationLogs.packMany(reports);
|
return await ModerationLogs.packMany(reports);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { Users } from '@/models/index';
|
import { Users } from '@/models/index';
|
||||||
|
|
||||||
|
@ -9,20 +7,22 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
userId: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
nullable: false, optional: false,
|
nullable: false, optional: false,
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['userId'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const user = await Users.findOne(ps.userId as string);
|
const user = await Users.findOne(ps.userId as string);
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { Users } from '@/models/index';
|
import { Users } from '@/models/index';
|
||||||
|
|
||||||
|
@ -8,61 +7,6 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
limit: {
|
|
||||||
validator: $.optional.num.range(1, 100),
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
|
|
||||||
offset: {
|
|
||||||
validator: $.optional.num.min(0),
|
|
||||||
default: 0,
|
|
||||||
},
|
|
||||||
|
|
||||||
sort: {
|
|
||||||
validator: $.optional.str.or([
|
|
||||||
'+follower',
|
|
||||||
'-follower',
|
|
||||||
'+createdAt',
|
|
||||||
'-createdAt',
|
|
||||||
'+updatedAt',
|
|
||||||
'-updatedAt',
|
|
||||||
]),
|
|
||||||
},
|
|
||||||
|
|
||||||
state: {
|
|
||||||
validator: $.optional.str.or([
|
|
||||||
'all',
|
|
||||||
'available',
|
|
||||||
'admin',
|
|
||||||
'moderator',
|
|
||||||
'adminOrModerator',
|
|
||||||
'silenced',
|
|
||||||
'suspended',
|
|
||||||
]),
|
|
||||||
default: 'all',
|
|
||||||
},
|
|
||||||
|
|
||||||
origin: {
|
|
||||||
validator: $.optional.str.or([
|
|
||||||
'combined',
|
|
||||||
'local',
|
|
||||||
'remote',
|
|
||||||
]),
|
|
||||||
default: 'local',
|
|
||||||
},
|
|
||||||
|
|
||||||
username: {
|
|
||||||
validator: $.optional.str,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
|
|
||||||
hostname: {
|
|
||||||
validator: $.optional.str,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
nullable: false, optional: false,
|
nullable: false, optional: false,
|
||||||
|
@ -74,8 +18,22 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
offset: { type: 'integer', default: 0 },
|
||||||
|
sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt'] },
|
||||||
|
state: { type: 'string', enum: ['all', 'available', 'admin', 'moderator', 'adminOrModerator', 'silenced', 'suspended'], default: "all" },
|
||||||
|
origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "local" },
|
||||||
|
username: { type: 'string', default: null },
|
||||||
|
hostname: { type: 'string', default: null },
|
||||||
|
},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const query = Users.createQueryBuilder('user');
|
const query = Users.createQueryBuilder('user');
|
||||||
|
|
||||||
switch (ps.state) {
|
switch (ps.state) {
|
||||||
|
@ -111,7 +69,7 @@ export default define(meta, async (ps, me) => {
|
||||||
default: query.orderBy('user.id', 'ASC'); break;
|
default: query.orderBy('user.id', 'ASC'); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
query.take(ps.limit!);
|
query.take(ps.limit);
|
||||||
query.skip(ps.offset);
|
query.skip(ps.offset);
|
||||||
|
|
||||||
const users = await query.getMany();
|
const users = await query.getMany();
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { Users } from '@/models/index';
|
import { Users } from '@/models/index';
|
||||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||||
|
@ -9,16 +7,18 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
userId: {
|
type: 'object',
|
||||||
validator: $.type(ID),
|
properties: {
|
||||||
},
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
},
|
},
|
||||||
|
required: ['userId'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const user = await Users.findOne(ps.userId as string);
|
const user = await Users.findOne(ps.userId as string);
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import deleteFollowing from '@/services/following/delete';
|
import deleteFollowing from '@/services/following/delete';
|
||||||
import { Users, Followings, Notifications } from '@/models/index';
|
import { Users, Followings, Notifications } from '@/models/index';
|
||||||
|
@ -13,16 +11,18 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
userId: {
|
type: 'object',
|
||||||
validator: $.type(ID),
|
properties: {
|
||||||
},
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
},
|
},
|
||||||
|
required: ['userId'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const user = await Users.findOne(ps.userId as string);
|
const user = await Users.findOne(ps.userId as string);
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { Users } from '@/models/index';
|
import { Users } from '@/models/index';
|
||||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||||
|
@ -9,16 +7,18 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
userId: {
|
type: 'object',
|
||||||
validator: $.type(ID),
|
properties: {
|
||||||
},
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
},
|
},
|
||||||
|
required: ['userId'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const user = await Users.findOne(ps.userId as string);
|
const user = await Users.findOne(ps.userId as string);
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { Users } from '@/models/index';
|
import { Users } from '@/models/index';
|
||||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||||
|
@ -10,16 +8,18 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
userId: {
|
type: 'object',
|
||||||
validator: $.type(ID),
|
properties: {
|
||||||
},
|
userId: { type: 'string', format: 'misskey:id' },
|
||||||
},
|
},
|
||||||
|
required: ['userId'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const user = await Users.findOne(ps.userId as string);
|
const user = await Users.findOne(ps.userId as string);
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
|
@ -1,310 +1,106 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { getConnection } from 'typeorm';
|
import { getConnection } from 'typeorm';
|
||||||
import { Meta } from '@/models/entities/meta';
|
import { Meta } from '@/models/entities/meta';
|
||||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||||
import { DB_MAX_NOTE_TEXT_LENGTH } from '@/misc/hard-limits';
|
import { DB_MAX_NOTE_TEXT_LENGTH } from '@/misc/hard-limits';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireAdmin: true,
|
requireAdmin: true,
|
||||||
|
} as const;
|
||||||
params: {
|
|
||||||
disableRegistration: {
|
export const paramDef = {
|
||||||
validator: $.optional.nullable.bool,
|
type: 'object',
|
||||||
},
|
properties: {
|
||||||
|
disableRegistration: { type: 'boolean', nullable: true },
|
||||||
disableLocalTimeline: {
|
disableLocalTimeline: { type: 'boolean', nullable: true },
|
||||||
validator: $.optional.nullable.bool,
|
disableGlobalTimeline: { type: 'boolean', nullable: true },
|
||||||
},
|
useStarForReactionFallback: { type: 'boolean', nullable: true },
|
||||||
|
pinnedUsers: { type: 'array', nullable: true, items: {
|
||||||
disableGlobalTimeline: {
|
type: 'string',
|
||||||
validator: $.optional.nullable.bool,
|
} },
|
||||||
},
|
hiddenTags: { type: 'array', nullable: true, items: {
|
||||||
|
type: 'string',
|
||||||
useStarForReactionFallback: {
|
} },
|
||||||
validator: $.optional.nullable.bool,
|
blockedHosts: { type: 'array', nullable: true, items: {
|
||||||
},
|
type: 'string',
|
||||||
|
} },
|
||||||
pinnedUsers: {
|
themeColor: { type: 'string', nullable: true },
|
||||||
validator: $.optional.nullable.arr($.str),
|
mascotImageUrl: { type: 'string', nullable: true },
|
||||||
},
|
bannerUrl: { type: 'string', nullable: true },
|
||||||
|
errorImageUrl: { type: 'string', nullable: true },
|
||||||
hiddenTags: {
|
iconUrl: { type: 'string', nullable: true },
|
||||||
validator: $.optional.nullable.arr($.str),
|
backgroundImageUrl: { type: 'string', nullable: true },
|
||||||
},
|
logoImageUrl: { type: 'string', nullable: true },
|
||||||
|
name: { type: 'string', nullable: true },
|
||||||
blockedHosts: {
|
description: { type: 'string', nullable: true },
|
||||||
validator: $.optional.nullable.arr($.str),
|
localDriveCapacityMb: { type: 'integer' },
|
||||||
},
|
remoteDriveCapacityMb: { type: 'integer' },
|
||||||
|
cacheRemoteFiles: { type: 'boolean' },
|
||||||
themeColor: {
|
proxyRemoteFiles: { type: 'boolean' },
|
||||||
validator: $.optional.nullable.str,
|
emailRequiredForSignup: { type: 'boolean' },
|
||||||
},
|
enableHcaptcha: { type: 'boolean' },
|
||||||
|
hcaptchaSiteKey: { type: 'string', nullable: true },
|
||||||
mascotImageUrl: {
|
hcaptchaSecretKey: { type: 'string', nullable: true },
|
||||||
validator: $.optional.nullable.str,
|
enableRecaptcha: { type: 'boolean' },
|
||||||
},
|
recaptchaSiteKey: { type: 'string', nullable: true },
|
||||||
|
recaptchaSecretKey: { type: 'string', nullable: true },
|
||||||
bannerUrl: {
|
proxyAccountId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||||
validator: $.optional.nullable.str,
|
maintainerName: { type: 'string', nullable: true },
|
||||||
},
|
maintainerEmail: { type: 'string', nullable: true },
|
||||||
|
pinnedPages: { type: 'array', items: {
|
||||||
errorImageUrl: {
|
type: 'string',
|
||||||
validator: $.optional.nullable.str,
|
} },
|
||||||
},
|
pinnedClipId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||||
|
langs: { type: 'array', items: {
|
||||||
iconUrl: {
|
type: 'string',
|
||||||
validator: $.optional.nullable.str,
|
} },
|
||||||
},
|
summalyProxy: { type: 'string', nullable: true },
|
||||||
|
deeplAuthKey: { type: 'string', nullable: true },
|
||||||
backgroundImageUrl: {
|
deeplIsPro: { type: 'boolean' },
|
||||||
validator: $.optional.nullable.str,
|
enableTwitterIntegration: { type: 'boolean' },
|
||||||
},
|
twitterConsumerKey: { type: 'string', nullable: true },
|
||||||
|
twitterConsumerSecret: { type: 'string', nullable: true },
|
||||||
logoImageUrl: {
|
enableGithubIntegration: { type: 'boolean' },
|
||||||
validator: $.optional.nullable.str,
|
githubClientId: { type: 'string', nullable: true },
|
||||||
},
|
githubClientSecret: { type: 'string', nullable: true },
|
||||||
|
enableDiscordIntegration: { type: 'boolean' },
|
||||||
name: {
|
discordClientId: { type: 'string', nullable: true },
|
||||||
validator: $.optional.nullable.str,
|
discordClientSecret: { type: 'string', nullable: true },
|
||||||
},
|
enableEmail: { type: 'boolean' },
|
||||||
|
email: { type: 'string', nullable: true },
|
||||||
description: {
|
smtpSecure: { type: 'boolean' },
|
||||||
validator: $.optional.nullable.str,
|
smtpHost: { type: 'string', nullable: true },
|
||||||
},
|
smtpPort: { type: 'integer', nullable: true },
|
||||||
|
smtpUser: { type: 'string', nullable: true },
|
||||||
maxNoteTextLength: {
|
smtpPass: { type: 'string', nullable: true },
|
||||||
validator: $.optional.num.min(0).max(DB_MAX_NOTE_TEXT_LENGTH),
|
enableServiceWorker: { type: 'boolean' },
|
||||||
},
|
swPublicKey: { type: 'string', nullable: true },
|
||||||
|
swPrivateKey: { type: 'string', nullable: true },
|
||||||
localDriveCapacityMb: {
|
tosUrl: { type: 'string', nullable: true },
|
||||||
validator: $.optional.num.min(0),
|
repositoryUrl: { type: 'string' },
|
||||||
},
|
feedbackUrl: { type: 'string' },
|
||||||
|
useObjectStorage: { type: 'boolean' },
|
||||||
remoteDriveCapacityMb: {
|
objectStorageBaseUrl: { type: 'string', nullable: true },
|
||||||
validator: $.optional.num.min(0),
|
objectStorageBucket: { type: 'string', nullable: true },
|
||||||
},
|
objectStoragePrefix: { type: 'string', nullable: true },
|
||||||
|
objectStorageEndpoint: { type: 'string', nullable: true },
|
||||||
cacheRemoteFiles: {
|
objectStorageRegion: { type: 'string', nullable: true },
|
||||||
validator: $.optional.bool,
|
objectStoragePort: { type: 'integer', nullable: true },
|
||||||
},
|
objectStorageAccessKey: { type: 'string', nullable: true },
|
||||||
|
objectStorageSecretKey: { type: 'string', nullable: true },
|
||||||
proxyRemoteFiles: {
|
objectStorageUseSSL: { type: 'boolean' },
|
||||||
validator: $.optional.bool,
|
objectStorageUseProxy: { type: 'boolean' },
|
||||||
},
|
objectStorageSetPublicRead: { type: 'boolean' },
|
||||||
|
objectStorageS3ForcePathStyle: { type: 'boolean' },
|
||||||
emailRequiredForSignup: {
|
},
|
||||||
validator: $.optional.bool,
|
required: [],
|
||||||
},
|
|
||||||
|
|
||||||
enableHcaptcha: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
hcaptchaSiteKey: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
hcaptchaSecretKey: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
enableRecaptcha: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
recaptchaSiteKey: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
recaptchaSecretKey: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
proxyAccountId: {
|
|
||||||
validator: $.optional.nullable.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
maintainerName: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
maintainerEmail: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
pinnedPages: {
|
|
||||||
validator: $.optional.arr($.str),
|
|
||||||
},
|
|
||||||
|
|
||||||
pinnedClipId: {
|
|
||||||
validator: $.optional.nullable.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
langs: {
|
|
||||||
validator: $.optional.arr($.str),
|
|
||||||
},
|
|
||||||
|
|
||||||
summalyProxy: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
deeplAuthKey: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
deeplIsPro: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
enableTwitterIntegration: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
twitterConsumerKey: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
twitterConsumerSecret: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
enableGithubIntegration: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
githubClientId: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
githubClientSecret: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
enableDiscordIntegration: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
discordClientId: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
discordClientSecret: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
enableEmail: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
email: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
smtpSecure: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
smtpHost: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
smtpPort: {
|
|
||||||
validator: $.optional.nullable.num,
|
|
||||||
},
|
|
||||||
|
|
||||||
smtpUser: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
smtpPass: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
enableServiceWorker: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
swPublicKey: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
swPrivateKey: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
tosUrl: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
repositoryUrl: {
|
|
||||||
validator: $.optional.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
feedbackUrl: {
|
|
||||||
validator: $.optional.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
useObjectStorage: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStorageBaseUrl: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStorageBucket: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStoragePrefix: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStorageEndpoint: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStorageRegion: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStoragePort: {
|
|
||||||
validator: $.optional.nullable.num,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStorageAccessKey: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStorageSecretKey: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStorageUseSSL: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStorageUseProxy: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStorageSetPublicRead: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
objectStorageS3ForcePathStyle: {
|
|
||||||
validator: $.optional.bool,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const set = {} as Partial<Meta>;
|
const set = {} as Partial<Meta>;
|
||||||
|
|
||||||
if (typeof ps.disableRegistration === 'boolean') {
|
if (typeof ps.disableRegistration === 'boolean') {
|
||||||
|
@ -367,10 +163,6 @@ export default define(meta, async (ps, me) => {
|
||||||
set.description = ps.description;
|
set.description = ps.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.maxNoteTextLength) {
|
|
||||||
set.maxNoteTextLength = ps.maxNoteTextLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ps.localDriveCapacityMb !== undefined) {
|
if (ps.localDriveCapacityMb !== undefined) {
|
||||||
set.localDriveCapacityMb = ps.localDriveCapacityMb;
|
set.localDriveCapacityMb = ps.localDriveCapacityMb;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { getConnection } from 'typeorm';
|
import { getConnection } from 'typeorm';
|
||||||
import { insertModerationLog } from '@/services/insert-moderation-log';
|
import { insertModerationLog } from '@/services/insert-moderation-log';
|
||||||
|
@ -8,19 +7,19 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
} as const;
|
||||||
|
|
||||||
params: {
|
export const paramDef = {
|
||||||
full: {
|
type: 'object',
|
||||||
validator: $.bool,
|
properties: {
|
||||||
},
|
full: { type: 'boolean' },
|
||||||
analyze: {
|
analyze: { type: 'boolean' },
|
||||||
validator: $.bool,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
required: ['full', 'analyze'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const params: string[] = [];
|
const params: string[] = [];
|
||||||
|
|
||||||
if (ps.full) {
|
if (ps.full) {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../define';
|
import define from '../define';
|
||||||
import { Announcements, AnnouncementReads } from '@/models/index';
|
import { Announcements, AnnouncementReads } from '@/models/index';
|
||||||
import { makePaginationQuery } from '../common/make-pagination-query';
|
import { makePaginationQuery } from '../common/make-pagination-query';
|
||||||
|
@ -9,26 +7,6 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: false,
|
requireCredential: false,
|
||||||
|
|
||||||
params: {
|
|
||||||
limit: {
|
|
||||||
validator: $.optional.num.range(1, 100),
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
|
|
||||||
withUnreads: {
|
|
||||||
validator: $.optional.boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
sinceId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
untilId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -73,11 +51,22 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
withUnreads: { type: 'boolean', default: false },
|
||||||
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
const query = makePaginationQuery(Announcements.createQueryBuilder('announcement'), ps.sinceId, ps.untilId);
|
const query = makePaginationQuery(Announcements.createQueryBuilder('announcement'), ps.sinceId, ps.untilId);
|
||||||
|
|
||||||
const announcements = await query.take(ps.limit!).getMany();
|
const announcements = await query.take(ps.limit).getMany();
|
||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
const reads = (await AnnouncementReads.find({
|
const reads = (await AnnouncementReads.find({
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { genId } from '@/misc/gen-id';
|
import { genId } from '@/misc/gen-id';
|
||||||
import { Antennas, UserLists, UserGroupJoinings } from '@/models/index';
|
import { Antennas, UserLists, UserGroupJoinings } from '@/models/index';
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
import { publishInternalEvent } from '@/services/stream';
|
import { publishInternalEvent } from '@/services/stream';
|
||||||
|
|
||||||
|
@ -13,52 +11,6 @@ export const meta = {
|
||||||
|
|
||||||
kind: 'write:account',
|
kind: 'write:account',
|
||||||
|
|
||||||
params: {
|
|
||||||
name: {
|
|
||||||
validator: $.str.range(1, 100),
|
|
||||||
},
|
|
||||||
|
|
||||||
src: {
|
|
||||||
validator: $.str.or(['home', 'all', 'users', 'list', 'group']),
|
|
||||||
},
|
|
||||||
|
|
||||||
userListId: {
|
|
||||||
validator: $.nullable.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
userGroupId: {
|
|
||||||
validator: $.nullable.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
keywords: {
|
|
||||||
validator: $.arr($.arr($.str)),
|
|
||||||
},
|
|
||||||
|
|
||||||
excludeKeywords: {
|
|
||||||
validator: $.arr($.arr($.str)),
|
|
||||||
},
|
|
||||||
|
|
||||||
users: {
|
|
||||||
validator: $.arr($.str),
|
|
||||||
},
|
|
||||||
|
|
||||||
caseSensitive: {
|
|
||||||
validator: $.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
withReplies: {
|
|
||||||
validator: $.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
withFile: {
|
|
||||||
validator: $.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
notify: {
|
|
||||||
validator: $.bool,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchUserList: {
|
noSuchUserList: {
|
||||||
message: 'No such user list.',
|
message: 'No such user list.',
|
||||||
|
@ -80,8 +32,36 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
name: { type: 'string', minLength: 1, maxLength: 100 },
|
||||||
|
src: { type: 'string', enum: ['home', 'all', 'users', 'list', 'group'] },
|
||||||
|
userListId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||||
|
userGroupId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||||
|
keywords: { type: 'array', items: {
|
||||||
|
type: 'array', items: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
} },
|
||||||
|
excludeKeywords: { type: 'array', items: {
|
||||||
|
type: 'array', items: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
} },
|
||||||
|
users: { type: 'array', items: {
|
||||||
|
type: 'string',
|
||||||
|
} },
|
||||||
|
caseSensitive: { type: 'boolean' },
|
||||||
|
withReplies: { type: 'boolean' },
|
||||||
|
withFile: { type: 'boolean' },
|
||||||
|
notify: { type: 'boolean' },
|
||||||
|
},
|
||||||
|
required: ['name', 'src', 'keywords', 'excludeKeywords', 'users', 'caseSensitive', 'withReplies', 'withFile', 'notify'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
let userList;
|
let userList;
|
||||||
let userGroupJoining;
|
let userGroupJoining;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
import { Antennas } from '@/models/index';
|
import { Antennas } from '@/models/index';
|
||||||
|
@ -12,12 +10,6 @@ export const meta = {
|
||||||
|
|
||||||
kind: 'write:account',
|
kind: 'write:account',
|
||||||
|
|
||||||
params: {
|
|
||||||
antennaId: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchAntenna: {
|
noSuchAntenna: {
|
||||||
message: 'No such antenna.',
|
message: 'No such antenna.',
|
||||||
|
@ -27,8 +19,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
antennaId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['antennaId'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
const antenna = await Antennas.findOne({
|
const antenna = await Antennas.findOne({
|
||||||
id: ps.antennaId,
|
id: ps.antennaId,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
|
|
@ -19,8 +19,14 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
required: [],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
const antennas = await Antennas.find({
|
const antennas = await Antennas.find({
|
||||||
userId: me.id,
|
userId: me.id,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import readNote from '@/services/note/read';
|
import readNote from '@/services/note/read';
|
||||||
import { Antennas, Notes, AntennaNotes } from '@/models/index';
|
import { Antennas, Notes, AntennaNotes } from '@/models/index';
|
||||||
|
@ -16,33 +14,6 @@ export const meta = {
|
||||||
|
|
||||||
kind: 'read:account',
|
kind: 'read:account',
|
||||||
|
|
||||||
params: {
|
|
||||||
antennaId: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
limit: {
|
|
||||||
validator: $.optional.num.range(1, 100),
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
|
|
||||||
sinceId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
untilId: {
|
|
||||||
validator: $.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
sinceDate: {
|
|
||||||
validator: $.optional.num,
|
|
||||||
},
|
|
||||||
|
|
||||||
untilDate: {
|
|
||||||
validator: $.optional.num,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchAntenna: {
|
noSuchAntenna: {
|
||||||
message: 'No such antenna.',
|
message: 'No such antenna.',
|
||||||
|
@ -62,8 +33,21 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
antennaId: { type: 'string', format: 'misskey:id' },
|
||||||
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
|
sinceDate: { type: 'integer' },
|
||||||
|
untilDate: { type: 'integer' },
|
||||||
|
},
|
||||||
|
required: ['antennaId'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
const antenna = await Antennas.findOne({
|
const antenna = await Antennas.findOne({
|
||||||
id: ps.antennaId,
|
id: ps.antennaId,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
@ -92,7 +76,7 @@ export default define(meta, async (ps, user) => {
|
||||||
generateBlockedUserQuery(query, user);
|
generateBlockedUserQuery(query, user);
|
||||||
|
|
||||||
const notes = await query
|
const notes = await query
|
||||||
.take(ps.limit!)
|
.take(ps.limit)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
if (notes.length > 0) {
|
if (notes.length > 0) {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
import { Antennas } from '@/models/index';
|
import { Antennas } from '@/models/index';
|
||||||
|
@ -11,12 +9,6 @@ export const meta = {
|
||||||
|
|
||||||
kind: 'read:account',
|
kind: 'read:account',
|
||||||
|
|
||||||
params: {
|
|
||||||
antennaId: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchAntenna: {
|
noSuchAntenna: {
|
||||||
message: 'No such antenna.',
|
message: 'No such antenna.',
|
||||||
|
@ -32,8 +24,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
antennaId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['antennaId'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, paramDef, async (ps, me) => {
|
||||||
// Fetch the antenna
|
// Fetch the antenna
|
||||||
const antenna = await Antennas.findOne({
|
const antenna = await Antennas.findOne({
|
||||||
id: ps.antennaId,
|
id: ps.antennaId,
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
import { Antennas, UserLists, UserGroupJoinings } from '@/models/index';
|
import { Antennas, UserLists, UserGroupJoinings } from '@/models/index';
|
||||||
|
@ -12,56 +10,6 @@ export const meta = {
|
||||||
|
|
||||||
kind: 'write:account',
|
kind: 'write:account',
|
||||||
|
|
||||||
params: {
|
|
||||||
antennaId: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
name: {
|
|
||||||
validator: $.str.range(1, 100),
|
|
||||||
},
|
|
||||||
|
|
||||||
src: {
|
|
||||||
validator: $.str.or(['home', 'all', 'users', 'list', 'group']),
|
|
||||||
},
|
|
||||||
|
|
||||||
userListId: {
|
|
||||||
validator: $.nullable.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
userGroupId: {
|
|
||||||
validator: $.nullable.optional.type(ID),
|
|
||||||
},
|
|
||||||
|
|
||||||
keywords: {
|
|
||||||
validator: $.arr($.arr($.str)),
|
|
||||||
},
|
|
||||||
|
|
||||||
excludeKeywords: {
|
|
||||||
validator: $.arr($.arr($.str)),
|
|
||||||
},
|
|
||||||
|
|
||||||
users: {
|
|
||||||
validator: $.arr($.str),
|
|
||||||
},
|
|
||||||
|
|
||||||
caseSensitive: {
|
|
||||||
validator: $.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
withReplies: {
|
|
||||||
validator: $.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
withFile: {
|
|
||||||
validator: $.bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
notify: {
|
|
||||||
validator: $.bool,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchAntenna: {
|
noSuchAntenna: {
|
||||||
message: 'No such antenna.',
|
message: 'No such antenna.',
|
||||||
|
@ -89,8 +37,37 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
antennaId: { type: 'string', format: 'misskey:id' },
|
||||||
|
name: { type: 'string', minLength: 1, maxLength: 100 },
|
||||||
|
src: { type: 'string', enum: ['home', 'all', 'users', 'list', 'group'] },
|
||||||
|
userListId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||||
|
userGroupId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||||
|
keywords: { type: 'array', items: {
|
||||||
|
type: 'array', items: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
} },
|
||||||
|
excludeKeywords: { type: 'array', items: {
|
||||||
|
type: 'array', items: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
} },
|
||||||
|
users: { type: 'array', items: {
|
||||||
|
type: 'string',
|
||||||
|
} },
|
||||||
|
caseSensitive: { type: 'boolean' },
|
||||||
|
withReplies: { type: 'boolean' },
|
||||||
|
withFile: { type: 'boolean' },
|
||||||
|
notify: { type: 'boolean' },
|
||||||
|
},
|
||||||
|
required: ['antennaId', 'name', 'src', 'keywords', 'excludeKeywords', 'users', 'caseSensitive', 'withReplies', 'withFile', 'notify'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
// Fetch the antenna
|
// Fetch the antenna
|
||||||
const antenna = await Antennas.findOne({
|
const antenna = await Antennas.findOne({
|
||||||
id: ps.antennaId,
|
id: ps.antennaId,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import Resolver from '@/remote/activitypub/resolver';
|
import Resolver from '@/remote/activitypub/resolver';
|
||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
|
@ -14,12 +13,6 @@ export const meta = {
|
||||||
max: 30,
|
max: 30,
|
||||||
},
|
},
|
||||||
|
|
||||||
params: {
|
|
||||||
uri: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -29,8 +22,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
uri: { type: 'string' },
|
||||||
|
},
|
||||||
|
required: ['uri'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const resolver = new Resolver();
|
const resolver = new Resolver();
|
||||||
const object = await resolver.resolve(ps.uri);
|
const object = await resolver.resolve(ps.uri);
|
||||||
return object;
|
return object;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import config from '@/config/index';
|
import config from '@/config/index';
|
||||||
import { createPerson } from '@/remote/activitypub/models/person';
|
import { createPerson } from '@/remote/activitypub/models/person';
|
||||||
|
@ -24,12 +23,6 @@ export const meta = {
|
||||||
max: 30,
|
max: 30,
|
||||||
},
|
},
|
||||||
|
|
||||||
params: {
|
|
||||||
uri: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchObject: {
|
noSuchObject: {
|
||||||
message: 'No such object.',
|
message: 'No such object.',
|
||||||
|
@ -75,8 +68,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
uri: { type: 'string' },
|
||||||
|
},
|
||||||
|
required: ['uri'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, paramDef, async (ps) => {
|
||||||
const object = await fetchAny(ps.uri);
|
const object = await fetchAny(ps.uri);
|
||||||
if (object) {
|
if (object) {
|
||||||
return object;
|
return object;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { Apps } from '@/models/index';
|
import { Apps } from '@/models/index';
|
||||||
import { genId } from '@/misc/gen-id';
|
import { genId } from '@/misc/gen-id';
|
||||||
|
@ -10,26 +9,6 @@ export const meta = {
|
||||||
|
|
||||||
requireCredential: false,
|
requireCredential: false,
|
||||||
|
|
||||||
params: {
|
|
||||||
name: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
description: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
|
|
||||||
permission: {
|
|
||||||
validator: $.arr($.str).unique(),
|
|
||||||
},
|
|
||||||
|
|
||||||
// TODO: Check it is valid url
|
|
||||||
callbackUrl: {
|
|
||||||
validator: $.optional.nullable.str,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -37,8 +16,21 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
name: { type: 'string' },
|
||||||
|
description: { type: 'string' },
|
||||||
|
permission: { type: 'array', uniqueItems: true, items: {
|
||||||
|
type: 'string',
|
||||||
|
} },
|
||||||
|
callbackUrl: { type: 'string', nullable: true },
|
||||||
|
},
|
||||||
|
required: ['name', 'description', 'permission'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
// Generate secret
|
// Generate secret
|
||||||
const secret = secureRndstr(32, true);
|
const secret = secureRndstr(32, true);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import $ from 'cafy';
|
|
||||||
import { ID } from '@/misc/cafy-id';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
import { Apps } from '@/models/index';
|
import { Apps } from '@/models/index';
|
||||||
|
@ -7,12 +5,6 @@ import { Apps } from '@/models/index';
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['app'],
|
tags: ['app'],
|
||||||
|
|
||||||
params: {
|
|
||||||
appId: {
|
|
||||||
validator: $.type(ID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchApp: {
|
noSuchApp: {
|
||||||
message: 'No such app.',
|
message: 'No such app.',
|
||||||
|
@ -28,8 +20,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
appId: { type: 'string', format: 'misskey:id' },
|
||||||
|
},
|
||||||
|
required: ['appId'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user, token) => {
|
export default define(meta, paramDef, async (ps, user, token) => {
|
||||||
const isSecure = user != null && token == null;
|
const isSecure = user != null && token == null;
|
||||||
|
|
||||||
// Lookup app
|
// Lookup app
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
import $ from 'cafy';
|
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
import { AuthSessions, AccessTokens, Apps } from '@/models/index';
|
import { AuthSessions, AccessTokens, Apps } from '@/models/index';
|
||||||
|
@ -13,12 +12,6 @@ export const meta = {
|
||||||
|
|
||||||
secure: true,
|
secure: true,
|
||||||
|
|
||||||
params: {
|
|
||||||
token: {
|
|
||||||
validator: $.str,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchSession: {
|
noSuchSession: {
|
||||||
message: 'No such session.',
|
message: 'No such session.',
|
||||||
|
@ -28,8 +21,16 @@ export const meta = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const paramDef = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
token: { type: 'string' },
|
||||||
|
},
|
||||||
|
required: ['token'],
|
||||||
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
// Fetch token
|
// Fetch token
|
||||||
const session = await AuthSessions
|
const session = await AuthSessions
|
||||||
.findOne({ token: ps.token });
|
.findOne({ token: ps.token });
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue