refactor: use ajv instead of cafy (#8324)
* wip * wip * Update abuse-user-reports.ts * Update files.ts * Update list-remote.ts * Update list.ts * Update show-users.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update update.ts * Update search.ts * Update reactions.ts * Update search.ts * wip * wip * wip * wip * Update update.ts * Update relation.ts * Update available.ts * wip * wip * wip * Update packages/backend/src/server/api/define.ts Co-authored-by: Johann150 <johann.galle@protonmail.com> * Update define.ts * Update define.ts * typo * wip * wip * wip * wip * wip * wip * wip * wip * Update update.ts * wip * Update signup.ts * Update call.ts * minimum for limit * type * remove needless annotation * wip * Update signup.ts * wip * wip * fix * Update create.ts Co-authored-by: Johann150 <johann.galle@protonmail.com>
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
|
||||
@ -14,25 +12,6 @@ export const meta = {
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -44,8 +23,19 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { 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' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||
.andWhere(new Brackets(qb => { qb
|
||||
.where(`note.replyId = :noteId`, { noteId: ps.noteId })
|
||||
@ -69,7 +59,7 @@ export default define(meta, async (ps, user) => {
|
||||
if (user) generateBlockedUserQuery(query, user);
|
||||
if (user) generateMutedInstanceQuery(query, user);
|
||||
|
||||
const notes = await query.take(ps.limit!).getMany();
|
||||
const notes = await query.take(ps.limit).getMany();
|
||||
|
||||
return await Notes.packMany(notes, user);
|
||||
});
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { ClipNotes, Clips } from '@/models/index';
|
||||
import { getNote } from '../../common/getters';
|
||||
@ -11,12 +9,6 @@ export const meta = {
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -36,8 +28,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const note = await getNote(ps.noteId).catch(e => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { ApiError } from '../../error';
|
||||
import { getNote } from '../../common/getters';
|
||||
@ -11,22 +9,6 @@ export const meta = {
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
offset: {
|
||||
validator: $.optional.num.min(0),
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -46,8 +28,18 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
offset: { type: 'integer', default: 0 },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
@ -65,7 +57,7 @@ export default define(meta, async (ps, user) => {
|
||||
conversation.push(p);
|
||||
}
|
||||
|
||||
if (conversation.length == ps.limit!) {
|
||||
if (conversation.length == ps.limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
import $ from 'cafy';
|
||||
import ms from 'ms';
|
||||
import { length } from 'stringz';
|
||||
import create from '@/services/note/create';
|
||||
import define from '../../define';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { ApiError } from '../../error';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { Users, DriveFiles, Notes, Channels, Blockings } from '@/models/index';
|
||||
import { DriveFile } from '@/models/entities/drive-file';
|
||||
@ -34,84 +32,6 @@ export const meta = {
|
||||
|
||||
kind: 'write:notes',
|
||||
|
||||
params: {
|
||||
visibility: {
|
||||
validator: $.optional.str.or(noteVisibilities as unknown as string[]),
|
||||
default: 'public',
|
||||
},
|
||||
|
||||
visibleUserIds: {
|
||||
validator: $.optional.arr($.type(ID)).unique().min(0),
|
||||
},
|
||||
|
||||
text: {
|
||||
validator: $.optional.nullable.str.pipe(text =>
|
||||
text.trim() != ''
|
||||
&& length(text.trim()) <= maxNoteTextLength
|
||||
&& Array.from(text.trim()).length <= DB_MAX_NOTE_TEXT_LENGTH, // DB limit
|
||||
),
|
||||
default: null,
|
||||
},
|
||||
|
||||
cw: {
|
||||
validator: $.optional.nullable.str.pipe(Notes.validateCw),
|
||||
},
|
||||
|
||||
localOnly: {
|
||||
validator: $.optional.bool,
|
||||
default: false,
|
||||
},
|
||||
|
||||
noExtractMentions: {
|
||||
validator: $.optional.bool,
|
||||
default: false,
|
||||
},
|
||||
|
||||
noExtractHashtags: {
|
||||
validator: $.optional.bool,
|
||||
default: false,
|
||||
},
|
||||
|
||||
noExtractEmojis: {
|
||||
validator: $.optional.bool,
|
||||
default: false,
|
||||
},
|
||||
|
||||
fileIds: {
|
||||
validator: $.optional.arr($.type(ID)).unique().range(1, 16),
|
||||
},
|
||||
|
||||
mediaIds: {
|
||||
validator: $.optional.arr($.type(ID)).unique().range(1, 16),
|
||||
deprecated: true,
|
||||
},
|
||||
|
||||
replyId: {
|
||||
validator: $.optional.nullable.type(ID),
|
||||
},
|
||||
|
||||
renoteId: {
|
||||
validator: $.optional.nullable.type(ID),
|
||||
},
|
||||
|
||||
channelId: {
|
||||
validator: $.optional.nullable.type(ID),
|
||||
},
|
||||
|
||||
poll: {
|
||||
validator: $.optional.nullable.obj({
|
||||
choices: $.arr($.str)
|
||||
.unique()
|
||||
.range(2, 10)
|
||||
.each(c => c.length > 0 && c.length < 50),
|
||||
multiple: $.optional.bool,
|
||||
expiresAt: $.optional.nullable.num.int(),
|
||||
expiredAfter: $.optional.nullable.num.int().min(1),
|
||||
}).strict(),
|
||||
ref: 'poll',
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
@ -175,8 +95,49 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
visibility: { type: 'string', enum: ['public', 'home', 'followers', 'specified'], default: "public" },
|
||||
visibleUserIds: { type: 'array', uniqueItems: true, items: {
|
||||
type: 'string', format: 'misskey:id',
|
||||
} },
|
||||
text: { type: 'string', nullable: true, maxLength: 3000, default: null },
|
||||
cw: { type: 'string', nullable: true, maxLength: 100 },
|
||||
localOnly: { type: 'boolean', default: false },
|
||||
noExtractMentions: { type: 'boolean', default: false },
|
||||
noExtractHashtags: { type: 'boolean', default: false },
|
||||
noExtractEmojis: { type: 'boolean', default: false },
|
||||
fileIds: { type: 'array', uniqueItems: true, minItems: 1, maxItems: 16, items: {
|
||||
type: 'string', format: 'misskey:id',
|
||||
} },
|
||||
mediaIds: { type: 'array', uniqueItems: true, minItems: 1, maxItems: 16, items: {
|
||||
type: 'string', format: 'misskey:id',
|
||||
} },
|
||||
replyId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||
renoteId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||
channelId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||
poll: {
|
||||
type: 'object', nullable: true,
|
||||
properties: {
|
||||
choices: {
|
||||
type: 'array', uniqueItems: true, minItems: 2, maxItems: 10,
|
||||
items: {
|
||||
type: 'string', minLength: 1, maxLength: 50,
|
||||
},
|
||||
},
|
||||
multiple: { type: 'boolean', default: false },
|
||||
expiresAt: { type: 'integer', nullable: true },
|
||||
expiredAfter: { type: 'integer', nullable: true, minimum: 1 },
|
||||
},
|
||||
required: ['choices'],
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
let visibleUsers: User[] = [];
|
||||
if (ps.visibleUserIds) {
|
||||
visibleUsers = (await Promise.all(ps.visibleUserIds.map(id => Users.findOne(id))))
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import deleteNote from '@/services/note/delete';
|
||||
import define from '../../define';
|
||||
import ms from 'ms';
|
||||
@ -20,12 +18,6 @@ export const meta = {
|
||||
minInterval: ms('1sec'),
|
||||
},
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
@ -41,8 +33,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import { ApiError } from '../../../error';
|
||||
import { getNote } from '../../../common/getters';
|
||||
@ -13,12 +11,6 @@ export const meta = {
|
||||
|
||||
kind: 'write:favorites',
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
@ -34,8 +26,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
// Get favoritee
|
||||
const note = await getNote(ps.noteId).catch(e => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import { ApiError } from '../../../error';
|
||||
import { getNote } from '../../../common/getters';
|
||||
@ -12,12 +10,6 @@ export const meta = {
|
||||
|
||||
kind: 'write:favorites',
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
@ -33,8 +25,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
// Get favoritee
|
||||
const note = await getNote(ps.noteId).catch(e => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
|
@ -1,4 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import define from '../../define';
|
||||
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
|
||||
import { Notes } from '@/models/index';
|
||||
@ -9,18 +8,6 @@ export const meta = {
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
offset: {
|
||||
validator: $.optional.num.min(0),
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -32,8 +19,17 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
offset: { type: 'integer', default: 0 },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const max = 30;
|
||||
const day = 1000 * 60 * 60 * 24 * 3; // 3日前まで
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { ApiError } from '../../error';
|
||||
@ -15,33 +13,6 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query';
|
||||
export const meta = {
|
||||
tags: ['notes'],
|
||||
|
||||
params: {
|
||||
withFiles: {
|
||||
validator: $.optional.bool,
|
||||
},
|
||||
|
||||
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,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -61,8 +32,21 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
withFiles: { type: 'boolean' },
|
||||
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: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const m = await fetchMeta();
|
||||
if (m.disableGlobalTimeline) {
|
||||
if (user == null || (!user.isAdmin && !user.isModerator)) {
|
||||
@ -92,7 +76,7 @@ export default define(meta, async (ps, user) => {
|
||||
}
|
||||
//#endregion
|
||||
|
||||
const timeline = await query.take(ps.limit!).getMany();
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
|
||||
process.nextTick(() => {
|
||||
if (user) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { ApiError } from '../../error';
|
||||
@ -20,48 +18,6 @@ export const meta = {
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
params: {
|
||||
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,
|
||||
},
|
||||
|
||||
includeMyRenotes: {
|
||||
validator: $.optional.bool,
|
||||
default: true,
|
||||
},
|
||||
|
||||
includeRenotedMyNotes: {
|
||||
validator: $.optional.bool,
|
||||
default: true,
|
||||
},
|
||||
|
||||
includeLocalRenotes: {
|
||||
validator: $.optional.bool,
|
||||
default: true,
|
||||
},
|
||||
|
||||
withFiles: {
|
||||
validator: $.optional.bool,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -81,8 +37,24 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
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' },
|
||||
sinceDate: { type: 'integer' },
|
||||
untilDate: { type: 'integer' },
|
||||
includeMyRenotes: { type: 'boolean', default: true },
|
||||
includeRenotedMyNotes: { type: 'boolean', default: true },
|
||||
includeLocalRenotes: { type: 'boolean', default: true },
|
||||
withFiles: { type: 'boolean' },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const m = await fetchMeta();
|
||||
if (m.disableLocalTimeline && !user.isAdmin && !user.isModerator) {
|
||||
throw new ApiError(meta.errors.stlDisabled);
|
||||
@ -149,7 +121,7 @@ export default define(meta, async (ps, user) => {
|
||||
}
|
||||
//#endregion
|
||||
|
||||
const timeline = await query.take(ps.limit!).getMany();
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
|
||||
process.nextTick(() => {
|
||||
if (user) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { ApiError } from '../../error';
|
||||
@ -17,42 +15,6 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query';
|
||||
export const meta = {
|
||||
tags: ['notes'],
|
||||
|
||||
params: {
|
||||
withFiles: {
|
||||
validator: $.optional.bool,
|
||||
},
|
||||
|
||||
fileType: {
|
||||
validator: $.optional.arr($.str),
|
||||
},
|
||||
|
||||
excludeNsfw: {
|
||||
validator: $.optional.bool,
|
||||
default: false,
|
||||
},
|
||||
|
||||
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,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -72,8 +34,25 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
withFiles: { type: 'boolean' },
|
||||
fileType: { type: 'array', items: {
|
||||
type: 'string',
|
||||
} },
|
||||
excludeNsfw: { type: 'boolean', default: false },
|
||||
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: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const m = await fetchMeta();
|
||||
if (m.disableLocalTimeline) {
|
||||
if (user == null || (!user.isAdmin && !user.isModerator)) {
|
||||
@ -118,7 +97,7 @@ export default define(meta, async (ps, user) => {
|
||||
}
|
||||
//#endregion
|
||||
|
||||
const timeline = await query.take(ps.limit!).getMany();
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
|
||||
process.nextTick(() => {
|
||||
if (user) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import read from '@/services/note/read';
|
||||
import { Notes, Followings } from '@/models/index';
|
||||
@ -15,30 +13,6 @@ export const meta = {
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
params: {
|
||||
following: {
|
||||
validator: $.optional.bool,
|
||||
default: false,
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
visibility: {
|
||||
validator: $.optional.str,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -50,8 +24,20 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
following: { type: 'boolean', default: false },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
visibility: { type: 'string' },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const followingQuery = Followings.createQueryBuilder('following')
|
||||
.select('following.followeeId')
|
||||
.where('following.followerId = :followerId', { followerId: user.id });
|
||||
@ -81,7 +67,7 @@ export default define(meta, async (ps, user) => {
|
||||
query.setParameters(followingQuery.getParameters());
|
||||
}
|
||||
|
||||
const mentions = await query.take(ps.limit!).getMany();
|
||||
const mentions = await query.take(ps.limit).getMany();
|
||||
|
||||
read(user.id, mentions);
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import define from '../../../define';
|
||||
import { Polls, Mutings, Notes, PollVotes } from '@/models/index';
|
||||
import { Brackets, In } from 'typeorm';
|
||||
@ -8,18 +7,6 @@ export const meta = {
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
params: {
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
offset: {
|
||||
validator: $.optional.num.min(0),
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -31,8 +18,17 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
offset: { type: 'integer', default: 0 },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// 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 = Polls.createQueryBuilder('poll')
|
||||
.where('poll.userHost IS NULL')
|
||||
.andWhere(`poll.userId != :meId`, { meId: user.id })
|
||||
@ -64,7 +60,7 @@ export default define(meta, async (ps, user) => {
|
||||
query.setParameters(mutingQuery.getParameters());
|
||||
//#endregion
|
||||
|
||||
const polls = await query.take(ps.limit!).skip(ps.offset).getMany();
|
||||
const polls = await query.take(ps.limit).skip(ps.offset).getMany();
|
||||
|
||||
if (polls.length === 0) return [];
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import { publishNoteStream } from '@/services/stream';
|
||||
import { createNotification } from '@/services/create-notification';
|
||||
import define from '../../../define';
|
||||
@ -21,16 +19,6 @@ export const meta = {
|
||||
|
||||
kind: 'write:votes',
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
|
||||
choice: {
|
||||
validator: $.num,
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
@ -70,8 +58,17 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
choice: { type: 'integer' },
|
||||
},
|
||||
required: ['noteId', 'choice'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const createdAt = new Date();
|
||||
|
||||
// Get votee
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { getNote } from '../../common/getters';
|
||||
import { ApiError } from '../../error';
|
||||
@ -12,34 +10,6 @@ export const meta = {
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
|
||||
type: {
|
||||
validator: $.optional.nullable.str,
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
offset: {
|
||||
validator: $.optional.num,
|
||||
default: 0,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -59,8 +29,21 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
type: { type: 'string', nullable: true },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
offset: { type: 'integer', default: 0 },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
@ -80,7 +63,7 @@ export default define(meta, async (ps, user) => {
|
||||
|
||||
const reactions = await NoteReactions.find({
|
||||
where: query,
|
||||
take: ps.limit!,
|
||||
take: ps.limit,
|
||||
skip: ps.offset,
|
||||
order: {
|
||||
id: -1,
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import createReaction from '@/services/note/reaction/create';
|
||||
import define from '../../../define';
|
||||
import { getNote } from '../../../common/getters';
|
||||
@ -12,16 +10,6 @@ export const meta = {
|
||||
|
||||
kind: 'write:reactions',
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
|
||||
reaction: {
|
||||
validator: $.str,
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
@ -43,8 +31,17 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
reaction: { type: 'string' },
|
||||
},
|
||||
required: ['noteId', 'reaction'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import ms from 'ms';
|
||||
import deleteReaction from '@/services/note/reaction/delete';
|
||||
@ -19,12 +17,6 @@ export const meta = {
|
||||
minInterval: ms('3sec'),
|
||||
},
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
@ -40,8 +32,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { getNote } from '../../common/getters';
|
||||
import { ApiError } from '../../error';
|
||||
@ -14,25 +12,6 @@ export const meta = {
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -52,8 +31,19 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { 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' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
@ -71,7 +61,7 @@ export default define(meta, async (ps, user) => {
|
||||
if (user) generateMutedUserQuery(query, user);
|
||||
if (user) generateBlockedUserQuery(query, user);
|
||||
|
||||
const renotes = await query.take(ps.limit!).getMany();
|
||||
const renotes = await query.take(ps.limit).getMany();
|
||||
|
||||
return await Notes.packMany(renotes, user);
|
||||
});
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { Notes } from '@/models/index';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query';
|
||||
@ -12,25 +10,6 @@ export const meta = {
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -42,8 +21,19 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||
.andWhere('note.replyId = :replyId', { replyId: ps.noteId })
|
||||
.innerJoinAndSelect('note.user', 'user')
|
||||
@ -56,7 +46,7 @@ export default define(meta, async (ps, user) => {
|
||||
if (user) generateMutedUserQuery(query, user);
|
||||
if (user) generateBlockedUserQuery(query, user);
|
||||
|
||||
const timeline = await query.take(ps.limit!).getMany();
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
|
||||
return await Notes.packMany(timeline, user);
|
||||
});
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query';
|
||||
import { Notes } from '@/models/index';
|
||||
@ -13,48 +11,6 @@ import { generateBlockedUserQuery } from '../../common/generate-block-query';
|
||||
export const meta = {
|
||||
tags: ['notes', 'hashtags'],
|
||||
|
||||
params: {
|
||||
tag: {
|
||||
validator: $.optional.str,
|
||||
},
|
||||
|
||||
query: {
|
||||
validator: $.optional.arr($.arr($.str)),
|
||||
},
|
||||
|
||||
reply: {
|
||||
validator: $.optional.nullable.bool,
|
||||
default: null,
|
||||
},
|
||||
|
||||
renote: {
|
||||
validator: $.optional.nullable.bool,
|
||||
default: null,
|
||||
},
|
||||
|
||||
withFiles: {
|
||||
validator: $.optional.bool,
|
||||
},
|
||||
|
||||
poll: {
|
||||
validator: $.optional.nullable.bool,
|
||||
default: null,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -66,8 +22,28 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
tag: { type: 'string' },
|
||||
query: { type: 'array', items: {
|
||||
type: 'array', items: {
|
||||
type: 'string',
|
||||
},
|
||||
} },
|
||||
reply: { type: 'boolean', nullable: true, default: null },
|
||||
renote: { type: 'boolean', nullable: true, default: null },
|
||||
withFiles: { type: 'boolean' },
|
||||
poll: { type: 'boolean', nullable: true, default: null },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// 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(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||
.innerJoinAndSelect('note.user', 'user')
|
||||
.leftJoinAndSelect('note.reply', 'reply')
|
||||
@ -129,7 +105,7 @@ export default define(meta, async (ps, me) => {
|
||||
}
|
||||
|
||||
// Search notes
|
||||
const notes = await query.take(ps.limit!).getMany();
|
||||
const notes = await query.take(ps.limit).getMany();
|
||||
|
||||
return await Notes.packMany(notes, me);
|
||||
});
|
||||
|
@ -1,9 +1,7 @@
|
||||
import $ from 'cafy';
|
||||
import es from '../../../../db/elasticsearch';
|
||||
import define from '../../define';
|
||||
import { Notes } from '@/models/index';
|
||||
import { In } from 'typeorm';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import config from '@/config/index';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query';
|
||||
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
|
||||
@ -15,40 +13,6 @@ export const meta = {
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
query: {
|
||||
validator: $.str,
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.optional.type(ID),
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.optional.num.range(1, 100),
|
||||
default: 10,
|
||||
},
|
||||
|
||||
host: {
|
||||
validator: $.optional.nullable.str,
|
||||
default: undefined,
|
||||
},
|
||||
|
||||
userId: {
|
||||
validator: $.optional.nullable.type(ID),
|
||||
default: null,
|
||||
},
|
||||
|
||||
channelId: {
|
||||
validator: $.optional.nullable.type(ID),
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -63,8 +27,23 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
query: { type: 'string' },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||
offset: { type: 'integer', default: 0 },
|
||||
host: { type: 'string', nullable: true },
|
||||
userId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
||||
channelId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
||||
},
|
||||
required: ['query'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, me) => {
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
if (es == null) {
|
||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId);
|
||||
|
||||
@ -86,7 +65,7 @@ export default define(meta, async (ps, me) => {
|
||||
if (me) generateMutedUserQuery(query, me);
|
||||
if (me) generateBlockedUserQuery(query, me);
|
||||
|
||||
const notes = await query.take(ps.limit!).getMany();
|
||||
const notes = await query.take(ps.limit).getMany();
|
||||
|
||||
return await Notes.packMany(notes, me);
|
||||
} else {
|
||||
@ -115,7 +94,7 @@ export default define(meta, async (ps, me) => {
|
||||
const result = await es.search({
|
||||
index: config.elasticsearch.index || 'misskey_note',
|
||||
body: {
|
||||
size: ps.limit!,
|
||||
size: ps.limit,
|
||||
from: ps.offset,
|
||||
query: {
|
||||
bool: {
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { getNote } from '../../common/getters';
|
||||
import { ApiError } from '../../error';
|
||||
@ -10,12 +8,6 @@ export const meta = {
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
@ -31,8 +23,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { NoteFavorites, Notes, NoteThreadMutings, NoteWatchings } from '@/models/index';
|
||||
|
||||
@ -8,12 +6,6 @@ export const meta = {
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
@ -34,8 +26,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 Notes.findOneOrFail(ps.noteId);
|
||||
|
||||
const [favorite, watching, threadMuting] = await Promise.all([
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import { getNote } from '../../../common/getters';
|
||||
import { ApiError } from '../../../error';
|
||||
@ -14,12 +12,6 @@ export const meta = {
|
||||
|
||||
kind: 'write:account',
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
@ -29,8 +21,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import { getNote } from '../../../common/getters';
|
||||
import { ApiError } from '../../../error';
|
||||
@ -12,12 +10,6 @@ export const meta = {
|
||||
|
||||
kind: 'write:account',
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
@ -27,8 +19,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { makePaginationQuery } from '../../common/make-pagination-query';
|
||||
import { Notes, Followings } from '@/models/index';
|
||||
@ -18,48 +16,6 @@ export const meta = {
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
params: {
|
||||
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,
|
||||
},
|
||||
|
||||
includeMyRenotes: {
|
||||
validator: $.optional.bool,
|
||||
default: true,
|
||||
},
|
||||
|
||||
includeRenotedMyNotes: {
|
||||
validator: $.optional.bool,
|
||||
default: true,
|
||||
},
|
||||
|
||||
includeLocalRenotes: {
|
||||
validator: $.optional.bool,
|
||||
default: true,
|
||||
},
|
||||
|
||||
withFiles: {
|
||||
validator: $.optional.bool,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -71,8 +27,24 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
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' },
|
||||
sinceDate: { type: 'integer' },
|
||||
untilDate: { type: 'integer' },
|
||||
includeMyRenotes: { type: 'boolean', default: true },
|
||||
includeRenotedMyNotes: { type: 'boolean', default: true },
|
||||
includeLocalRenotes: { type: 'boolean', default: true },
|
||||
withFiles: { type: 'boolean' },
|
||||
},
|
||||
required: [],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const hasFollowing = (await Followings.count({
|
||||
where: {
|
||||
followerId: user.id,
|
||||
@ -141,7 +113,7 @@ export default define(meta, async (ps, user) => {
|
||||
}
|
||||
//#endregion
|
||||
|
||||
const timeline = await query.take(ps.limit!).getMany();
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
|
||||
process.nextTick(() => {
|
||||
if (user) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { getNote } from '../../common/getters';
|
||||
import { ApiError } from '../../error';
|
||||
@ -15,15 +13,6 @@ export const meta = {
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
targetLang: {
|
||||
validator: $.str,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
@ -38,8 +27,17 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
targetLang: { type: 'string' },
|
||||
},
|
||||
required: ['noteId', 'targetLang'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import deleteNote from '@/services/note/delete';
|
||||
import define from '../../define';
|
||||
import ms from 'ms';
|
||||
@ -20,12 +18,6 @@ export const meta = {
|
||||
minInterval: ms('1sec'),
|
||||
},
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
@ -35,8 +27,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../define';
|
||||
import { ApiError } from '../../error';
|
||||
import { UserLists, UserListJoinings, Notes } from '@/models/index';
|
||||
@ -13,52 +11,6 @@ export const meta = {
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
params: {
|
||||
listId: {
|
||||
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,
|
||||
},
|
||||
|
||||
includeMyRenotes: {
|
||||
validator: $.optional.bool,
|
||||
default: true,
|
||||
},
|
||||
|
||||
includeRenotedMyNotes: {
|
||||
validator: $.optional.bool,
|
||||
default: true,
|
||||
},
|
||||
|
||||
includeLocalRenotes: {
|
||||
validator: $.optional.bool,
|
||||
default: true,
|
||||
},
|
||||
|
||||
withFiles: {
|
||||
validator: $.optional.bool,
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
@ -78,8 +30,25 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
listId: { 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' },
|
||||
includeMyRenotes: { type: 'boolean', default: true },
|
||||
includeRenotedMyNotes: { type: 'boolean', default: true },
|
||||
includeLocalRenotes: { type: 'boolean', default: true },
|
||||
withFiles: { type: 'boolean' },
|
||||
},
|
||||
required: ['listId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, async (ps, user) => {
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const list = await UserLists.findOne({
|
||||
id: ps.listId,
|
||||
userId: user.id,
|
||||
@ -140,7 +109,7 @@ export default define(meta, async (ps, user) => {
|
||||
}
|
||||
//#endregion
|
||||
|
||||
const timeline = await query.take(ps.limit!).getMany();
|
||||
const timeline = await query.take(ps.limit).getMany();
|
||||
|
||||
activeUsersChart.read(user);
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import watch from '@/services/note/watch';
|
||||
import { getNote } from '../../../common/getters';
|
||||
@ -12,12 +10,6 @@ export const meta = {
|
||||
|
||||
kind: 'write:account',
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
@ -27,8 +19,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
@ -1,5 +1,3 @@
|
||||
import $ from 'cafy';
|
||||
import { ID } from '@/misc/cafy-id';
|
||||
import define from '../../../define';
|
||||
import unwatch from '@/services/note/unwatch';
|
||||
import { getNote } from '../../../common/getters';
|
||||
@ -12,12 +10,6 @@ export const meta = {
|
||||
|
||||
kind: 'write:account',
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchNote: {
|
||||
message: 'No such note.',
|
||||
@ -27,8 +19,16 @@ export const meta = {
|
||||
},
|
||||
} as const;
|
||||
|
||||
const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// 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 => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
|
Reference in New Issue
Block a user