: never;
-export type SchemaTypeDef =
+export type SchemaTypeDef
=
+ p['type'] extends 'null' ? null :
+ p['type'] extends 'integer' ? number :
p['type'] extends 'number' ? number :
p['type'] extends 'string' ? (
p['enum'] extends readonly string[] ?
@@ -151,22 +146,22 @@ export type SchemaTypeDef
=
p['type'] extends 'boolean' ? boolean :
p['type'] extends 'object' ? (
p['ref'] extends keyof typeof refs ? Packed
:
- p['properties'] extends NonNullable ? ObjType :
- p['anyOf'] extends ReadonlyArray ? UnionSchemaType & Partial>> :
- p['allOf'] extends ReadonlyArray ? UnionToIntersection> :
+ p['properties'] extends NonNullable ? ObjType[number]> :
+ p['anyOf'] extends ReadonlyArray ? UnionSchemaType & Partial>> :
+ p['allOf'] extends ReadonlyArray ? UnionToIntersection> :
any
) :
p['type'] extends 'array' ? (
p['items'] extends OfSchema ? (
- p['items']['anyOf'] extends ReadonlyArray ? UnionSchemaType>[] :
- p['items']['oneOf'] extends ReadonlyArray ? ArrayUnion>> :
- p['items']['allOf'] extends ReadonlyArray ? UnionToIntersection>>[] :
+ p['items']['anyOf'] extends ReadonlyArray ? UnionSchemaType>[] :
+ p['items']['oneOf'] extends ReadonlyArray ? ArrayUnion>> :
+ p['items']['allOf'] extends ReadonlyArray ? UnionToIntersection>>[] :
never
) :
- p['items'] extends NonNullable ? SchemaTypeDef[] :
+ p['items'] extends NonNullable ? SchemaTypeDef[] :
any[]
) :
- p['oneOf'] extends ReadonlyArray ? UnionSchemaType :
+ p['oneOf'] extends ReadonlyArray ? UnionSchemaType :
any;
-export type SchemaType
= NullOrUndefined
>;
+export type SchemaType
= NullOrUndefined
>;
diff --git a/packages/backend/src/misc/secure-rndstr.ts b/packages/backend/src/misc/secure-rndstr.ts
index 76ee1225e..8d4fcb1ba 100644
--- a/packages/backend/src/misc/secure-rndstr.ts
+++ b/packages/backend/src/misc/secure-rndstr.ts
@@ -1,4 +1,4 @@
-import * as crypto from 'crypto';
+import * as crypto from 'node:crypto';
const L_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz';
const LU_CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
diff --git a/packages/backend/src/misc/show-machine-info.ts b/packages/backend/src/misc/show-machine-info.ts
index 58747c115..bc71cfbe9 100644
--- a/packages/backend/src/misc/show-machine-info.ts
+++ b/packages/backend/src/misc/show-machine-info.ts
@@ -1,6 +1,6 @@
-import * as os from 'os';
-import * as sysUtils from 'systeminformation';
-import Logger from '@/services/logger';
+import * as os from 'node:os';
+import sysUtils from 'systeminformation';
+import Logger from '@/services/logger.js';
export async function showMachineInfo(parentLogger: Logger) {
const logger = parentLogger.createSubLogger('machine');
diff --git a/packages/backend/src/models/entities/abuse-user-report.ts b/packages/backend/src/models/entities/abuse-user-report.ts
index 27c1e47fd..6ac563552 100644
--- a/packages/backend/src/models/entities/abuse-user-report.ts
+++ b/packages/backend/src/models/entities/abuse-user-report.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class AbuseUserReport {
diff --git a/packages/backend/src/models/entities/access-token.ts b/packages/backend/src/models/entities/access-token.ts
index 33b60e44f..69cdc49ce 100644
--- a/packages/backend/src/models/entities/access-token.ts
+++ b/packages/backend/src/models/entities/access-token.ts
@@ -1,7 +1,7 @@
import { Entity, PrimaryColumn, Index, Column, ManyToOne, JoinColumn } from 'typeorm';
-import { User } from './user';
-import { App } from './app';
-import { id } from '../id';
+import { User } from './user.js';
+import { App } from './app.js';
+import { id } from '../id.js';
@Entity()
export class AccessToken {
diff --git a/packages/backend/src/models/entities/ad.ts b/packages/backend/src/models/entities/ad.ts
index 68be4ab1c..36b758f20 100644
--- a/packages/backend/src/models/entities/ad.ts
+++ b/packages/backend/src/models/entities/ad.ts
@@ -1,5 +1,5 @@
import { Entity, Index, Column, PrimaryColumn } from 'typeorm';
-import { id } from '../id';
+import { id } from '../id.js';
@Entity()
export class Ad {
diff --git a/packages/backend/src/models/entities/announcement-read.ts b/packages/backend/src/models/entities/announcement-read.ts
index 88a1966e2..e4d256a86 100644
--- a/packages/backend/src/models/entities/announcement-read.ts
+++ b/packages/backend/src/models/entities/announcement-read.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { Announcement } from './announcement';
-import { id } from '../id';
+import { User } from './user.js';
+import { Announcement } from './announcement.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'announcementId'], { unique: true })
diff --git a/packages/backend/src/models/entities/announcement.ts b/packages/backend/src/models/entities/announcement.ts
index 3448bb686..beb2f8246 100644
--- a/packages/backend/src/models/entities/announcement.ts
+++ b/packages/backend/src/models/entities/announcement.ts
@@ -1,5 +1,5 @@
import { Entity, Index, Column, PrimaryColumn } from 'typeorm';
-import { id } from '../id';
+import { id } from '../id.js';
@Entity()
export class Announcement {
diff --git a/packages/backend/src/models/entities/antenna-note.ts b/packages/backend/src/models/entities/antenna-note.ts
index a72da423d..fcca493fe 100644
--- a/packages/backend/src/models/entities/antenna-note.ts
+++ b/packages/backend/src/models/entities/antenna-note.ts
@@ -1,7 +1,7 @@
import { Entity, Index, JoinColumn, Column, ManyToOne, PrimaryColumn } from 'typeorm';
-import { Note } from './note';
-import { Antenna } from './antenna';
-import { id } from '../id';
+import { Note } from './note.js';
+import { Antenna } from './antenna.js';
+import { id } from '../id.js';
@Entity()
@Index(['noteId', 'antennaId'], { unique: true })
diff --git a/packages/backend/src/models/entities/antenna.ts b/packages/backend/src/models/entities/antenna.ts
index ffe7cc7e3..6c8bb13e5 100644
--- a/packages/backend/src/models/entities/antenna.ts
+++ b/packages/backend/src/models/entities/antenna.ts
@@ -1,8 +1,8 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
-import { UserList } from './user-list';
-import { UserGroupJoining } from './user-group-joining';
+import { User } from './user.js';
+import { id } from '../id.js';
+import { UserList } from './user-list.js';
+import { UserGroupJoining } from './user-group-joining.js';
@Entity()
export class Antenna {
diff --git a/packages/backend/src/models/entities/app.ts b/packages/backend/src/models/entities/app.ts
index c1efdc070..46c11548a 100644
--- a/packages/backend/src/models/entities/app.ts
+++ b/packages/backend/src/models/entities/app.ts
@@ -1,6 +1,6 @@
import { Entity, PrimaryColumn, Column, Index, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class App {
diff --git a/packages/backend/src/models/entities/attestation-challenge.ts b/packages/backend/src/models/entities/attestation-challenge.ts
index cf3527059..c40df2329 100644
--- a/packages/backend/src/models/entities/attestation-challenge.ts
+++ b/packages/backend/src/models/entities/attestation-challenge.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, JoinColumn, Column, ManyToOne, Index } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class AttestationChallenge {
diff --git a/packages/backend/src/models/entities/auth-session.ts b/packages/backend/src/models/entities/auth-session.ts
index 199138552..b82585620 100644
--- a/packages/backend/src/models/entities/auth-session.ts
+++ b/packages/backend/src/models/entities/auth-session.ts
@@ -1,7 +1,7 @@
import { Entity, PrimaryColumn, Index, Column, ManyToOne, JoinColumn } from 'typeorm';
-import { User } from './user';
-import { App } from './app';
-import { id } from '../id';
+import { User } from './user.js';
+import { App } from './app.js';
+import { id } from '../id.js';
@Entity()
export class AuthSession {
diff --git a/packages/backend/src/models/entities/blocking.ts b/packages/backend/src/models/entities/blocking.ts
index aacbfef7f..4ac73a00b 100644
--- a/packages/backend/src/models/entities/blocking.ts
+++ b/packages/backend/src/models/entities/blocking.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
@Index(['blockerId', 'blockeeId'], { unique: true })
diff --git a/packages/backend/src/models/entities/channel-following.ts b/packages/backend/src/models/entities/channel-following.ts
index 3727283a2..029dd6cf1 100644
--- a/packages/backend/src/models/entities/channel-following.ts
+++ b/packages/backend/src/models/entities/channel-following.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
-import { Channel } from './channel';
+import { User } from './user.js';
+import { id } from '../id.js';
+import { Channel } from './channel.js';
@Entity()
@Index(['followerId', 'followeeId'], { unique: true })
diff --git a/packages/backend/src/models/entities/channel-note-pining.ts b/packages/backend/src/models/entities/channel-note-pining.ts
index d6b677403..23be3b69d 100644
--- a/packages/backend/src/models/entities/channel-note-pining.ts
+++ b/packages/backend/src/models/entities/channel-note-pining.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { Note } from './note';
-import { Channel } from './channel';
-import { id } from '../id';
+import { Note } from './note.js';
+import { Channel } from './channel.js';
+import { id } from '../id.js';
@Entity()
@Index(['channelId', 'noteId'], { unique: true })
diff --git a/packages/backend/src/models/entities/channel.ts b/packages/backend/src/models/entities/channel.ts
index a6767b038..abf6668bd 100644
--- a/packages/backend/src/models/entities/channel.ts
+++ b/packages/backend/src/models/entities/channel.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
-import { DriveFile } from './drive-file';
+import { User } from './user.js';
+import { id } from '../id.js';
+import { DriveFile } from './drive-file.js';
@Entity()
export class Channel {
diff --git a/packages/backend/src/models/entities/clip-note.ts b/packages/backend/src/models/entities/clip-note.ts
index 2bc435226..6f3688550 100644
--- a/packages/backend/src/models/entities/clip-note.ts
+++ b/packages/backend/src/models/entities/clip-note.ts
@@ -1,7 +1,7 @@
import { Entity, Index, JoinColumn, Column, ManyToOne, PrimaryColumn } from 'typeorm';
-import { Note } from './note';
-import { Clip } from './clip';
-import { id } from '../id';
+import { Note } from './note.js';
+import { Clip } from './clip.js';
+import { id } from '../id.js';
@Entity()
@Index(['noteId', 'clipId'], { unique: true })
diff --git a/packages/backend/src/models/entities/clip.ts b/packages/backend/src/models/entities/clip.ts
index 84f5c4d21..da6b3c7a7 100644
--- a/packages/backend/src/models/entities/clip.ts
+++ b/packages/backend/src/models/entities/clip.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class Clip {
diff --git a/packages/backend/src/models/entities/drive-file.ts b/packages/backend/src/models/entities/drive-file.ts
index cec86880f..3d375f0e3 100644
--- a/packages/backend/src/models/entities/drive-file.ts
+++ b/packages/backend/src/models/entities/drive-file.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { DriveFolder } from './drive-folder';
-import { id } from '../id';
+import { User } from './user.js';
+import { DriveFolder } from './drive-folder.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'folderId', 'id'])
diff --git a/packages/backend/src/models/entities/drive-folder.ts b/packages/backend/src/models/entities/drive-folder.ts
index 09f5e6448..d4022c6eb 100644
--- a/packages/backend/src/models/entities/drive-folder.ts
+++ b/packages/backend/src/models/entities/drive-folder.ts
@@ -1,6 +1,6 @@
import { JoinColumn, ManyToOne, Entity, PrimaryColumn, Index, Column } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class DriveFolder {
diff --git a/packages/backend/src/models/entities/emoji.ts b/packages/backend/src/models/entities/emoji.ts
index 2e9c11d21..b72ca7233 100644
--- a/packages/backend/src/models/entities/emoji.ts
+++ b/packages/backend/src/models/entities/emoji.ts
@@ -1,5 +1,5 @@
import { PrimaryColumn, Entity, Index, Column } from 'typeorm';
-import { id } from '../id';
+import { id } from '../id.js';
@Entity()
@Index(['name', 'host'], { unique: true })
diff --git a/packages/backend/src/models/entities/follow-request.ts b/packages/backend/src/models/entities/follow-request.ts
index 6aa202299..89946f6d3 100644
--- a/packages/backend/src/models/entities/follow-request.ts
+++ b/packages/backend/src/models/entities/follow-request.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
@Index(['followerId', 'followeeId'], { unique: true })
diff --git a/packages/backend/src/models/entities/following.ts b/packages/backend/src/models/entities/following.ts
index ad387e518..b283ca7e8 100644
--- a/packages/backend/src/models/entities/following.ts
+++ b/packages/backend/src/models/entities/following.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
@Index(['followerId', 'followeeId'], { unique: true })
diff --git a/packages/backend/src/models/entities/gallery-like.ts b/packages/backend/src/models/entities/gallery-like.ts
index 41615dcea..4ce166d19 100644
--- a/packages/backend/src/models/entities/gallery-like.ts
+++ b/packages/backend/src/models/entities/gallery-like.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
-import { GalleryPost } from './gallery-post';
+import { User } from './user.js';
+import { id } from '../id.js';
+import { GalleryPost } from './gallery-post.js';
@Entity()
@Index(['userId', 'postId'], { unique: true })
diff --git a/packages/backend/src/models/entities/gallery-post.ts b/packages/backend/src/models/entities/gallery-post.ts
index 393603e3d..774cb946e 100644
--- a/packages/backend/src/models/entities/gallery-post.ts
+++ b/packages/backend/src/models/entities/gallery-post.ts
@@ -1,7 +1,7 @@
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
-import { DriveFile } from './drive-file';
+import { User } from './user.js';
+import { id } from '../id.js';
+import { DriveFile } from './drive-file.js';
@Entity()
export class GalleryPost {
diff --git a/packages/backend/src/models/entities/hashtag.ts b/packages/backend/src/models/entities/hashtag.ts
index 761974590..6bd991f62 100644
--- a/packages/backend/src/models/entities/hashtag.ts
+++ b/packages/backend/src/models/entities/hashtag.ts
@@ -1,6 +1,6 @@
import { Entity, PrimaryColumn, Index, Column } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class Hashtag {
diff --git a/packages/backend/src/models/entities/instance.ts b/packages/backend/src/models/entities/instance.ts
index d1314be17..bb24d6b30 100644
--- a/packages/backend/src/models/entities/instance.ts
+++ b/packages/backend/src/models/entities/instance.ts
@@ -1,5 +1,5 @@
import { Entity, PrimaryColumn, Index, Column } from 'typeorm';
-import { id } from '../id';
+import { id } from '../id.js';
@Entity()
export class Instance {
@@ -59,22 +59,6 @@ export class Instance {
})
public followersCount: number;
- /**
- * ドライブ使用量
- */
- @Column('bigint', {
- default: 0,
- })
- public driveUsage: number;
-
- /**
- * ドライブのファイル数
- */
- @Column('integer', {
- default: 0,
- })
- public driveFiles: number;
-
/**
* 直近のリクエスト送信日時
*/
diff --git a/packages/backend/src/models/entities/messaging-message.ts b/packages/backend/src/models/entities/messaging-message.ts
index 06ae005de..099fb7aa0 100644
--- a/packages/backend/src/models/entities/messaging-message.ts
+++ b/packages/backend/src/models/entities/messaging-message.ts
@@ -1,8 +1,8 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { DriveFile } from './drive-file';
-import { id } from '../id';
-import { UserGroup } from './user-group';
+import { User } from './user.js';
+import { DriveFile } from './drive-file.js';
+import { id } from '../id.js';
+import { UserGroup } from './user-group.js';
@Entity()
export class MessagingMessage {
diff --git a/packages/backend/src/models/entities/meta.ts b/packages/backend/src/models/entities/meta.ts
index 1426c79c5..4d58b5f04 100644
--- a/packages/backend/src/models/entities/meta.ts
+++ b/packages/backend/src/models/entities/meta.ts
@@ -1,7 +1,7 @@
import { Entity, Column, PrimaryColumn, ManyToOne, JoinColumn } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
-import { Clip } from './clip';
+import { User } from './user.js';
+import { id } from '../id.js';
+import { Clip } from './clip.js';
@Entity()
export class Meta {
@@ -137,11 +137,6 @@ export class Meta {
})
public cacheRemoteFiles: boolean;
- @Column('boolean', {
- default: false,
- })
- public proxyRemoteFiles: boolean;
-
@Column({
...id(),
nullable: true,
@@ -205,12 +200,6 @@ export class Meta {
})
public remoteDriveCapacityMb: number;
- @Column('integer', {
- default: 500,
- comment: 'Max allowed note text length in characters',
- })
- public maxNoteTextLength: number;
-
@Column('varchar', {
length: 128,
nullable: true,
@@ -355,6 +344,20 @@ export class Meta {
})
public feedbackUrl: string | null;
+ @Column('varchar', {
+ length: 8192,
+ default: null,
+ nullable: true,
+ })
+ public defaultLightTheme: string | null;
+
+ @Column('varchar', {
+ length: 8192,
+ default: null,
+ nullable: true,
+ })
+ public defaultDarkTheme: string | null;
+
@Column('boolean', {
default: false,
})
diff --git a/packages/backend/src/models/entities/moderation-log.ts b/packages/backend/src/models/entities/moderation-log.ts
index fe000e14f..c99e55078 100644
--- a/packages/backend/src/models/entities/moderation-log.ts
+++ b/packages/backend/src/models/entities/moderation-log.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class ModerationLog {
diff --git a/packages/backend/src/models/entities/muted-note.ts b/packages/backend/src/models/entities/muted-note.ts
index b01bb0551..96a4fa8e3 100644
--- a/packages/backend/src/models/entities/muted-note.ts
+++ b/packages/backend/src/models/entities/muted-note.ts
@@ -1,8 +1,8 @@
import { Entity, Index, JoinColumn, Column, ManyToOne, PrimaryColumn } from 'typeorm';
-import { Note } from './note';
-import { User } from './user';
-import { id } from '../id';
-import { mutedNoteReasons } from '../../types';
+import { Note } from './note.js';
+import { User } from './user.js';
+import { id } from '../id.js';
+import { mutedNoteReasons } from '../../types.js';
@Entity()
@Index(['noteId', 'userId'], { unique: true })
diff --git a/packages/backend/src/models/entities/muting.ts b/packages/backend/src/models/entities/muting.ts
index b9f18a585..b3a7e7a67 100644
--- a/packages/backend/src/models/entities/muting.ts
+++ b/packages/backend/src/models/entities/muting.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
@Index(['muterId', 'muteeId'], { unique: true })
@@ -14,6 +14,13 @@ export class Muting {
})
public createdAt: Date;
+ @Index()
+ @Column('timestamp with time zone', {
+ nullable: true,
+ default: null,
+ })
+ public expiresAt: Date | null;
+
@Index()
@Column({
...id(),
diff --git a/packages/backend/src/models/entities/note-favorite.ts b/packages/backend/src/models/entities/note-favorite.ts
index 69d9b49d1..fe065b77a 100644
--- a/packages/backend/src/models/entities/note-favorite.ts
+++ b/packages/backend/src/models/entities/note-favorite.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { Note } from './note';
-import { User } from './user';
-import { id } from '../id';
+import { Note } from './note.js';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'noteId'], { unique: true })
diff --git a/packages/backend/src/models/entities/note-reaction.ts b/packages/backend/src/models/entities/note-reaction.ts
index 369505a6c..d7bc60989 100644
--- a/packages/backend/src/models/entities/note-reaction.ts
+++ b/packages/backend/src/models/entities/note-reaction.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { Note } from './note';
-import { id } from '../id';
+import { User } from './user.js';
+import { Note } from './note.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'noteId'], { unique: true })
diff --git a/packages/backend/src/models/entities/note-thread-muting.ts b/packages/backend/src/models/entities/note-thread-muting.ts
index f4a3a4887..8c5f7bbab 100644
--- a/packages/backend/src/models/entities/note-thread-muting.ts
+++ b/packages/backend/src/models/entities/note-thread-muting.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { Note } from './note';
-import { id } from '../id';
+import { User } from './user.js';
+import { Note } from './note.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'threadId'], { unique: true })
diff --git a/packages/backend/src/models/entities/note-unread.ts b/packages/backend/src/models/entities/note-unread.ts
index 952f71cda..a7acf254d 100644
--- a/packages/backend/src/models/entities/note-unread.ts
+++ b/packages/backend/src/models/entities/note-unread.ts
@@ -1,8 +1,8 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { Note } from './note';
-import { id } from '../id';
-import { Channel } from './channel';
+import { User } from './user.js';
+import { Note } from './note.js';
+import { id } from '../id.js';
+import { Channel } from './channel.js';
@Entity()
@Index(['userId', 'noteId'], { unique: true })
diff --git a/packages/backend/src/models/entities/note-watching.ts b/packages/backend/src/models/entities/note-watching.ts
index 2758efdc3..ed82e7dfe 100644
--- a/packages/backend/src/models/entities/note-watching.ts
+++ b/packages/backend/src/models/entities/note-watching.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { Note } from './note';
-import { id } from '../id';
+import { User } from './user.js';
+import { Note } from './note.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'noteId'], { unique: true })
diff --git a/packages/backend/src/models/entities/note.ts b/packages/backend/src/models/entities/note.ts
index e4a5ac871..da49d53b6 100644
--- a/packages/backend/src/models/entities/note.ts
+++ b/packages/backend/src/models/entities/note.ts
@@ -1,9 +1,9 @@
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { DriveFile } from './drive-file';
-import { id } from '../id';
-import { noteVisibilities } from '../../types';
-import { Channel } from './channel';
+import { User } from './user.js';
+import { DriveFile } from './drive-file.js';
+import { id } from '../id.js';
+import { noteVisibilities } from '../../types.js';
+import { Channel } from './channel.js';
@Entity()
@Index('IDX_NOTE_TAGS', { synchronize: false })
diff --git a/packages/backend/src/models/entities/notification.ts b/packages/backend/src/models/entities/notification.ts
index 9c1d8242f..db3dba363 100644
--- a/packages/backend/src/models/entities/notification.ts
+++ b/packages/backend/src/models/entities/notification.ts
@@ -1,11 +1,11 @@
import { Entity, Index, JoinColumn, ManyToOne, Column, PrimaryColumn } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
-import { Note } from './note';
-import { FollowRequest } from './follow-request';
-import { UserGroupInvitation } from './user-group-invitation';
-import { AccessToken } from './access-token';
-import { notificationTypes } from '@/types';
+import { User } from './user.js';
+import { id } from '../id.js';
+import { Note } from './note.js';
+import { FollowRequest } from './follow-request.js';
+import { UserGroupInvitation } from './user-group-invitation.js';
+import { AccessToken } from './access-token.js';
+import { notificationTypes } from '@/types.js';
@Entity()
export class Notification {
@@ -59,7 +59,8 @@ export class Notification {
* renote - (自分または自分がWatchしている)投稿がRenoteされた
* quote - (自分または自分がWatchしている)投稿が引用Renoteされた
* reaction - (自分または自分がWatchしている)投稿にリアクションされた
- * pollVote - (自分または自分がWatchしている)投稿の投票に投票された
+ * pollVote - (自分または自分がWatchしている)投稿のアンケートに投票された
+ * pollEnded - 自分のアンケートもしくは自分が投票したアンケートが終了した
* receiveFollowRequest - フォローリクエストされた
* followRequestAccepted - 自分の送ったフォローリクエストが承認された
* groupInvited - グループに招待された
diff --git a/packages/backend/src/models/entities/page-like.ts b/packages/backend/src/models/entities/page-like.ts
index 16fb8f172..17f4ebf52 100644
--- a/packages/backend/src/models/entities/page-like.ts
+++ b/packages/backend/src/models/entities/page-like.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
-import { Page } from './page';
+import { User } from './user.js';
+import { id } from '../id.js';
+import { Page } from './page.js';
@Entity()
@Index(['userId', 'pageId'], { unique: true })
diff --git a/packages/backend/src/models/entities/page.ts b/packages/backend/src/models/entities/page.ts
index 2b540e199..baad3a36f 100644
--- a/packages/backend/src/models/entities/page.ts
+++ b/packages/backend/src/models/entities/page.ts
@@ -1,7 +1,7 @@
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
-import { DriveFile } from './drive-file';
+import { User } from './user.js';
+import { id } from '../id.js';
+import { DriveFile } from './drive-file.js';
@Entity()
@Index(['userId', 'name'], { unique: true })
diff --git a/packages/backend/src/models/entities/password-reset-request.ts b/packages/backend/src/models/entities/password-reset-request.ts
index a2db0f114..05e62cc5a 100644
--- a/packages/backend/src/models/entities/password-reset-request.ts
+++ b/packages/backend/src/models/entities/password-reset-request.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, Column, ManyToOne, JoinColumn } from 'typeorm';
-import { id } from '../id';
-import { User } from './user';
+import { id } from '../id.js';
+import { User } from './user.js';
@Entity()
export class PasswordResetRequest {
diff --git a/packages/backend/src/models/entities/poll-vote.ts b/packages/backend/src/models/entities/poll-vote.ts
index fb44a58e9..fca1cd009 100644
--- a/packages/backend/src/models/entities/poll-vote.ts
+++ b/packages/backend/src/models/entities/poll-vote.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { Note } from './note';
-import { id } from '../id';
+import { User } from './user.js';
+import { Note } from './note.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'noteId', 'choice'], { unique: true })
diff --git a/packages/backend/src/models/entities/poll.ts b/packages/backend/src/models/entities/poll.ts
index 9c8069349..83d0873cc 100644
--- a/packages/backend/src/models/entities/poll.ts
+++ b/packages/backend/src/models/entities/poll.ts
@@ -1,8 +1,8 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, OneToOne } from 'typeorm';
-import { id } from '../id';
-import { Note } from './note';
-import { User } from './user';
-import { noteVisibilities } from '../../types';
+import { id } from '../id.js';
+import { Note } from './note.js';
+import { User } from './user.js';
+import { noteVisibilities } from '../../types.js';
@Entity()
export class Poll {
diff --git a/packages/backend/src/models/entities/promo-note.ts b/packages/backend/src/models/entities/promo-note.ts
index e3fbab441..d110b81e9 100644
--- a/packages/backend/src/models/entities/promo-note.ts
+++ b/packages/backend/src/models/entities/promo-note.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, OneToOne } from 'typeorm';
-import { Note } from './note';
-import { User } from './user';
-import { id } from '../id';
+import { Note } from './note.js';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class PromoNote {
diff --git a/packages/backend/src/models/entities/promo-read.ts b/packages/backend/src/models/entities/promo-read.ts
index 777ed301b..a63b79cd1 100644
--- a/packages/backend/src/models/entities/promo-read.ts
+++ b/packages/backend/src/models/entities/promo-read.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { Note } from './note';
-import { User } from './user';
-import { id } from '../id';
+import { Note } from './note.js';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'noteId'], { unique: true })
diff --git a/packages/backend/src/models/entities/registration-tickets.ts b/packages/backend/src/models/entities/registration-tickets.ts
index d962f78a7..139e40f85 100644
--- a/packages/backend/src/models/entities/registration-tickets.ts
+++ b/packages/backend/src/models/entities/registration-tickets.ts
@@ -1,5 +1,5 @@
import { PrimaryColumn, Entity, Index, Column } from 'typeorm';
-import { id } from '../id';
+import { id } from '../id.js';
@Entity()
export class RegistrationTicket {
diff --git a/packages/backend/src/models/entities/registry-item.ts b/packages/backend/src/models/entities/registry-item.ts
index 6d5f0185d..283796df9 100644
--- a/packages/backend/src/models/entities/registry-item.ts
+++ b/packages/backend/src/models/entities/registry-item.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
// TODO: 同じdomain、同じscope、同じkeyのレコードは二つ以上存在しないように制約付けたい
@Entity()
diff --git a/packages/backend/src/models/entities/relay.ts b/packages/backend/src/models/entities/relay.ts
index 4c82ccb12..94d192957 100644
--- a/packages/backend/src/models/entities/relay.ts
+++ b/packages/backend/src/models/entities/relay.ts
@@ -1,5 +1,5 @@
import { PrimaryColumn, Entity, Index, Column } from 'typeorm';
-import { id } from '../id';
+import { id } from '../id.js';
@Entity()
export class Relay {
diff --git a/packages/backend/src/models/entities/signin.ts b/packages/backend/src/models/entities/signin.ts
index 7f54f2ebf..ba81f45e4 100644
--- a/packages/backend/src/models/entities/signin.ts
+++ b/packages/backend/src/models/entities/signin.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class Signin {
diff --git a/packages/backend/src/models/entities/sw-subscription.ts b/packages/backend/src/models/entities/sw-subscription.ts
index 2debcf744..59144d348 100644
--- a/packages/backend/src/models/entities/sw-subscription.ts
+++ b/packages/backend/src/models/entities/sw-subscription.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class SwSubscription {
diff --git a/packages/backend/src/models/entities/user-group-invitation.ts b/packages/backend/src/models/entities/user-group-invitation.ts
index 479442a13..10f357049 100644
--- a/packages/backend/src/models/entities/user-group-invitation.ts
+++ b/packages/backend/src/models/entities/user-group-invitation.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { UserGroup } from './user-group';
-import { id } from '../id';
+import { User } from './user.js';
+import { UserGroup } from './user-group.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'userGroupId'], { unique: true })
diff --git a/packages/backend/src/models/entities/user-group-joining.ts b/packages/backend/src/models/entities/user-group-joining.ts
index 81f335858..62a814218 100644
--- a/packages/backend/src/models/entities/user-group-joining.ts
+++ b/packages/backend/src/models/entities/user-group-joining.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { UserGroup } from './user-group';
-import { id } from '../id';
+import { User } from './user.js';
+import { UserGroup } from './user-group.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'userGroupId'], { unique: true })
diff --git a/packages/backend/src/models/entities/user-group.ts b/packages/backend/src/models/entities/user-group.ts
index 1fdb60c40..8d5de1d92 100644
--- a/packages/backend/src/models/entities/user-group.ts
+++ b/packages/backend/src/models/entities/user-group.ts
@@ -1,6 +1,6 @@
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class UserGroup {
diff --git a/packages/backend/src/models/entities/user-keypair.ts b/packages/backend/src/models/entities/user-keypair.ts
index 48bff0d10..85fa06297 100644
--- a/packages/backend/src/models/entities/user-keypair.ts
+++ b/packages/backend/src/models/entities/user-keypair.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, JoinColumn, Column, OneToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class UserKeypair {
diff --git a/packages/backend/src/models/entities/user-list-joining.ts b/packages/backend/src/models/entities/user-list-joining.ts
index 2efa01752..12f28c414 100644
--- a/packages/backend/src/models/entities/user-list-joining.ts
+++ b/packages/backend/src/models/entities/user-list-joining.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { UserList } from './user-list';
-import { id } from '../id';
+import { User } from './user.js';
+import { UserList } from './user-list.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'userListId'], { unique: true })
diff --git a/packages/backend/src/models/entities/user-list.ts b/packages/backend/src/models/entities/user-list.ts
index c2896a1db..ca69394e9 100644
--- a/packages/backend/src/models/entities/user-list.ts
+++ b/packages/backend/src/models/entities/user-list.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class UserList {
diff --git a/packages/backend/src/models/entities/user-note-pining.ts b/packages/backend/src/models/entities/user-note-pining.ts
index b91e02c5c..c91ab7fdd 100644
--- a/packages/backend/src/models/entities/user-note-pining.ts
+++ b/packages/backend/src/models/entities/user-note-pining.ts
@@ -1,7 +1,7 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
-import { Note } from './note';
-import { User } from './user';
-import { id } from '../id';
+import { Note } from './note.js';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
@Index(['userId', 'noteId'], { unique: true })
diff --git a/packages/backend/src/models/entities/user-pending.ts b/packages/backend/src/models/entities/user-pending.ts
index 40482af33..763794884 100644
--- a/packages/backend/src/models/entities/user-pending.ts
+++ b/packages/backend/src/models/entities/user-pending.ts
@@ -1,5 +1,5 @@
import { PrimaryColumn, Entity, Index, Column } from 'typeorm';
-import { id } from '../id';
+import { id } from '../id.js';
@Entity()
export class UserPending {
diff --git a/packages/backend/src/models/entities/user-profile.ts b/packages/backend/src/models/entities/user-profile.ts
index d8317de8d..f95cb144c 100644
--- a/packages/backend/src/models/entities/user-profile.ts
+++ b/packages/backend/src/models/entities/user-profile.ts
@@ -1,8 +1,8 @@
import { Entity, Column, Index, OneToOne, JoinColumn, PrimaryColumn } from 'typeorm';
-import { id } from '../id';
-import { User } from './user';
-import { Page } from './page';
-import { ffVisibility, notificationTypes } from '@/types';
+import { id } from '../id.js';
+import { User } from './user.js';
+import { Page } from './page.js';
+import { ffVisibility, notificationTypes } from '@/types.js';
// TODO: このテーブルで管理している情報すべてレジストリで管理するようにしても良いかも
// ただ、「emailVerified が true なユーザーを find する」のようなクエリは書けなくなるからウーン
diff --git a/packages/backend/src/models/entities/user-publickey.ts b/packages/backend/src/models/entities/user-publickey.ts
index 128e13510..31ed60de8 100644
--- a/packages/backend/src/models/entities/user-publickey.ts
+++ b/packages/backend/src/models/entities/user-publickey.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, OneToOne } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class UserPublickey {
diff --git a/packages/backend/src/models/entities/user-security-key.ts b/packages/backend/src/models/entities/user-security-key.ts
index e7b63fb82..c4f2a852e 100644
--- a/packages/backend/src/models/entities/user-security-key.ts
+++ b/packages/backend/src/models/entities/user-security-key.ts
@@ -1,6 +1,6 @@
import { PrimaryColumn, Entity, JoinColumn, Column, ManyToOne, Index } from 'typeorm';
-import { User } from './user';
-import { id } from '../id';
+import { User } from './user.js';
+import { id } from '../id.js';
@Entity()
export class UserSecurityKey {
diff --git a/packages/backend/src/models/entities/user.ts b/packages/backend/src/models/entities/user.ts
index e4d9a3ced..9d5db10eb 100644
--- a/packages/backend/src/models/entities/user.ts
+++ b/packages/backend/src/models/entities/user.ts
@@ -1,6 +1,6 @@
import { Entity, Column, Index, OneToOne, JoinColumn, PrimaryColumn } from 'typeorm';
-import { DriveFile } from './drive-file';
-import { id } from '../id';
+import { DriveFile } from './drive-file.js';
+import { id } from '../id.js';
@Entity()
@Index(['usernameLower', 'host'], { unique: true })
@@ -106,26 +106,6 @@ export class User {
})
public tags: string[];
- @Column('varchar', {
- length: 512, nullable: true,
- })
- public avatarUrl: string | null;
-
- @Column('varchar', {
- length: 512, nullable: true,
- })
- public bannerUrl: string | null;
-
- @Column('varchar', {
- length: 128, nullable: true,
- })
- public avatarBlurhash: string | null;
-
- @Column('varchar', {
- length: 128, nullable: true,
- })
- public bannerBlurhash: string | null;
-
@Column('boolean', {
default: false,
comment: 'Whether the User is suspended.',
diff --git a/packages/backend/src/models/index.ts b/packages/backend/src/models/index.ts
index 67da34739..e7b685488 100644
--- a/packages/backend/src/models/index.ts
+++ b/packages/backend/src/models/index.ts
@@ -1,66 +1,67 @@
import { getRepository, getCustomRepository } from 'typeorm';
-import { Announcement } from './entities/announcement';
-import { AnnouncementRead } from './entities/announcement-read';
-import { Instance } from './entities/instance';
-import { Poll } from './entities/poll';
-import { PollVote } from './entities/poll-vote';
-import { Meta } from './entities/meta';
-import { SwSubscription } from './entities/sw-subscription';
-import { NoteWatching } from './entities/note-watching';
-import { NoteThreadMuting } from './entities/note-thread-muting';
-import { NoteUnread } from './entities/note-unread';
-import { RegistrationTicket } from './entities/registration-tickets';
-import { UserRepository } from './repositories/user';
-import { NoteRepository } from './repositories/note';
-import { DriveFileRepository } from './repositories/drive-file';
-import { DriveFolderRepository } from './repositories/drive-folder';
-import { AccessToken } from './entities/access-token';
-import { UserNotePining } from './entities/user-note-pining';
-import { SigninRepository } from './repositories/signin';
-import { MessagingMessageRepository } from './repositories/messaging-message';
-import { UserListRepository } from './repositories/user-list';
-import { UserListJoining } from './entities/user-list-joining';
-import { UserGroupRepository } from './repositories/user-group';
-import { UserGroupJoining } from './entities/user-group-joining';
-import { UserGroupInvitationRepository } from './repositories/user-group-invitation';
-import { FollowRequestRepository } from './repositories/follow-request';
-import { MutingRepository } from './repositories/muting';
-import { BlockingRepository } from './repositories/blocking';
-import { NoteReactionRepository } from './repositories/note-reaction';
-import { NotificationRepository } from './repositories/notification';
-import { NoteFavoriteRepository } from './repositories/note-favorite';
-import { UserPublickey } from './entities/user-publickey';
-import { UserKeypair } from './entities/user-keypair';
-import { AppRepository } from './repositories/app';
-import { FollowingRepository } from './repositories/following';
-import { AbuseUserReportRepository } from './repositories/abuse-user-report';
-import { AuthSessionRepository } from './repositories/auth-session';
-import { UserProfile } from './entities/user-profile';
-import { AttestationChallenge } from './entities/attestation-challenge';
-import { UserSecurityKey } from './entities/user-security-key';
-import { HashtagRepository } from './repositories/hashtag';
-import { PageRepository } from './repositories/page';
-import { PageLikeRepository } from './repositories/page-like';
-import { GalleryPostRepository } from './repositories/gallery-post';
-import { GalleryLikeRepository } from './repositories/gallery-like';
-import { ModerationLogRepository } from './repositories/moderation-logs';
-import { UsedUsername } from './entities/used-username';
-import { ClipRepository } from './repositories/clip';
-import { ClipNote } from './entities/clip-note';
-import { AntennaRepository } from './repositories/antenna';
-import { AntennaNote } from './entities/antenna-note';
-import { PromoNote } from './entities/promo-note';
-import { PromoRead } from './entities/promo-read';
-import { EmojiRepository } from './repositories/emoji';
-import { RelayRepository } from './repositories/relay';
-import { ChannelRepository } from './repositories/channel';
-import { MutedNote } from './entities/muted-note';
-import { ChannelFollowing } from './entities/channel-following';
-import { ChannelNotePining } from './entities/channel-note-pining';
-import { RegistryItem } from './entities/registry-item';
-import { Ad } from './entities/ad';
-import { PasswordResetRequest } from './entities/password-reset-request';
-import { UserPending } from './entities/user-pending';
+import { Announcement } from './entities/announcement.js';
+import { AnnouncementRead } from './entities/announcement-read.js';
+import { Instance } from './entities/instance.js';
+import { Poll } from './entities/poll.js';
+import { PollVote } from './entities/poll-vote.js';
+import { Meta } from './entities/meta.js';
+import { SwSubscription } from './entities/sw-subscription.js';
+import { NoteWatching } from './entities/note-watching.js';
+import { NoteThreadMuting } from './entities/note-thread-muting.js';
+import { NoteUnread } from './entities/note-unread.js';
+import { RegistrationTicket } from './entities/registration-tickets.js';
+import { UserRepository } from './repositories/user.js';
+import { NoteRepository } from './repositories/note.js';
+import { DriveFileRepository } from './repositories/drive-file.js';
+import { DriveFolderRepository } from './repositories/drive-folder.js';
+import { AccessToken } from './entities/access-token.js';
+import { UserNotePining } from './entities/user-note-pining.js';
+import { SigninRepository } from './repositories/signin.js';
+import { MessagingMessageRepository } from './repositories/messaging-message.js';
+import { UserListRepository } from './repositories/user-list.js';
+import { UserListJoining } from './entities/user-list-joining.js';
+import { UserGroupRepository } from './repositories/user-group.js';
+import { UserGroupJoining } from './entities/user-group-joining.js';
+import { UserGroupInvitationRepository } from './repositories/user-group-invitation.js';
+import { FollowRequestRepository } from './repositories/follow-request.js';
+import { MutingRepository } from './repositories/muting.js';
+import { BlockingRepository } from './repositories/blocking.js';
+import { NoteReactionRepository } from './repositories/note-reaction.js';
+import { NotificationRepository } from './repositories/notification.js';
+import { NoteFavoriteRepository } from './repositories/note-favorite.js';
+import { UserPublickey } from './entities/user-publickey.js';
+import { UserKeypair } from './entities/user-keypair.js';
+import { AppRepository } from './repositories/app.js';
+import { FollowingRepository } from './repositories/following.js';
+import { AbuseUserReportRepository } from './repositories/abuse-user-report.js';
+import { AuthSessionRepository } from './repositories/auth-session.js';
+import { UserProfile } from './entities/user-profile.js';
+import { AttestationChallenge } from './entities/attestation-challenge.js';
+import { UserSecurityKey } from './entities/user-security-key.js';
+import { HashtagRepository } from './repositories/hashtag.js';
+import { PageRepository } from './repositories/page.js';
+import { PageLikeRepository } from './repositories/page-like.js';
+import { GalleryPostRepository } from './repositories/gallery-post.js';
+import { GalleryLikeRepository } from './repositories/gallery-like.js';
+import { ModerationLogRepository } from './repositories/moderation-logs.js';
+import { UsedUsername } from './entities/used-username.js';
+import { ClipRepository } from './repositories/clip.js';
+import { ClipNote } from './entities/clip-note.js';
+import { AntennaRepository } from './repositories/antenna.js';
+import { AntennaNote } from './entities/antenna-note.js';
+import { PromoNote } from './entities/promo-note.js';
+import { PromoRead } from './entities/promo-read.js';
+import { EmojiRepository } from './repositories/emoji.js';
+import { RelayRepository } from './repositories/relay.js';
+import { ChannelRepository } from './repositories/channel.js';
+import { MutedNote } from './entities/muted-note.js';
+import { ChannelFollowing } from './entities/channel-following.js';
+import { ChannelNotePining } from './entities/channel-note-pining.js';
+import { RegistryItem } from './entities/registry-item.js';
+import { Ad } from './entities/ad.js';
+import { PasswordResetRequest } from './entities/password-reset-request.js';
+import { UserPending } from './entities/user-pending.js';
+import { InstanceRepository } from './repositories/instance.js';
export const Announcements = getRepository(Announcement);
export const AnnouncementReads = getRepository(AnnouncementRead);
@@ -89,7 +90,7 @@ export const UserNotePinings = getRepository(UserNotePining);
export const UsedUsernames = getRepository(UsedUsername);
export const Followings = getCustomRepository(FollowingRepository);
export const FollowRequests = getCustomRepository(FollowRequestRepository);
-export const Instances = getRepository(Instance);
+export const Instances = getCustomRepository(InstanceRepository);
export const Emojis = getCustomRepository(EmojiRepository);
export const DriveFiles = getCustomRepository(DriveFileRepository);
export const DriveFolders = getCustomRepository(DriveFolderRepository);
diff --git a/packages/backend/src/models/repositories/abuse-user-report.ts b/packages/backend/src/models/repositories/abuse-user-report.ts
index 144195855..348f88b3a 100644
--- a/packages/backend/src/models/repositories/abuse-user-report.ts
+++ b/packages/backend/src/models/repositories/abuse-user-report.ts
@@ -1,7 +1,7 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Users } from '../index';
-import { AbuseUserReport } from '@/models/entities/abuse-user-report';
-import { awaitAll } from '@/prelude/await-all';
+import { Users } from '../index.js';
+import { AbuseUserReport } from '@/models/entities/abuse-user-report.js';
+import { awaitAll } from '@/prelude/await-all.js';
@EntityRepository(AbuseUserReport)
export class AbuseUserReportRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/antenna.ts b/packages/backend/src/models/repositories/antenna.ts
index 3bf0645a7..3440ca187 100644
--- a/packages/backend/src/models/repositories/antenna.ts
+++ b/packages/backend/src/models/repositories/antenna.ts
@@ -1,7 +1,7 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Antenna } from '@/models/entities/antenna';
-import { Packed } from '@/misc/schema';
-import { AntennaNotes, UserGroupJoinings } from '../index';
+import { Antenna } from '@/models/entities/antenna.js';
+import { Packed } from '@/misc/schema.js';
+import { AntennaNotes, UserGroupJoinings } from '../index.js';
@EntityRepository(Antenna)
export class AntennaRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/app.ts b/packages/backend/src/models/repositories/app.ts
index 6bac4d959..4c3c488da 100644
--- a/packages/backend/src/models/repositories/app.ts
+++ b/packages/backend/src/models/repositories/app.ts
@@ -1,8 +1,8 @@
import { EntityRepository, Repository } from 'typeorm';
-import { App } from '@/models/entities/app';
-import { AccessTokens } from '../index';
-import { Packed } from '@/misc/schema';
-import { User } from '../entities/user';
+import { App } from '@/models/entities/app.js';
+import { AccessTokens } from '../index.js';
+import { Packed } from '@/misc/schema.js';
+import { User } from '../entities/user.js';
@EntityRepository(App)
export class AppRepository extends Repository {
@@ -32,7 +32,7 @@ export class AppRepository extends Repository {
...(me ? {
isAuthorized: await AccessTokens.count({
appId: app.id,
- userId: me,
+ userId: me.id,
}).then(count => count > 0),
} : {}),
};
diff --git a/packages/backend/src/models/repositories/auth-session.ts b/packages/backend/src/models/repositories/auth-session.ts
index 6308909c4..7a7bd3a1e 100644
--- a/packages/backend/src/models/repositories/auth-session.ts
+++ b/packages/backend/src/models/repositories/auth-session.ts
@@ -1,8 +1,8 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Apps } from '../index';
-import { AuthSession } from '@/models/entities/auth-session';
-import { awaitAll } from '@/prelude/await-all';
-import { User } from '@/models/entities/user';
+import { Apps } from '../index.js';
+import { AuthSession } from '@/models/entities/auth-session.js';
+import { awaitAll } from '@/prelude/await-all.js';
+import { User } from '@/models/entities/user.js';
@EntityRepository(AuthSession)
export class AuthSessionRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/blocking.ts b/packages/backend/src/models/repositories/blocking.ts
index c20b02f50..b155bf944 100644
--- a/packages/backend/src/models/repositories/blocking.ts
+++ b/packages/backend/src/models/repositories/blocking.ts
@@ -1,9 +1,9 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Users } from '../index';
-import { Blocking } from '@/models/entities/blocking';
-import { awaitAll } from '@/prelude/await-all';
-import { Packed } from '@/misc/schema';
-import { User } from '@/models/entities/user';
+import { Users } from '../index.js';
+import { Blocking } from '@/models/entities/blocking.js';
+import { awaitAll } from '@/prelude/await-all.js';
+import { Packed } from '@/misc/schema.js';
+import { User } from '@/models/entities/user.js';
@EntityRepository(Blocking)
export class BlockingRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/channel.ts b/packages/backend/src/models/repositories/channel.ts
index b3afb823a..cc13d7c1e 100644
--- a/packages/backend/src/models/repositories/channel.ts
+++ b/packages/backend/src/models/repositories/channel.ts
@@ -1,8 +1,8 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Channel } from '@/models/entities/channel';
-import { Packed } from '@/misc/schema';
-import { DriveFiles, ChannelFollowings, NoteUnreads } from '../index';
-import { User } from '@/models/entities/user';
+import { Channel } from '@/models/entities/channel.js';
+import { Packed } from '@/misc/schema.js';
+import { DriveFiles, ChannelFollowings, NoteUnreads } from '../index.js';
+import { User } from '@/models/entities/user.js';
@EntityRepository(Channel)
export class ChannelRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/clip.ts b/packages/backend/src/models/repositories/clip.ts
index 6f9ceeb50..9e1979729 100644
--- a/packages/backend/src/models/repositories/clip.ts
+++ b/packages/backend/src/models/repositories/clip.ts
@@ -1,8 +1,8 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Clip } from '@/models/entities/clip';
-import { Packed } from '@/misc/schema';
-import { Users } from '../index';
-import { awaitAll } from '@/prelude/await-all';
+import { Clip } from '@/models/entities/clip.js';
+import { Packed } from '@/misc/schema.js';
+import { Users } from '../index.js';
+import { awaitAll } from '@/prelude/await-all.js';
@EntityRepository(Clip)
export class ClipRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/drive-file.ts b/packages/backend/src/models/repositories/drive-file.ts
index 44db9a0a5..6452632db 100644
--- a/packages/backend/src/models/repositories/drive-file.ts
+++ b/packages/backend/src/models/repositories/drive-file.ts
@@ -1,14 +1,14 @@
import { EntityRepository, Repository } from 'typeorm';
-import { DriveFile } from '@/models/entities/drive-file';
-import { Users, DriveFolders } from '../index';
-import { User } from '@/models/entities/user';
-import { toPuny } from '@/misc/convert-host';
-import { awaitAll, Promiseable } from '@/prelude/await-all';
-import { Packed } from '@/misc/schema';
-import config from '@/config/index';
-import { query, appendQuery } from '@/prelude/url';
-import { Meta } from '@/models/entities/meta';
-import { fetchMeta } from '@/misc/fetch-meta';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { Users, DriveFolders } from '../index.js';
+import { User } from '@/models/entities/user.js';
+import { toPuny } from '@/misc/convert-host.js';
+import { awaitAll, Promiseable } from '@/prelude/await-all.js';
+import { Packed } from '@/misc/schema.js';
+import config from '@/config/index.js';
+import { query, appendQuery } from '@/prelude/url.js';
+import { Meta } from '@/models/entities/meta.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
type PackOptions = {
detail?: boolean,
@@ -41,7 +41,7 @@ export class DriveFileRepository extends Repository {
return file.properties;
}
- public getPublicUrl(file: DriveFile, thumbnail = false, meta?: Meta): string | null {
+ public getPublicUrl(file: DriveFile, thumbnail = false): string | null {
// リモートかつメディアプロキシ
if (file.uri != null && file.userHost != null && config.mediaProxy != null) {
return appendQuery(config.mediaProxy, query({
@@ -51,7 +51,7 @@ export class DriveFileRepository extends Repository {
}
// リモートかつ期限切れはローカルプロキシを試みる
- if (file.uri != null && file.isLink && meta && meta.proxyRemoteFiles) {
+ if (file.uri != null && file.isLink && config.proxyRemoteFiles) {
const key = thumbnail ? file.thumbnailAccessKey : file.webpublicAccessKey;
if (key && !key.match('/')) { // 古いものはここにオブジェクトストレージキーが入ってるので除外
@@ -136,8 +136,8 @@ export class DriveFileRepository extends Repository {
isSensitive: file.isSensitive,
blurhash: file.blurhash,
properties: opts.self ? file.properties : this.getPublicProperties(file),
- url: opts.self ? file.url : this.getPublicUrl(file, false, meta),
- thumbnailUrl: this.getPublicUrl(file, true, meta),
+ url: opts.self ? file.url : this.getPublicUrl(file, false),
+ thumbnailUrl: this.getPublicUrl(file, true),
comment: file.comment,
folderId: file.folderId,
folder: opts.detail && file.folderId ? DriveFolders.pack(file.folderId, {
diff --git a/packages/backend/src/models/repositories/drive-folder.ts b/packages/backend/src/models/repositories/drive-folder.ts
index b2e6cee9b..b0e09eedf 100644
--- a/packages/backend/src/models/repositories/drive-folder.ts
+++ b/packages/backend/src/models/repositories/drive-folder.ts
@@ -1,18 +1,11 @@
import { EntityRepository, Repository } from 'typeorm';
-import { DriveFolders, DriveFiles } from '../index';
-import { DriveFolder } from '@/models/entities/drive-folder';
-import { awaitAll } from '@/prelude/await-all';
-import { Packed } from '@/misc/schema';
+import { DriveFolders, DriveFiles } from '../index.js';
+import { DriveFolder } from '@/models/entities/drive-folder.js';
+import { awaitAll } from '@/prelude/await-all.js';
+import { Packed } from '@/misc/schema.js';
@EntityRepository(DriveFolder)
export class DriveFolderRepository extends Repository {
- public validateFolderName(name: string): boolean {
- return (
- (name.trim().length > 0) &&
- (name.length <= 200)
- );
- }
-
public async pack(
src: DriveFolder['id'] | DriveFolder,
options?: {
diff --git a/packages/backend/src/models/repositories/emoji.ts b/packages/backend/src/models/repositories/emoji.ts
index b9dc6ed0a..3b13832a3 100644
--- a/packages/backend/src/models/repositories/emoji.ts
+++ b/packages/backend/src/models/repositories/emoji.ts
@@ -1,6 +1,6 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Emoji } from '@/models/entities/emoji';
-import { Packed } from '@/misc/schema';
+import { Emoji } from '@/models/entities/emoji.js';
+import { Packed } from '@/misc/schema.js';
@EntityRepository(Emoji)
export class EmojiRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/federation-instance.ts b/packages/backend/src/models/repositories/federation-instance.ts
deleted file mode 100644
index 426fd5bfc..000000000
--- a/packages/backend/src/models/repositories/federation-instance.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-import config from '@/config/index';
-
diff --git a/packages/backend/src/models/repositories/follow-request.ts b/packages/backend/src/models/repositories/follow-request.ts
index d6ee58e23..1da1f875e 100644
--- a/packages/backend/src/models/repositories/follow-request.ts
+++ b/packages/backend/src/models/repositories/follow-request.ts
@@ -1,7 +1,7 @@
import { EntityRepository, Repository } from 'typeorm';
-import { FollowRequest } from '@/models/entities/follow-request';
-import { Users } from '../index';
-import { User } from '@/models/entities/user';
+import { FollowRequest } from '@/models/entities/follow-request.js';
+import { Users } from '../index.js';
+import { User } from '@/models/entities/user.js';
@EntityRepository(FollowRequest)
export class FollowRequestRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/following.ts b/packages/backend/src/models/repositories/following.ts
index 9d20f442d..f25289d19 100644
--- a/packages/backend/src/models/repositories/following.ts
+++ b/packages/backend/src/models/repositories/following.ts
@@ -1,9 +1,9 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Users } from '../index';
-import { Following } from '@/models/entities/following';
-import { awaitAll } from '@/prelude/await-all';
-import { Packed } from '@/misc/schema';
-import { User } from '@/models/entities/user';
+import { Users } from '../index.js';
+import { Following } from '@/models/entities/following.js';
+import { awaitAll } from '@/prelude/await-all.js';
+import { Packed } from '@/misc/schema.js';
+import { User } from '@/models/entities/user.js';
type LocalFollowerFollowing = Following & {
followerHost: null;
diff --git a/packages/backend/src/models/repositories/gallery-like.ts b/packages/backend/src/models/repositories/gallery-like.ts
index 79123e5ee..545186fa1 100644
--- a/packages/backend/src/models/repositories/gallery-like.ts
+++ b/packages/backend/src/models/repositories/gallery-like.ts
@@ -1,6 +1,6 @@
import { EntityRepository, Repository } from 'typeorm';
-import { GalleryLike } from '@/models/entities/gallery-like';
-import { GalleryPosts } from '../index';
+import { GalleryLike } from '@/models/entities/gallery-like.js';
+import { GalleryPosts } from '../index.js';
@EntityRepository(GalleryLike)
export class GalleryLikeRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/gallery-post.ts b/packages/backend/src/models/repositories/gallery-post.ts
index e9233bb91..bbb036dd0 100644
--- a/packages/backend/src/models/repositories/gallery-post.ts
+++ b/packages/backend/src/models/repositories/gallery-post.ts
@@ -1,9 +1,9 @@
import { EntityRepository, Repository } from 'typeorm';
-import { GalleryPost } from '@/models/entities/gallery-post';
-import { Packed } from '@/misc/schema';
-import { Users, DriveFiles, GalleryLikes } from '../index';
-import { awaitAll } from '@/prelude/await-all';
-import { User } from '@/models/entities/user';
+import { GalleryPost } from '@/models/entities/gallery-post.js';
+import { Packed } from '@/misc/schema.js';
+import { Users, DriveFiles, GalleryLikes } from '../index.js';
+import { awaitAll } from '@/prelude/await-all.js';
+import { User } from '@/models/entities/user.js';
@EntityRepository(GalleryPost)
export class GalleryPostRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/hashtag.ts b/packages/backend/src/models/repositories/hashtag.ts
index c4b8d50c4..0548e19ee 100644
--- a/packages/backend/src/models/repositories/hashtag.ts
+++ b/packages/backend/src/models/repositories/hashtag.ts
@@ -1,6 +1,6 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Hashtag } from '@/models/entities/hashtag';
-import { Packed } from '@/misc/schema';
+import { Hashtag } from '@/models/entities/hashtag.js';
+import { Packed } from '@/misc/schema.js';
@EntityRepository(Hashtag)
export class HashtagRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/instance.ts b/packages/backend/src/models/repositories/instance.ts
new file mode 100644
index 000000000..358e055aa
--- /dev/null
+++ b/packages/backend/src/models/repositories/instance.ts
@@ -0,0 +1,39 @@
+import { EntityRepository, Repository } from 'typeorm';
+import { Instance } from '@/models/entities/instance.js';
+import { Packed } from '@/misc/schema.js';
+
+@EntityRepository(Instance)
+export class InstanceRepository extends Repository {
+ public async pack(
+ instance: Instance,
+ ): Promise> {
+ 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)));
+ }
+}
diff --git a/packages/backend/src/models/repositories/messaging-message.ts b/packages/backend/src/models/repositories/messaging-message.ts
index 0a342430b..3f5170700 100644
--- a/packages/backend/src/models/repositories/messaging-message.ts
+++ b/packages/backend/src/models/repositories/messaging-message.ts
@@ -1,15 +1,11 @@
import { EntityRepository, Repository } from 'typeorm';
-import { MessagingMessage } from '@/models/entities/messaging-message';
-import { Users, DriveFiles, UserGroups } from '../index';
-import { Packed } from '@/misc/schema';
-import { User } from '@/models/entities/user';
+import { MessagingMessage } from '@/models/entities/messaging-message.js';
+import { Users, DriveFiles, UserGroups } from '../index.js';
+import { Packed } from '@/misc/schema.js';
+import { User } from '@/models/entities/user.js';
@EntityRepository(MessagingMessage)
export class MessagingMessageRepository extends Repository {
- public validateText(text: string): boolean {
- return text.trim().length <= 1000 && text.trim() != '';
- }
-
public async pack(
src: MessagingMessage['id'] | MessagingMessage,
me?: { id: User['id'] } | null | undefined,
diff --git a/packages/backend/src/models/repositories/moderation-logs.ts b/packages/backend/src/models/repositories/moderation-logs.ts
index f530613bc..ea7810496 100644
--- a/packages/backend/src/models/repositories/moderation-logs.ts
+++ b/packages/backend/src/models/repositories/moderation-logs.ts
@@ -1,7 +1,7 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Users } from '../index';
-import { ModerationLog } from '@/models/entities/moderation-log';
-import { awaitAll } from '@/prelude/await-all';
+import { Users } from '../index.js';
+import { ModerationLog } from '@/models/entities/moderation-log.js';
+import { awaitAll } from '@/prelude/await-all.js';
@EntityRepository(ModerationLog)
export class ModerationLogRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/muting.ts b/packages/backend/src/models/repositories/muting.ts
index bdbe9b47d..643e0b68e 100644
--- a/packages/backend/src/models/repositories/muting.ts
+++ b/packages/backend/src/models/repositories/muting.ts
@@ -1,9 +1,9 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Users } from '../index';
-import { Muting } from '@/models/entities/muting';
-import { awaitAll } from '@/prelude/await-all';
-import { Packed } from '@/misc/schema';
-import { User } from '@/models/entities/user';
+import { Users } from '../index.js';
+import { Muting } from '@/models/entities/muting.js';
+import { awaitAll } from '@/prelude/await-all.js';
+import { Packed } from '@/misc/schema.js';
+import { User } from '@/models/entities/user.js';
@EntityRepository(Muting)
export class MutingRepository extends Repository {
@@ -16,6 +16,7 @@ export class MutingRepository extends Repository {
return await awaitAll({
id: muting.id,
createdAt: muting.createdAt.toISOString(),
+ expiresAt: muting.expiresAt ? muting.expiresAt.toISOString() : null,
muteeId: muting.muteeId,
mutee: Users.pack(muting.muteeId, me, {
detail: true,
diff --git a/packages/backend/src/models/repositories/note-favorite.ts b/packages/backend/src/models/repositories/note-favorite.ts
index f4cd64e39..d7a7925eb 100644
--- a/packages/backend/src/models/repositories/note-favorite.ts
+++ b/packages/backend/src/models/repositories/note-favorite.ts
@@ -1,7 +1,7 @@
import { EntityRepository, Repository } from 'typeorm';
-import { NoteFavorite } from '@/models/entities/note-favorite';
-import { Notes } from '../index';
-import { User } from '@/models/entities/user';
+import { NoteFavorite } from '@/models/entities/note-favorite.js';
+import { Notes } from '../index.js';
+import { User } from '@/models/entities/user.js';
@EntityRepository(NoteFavorite)
export class NoteFavoriteRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/note-reaction.ts b/packages/backend/src/models/repositories/note-reaction.ts
index 097574eff..a212b0d3e 100644
--- a/packages/backend/src/models/repositories/note-reaction.ts
+++ b/packages/backend/src/models/repositories/note-reaction.ts
@@ -1,9 +1,9 @@
import { EntityRepository, Repository } from 'typeorm';
-import { NoteReaction } from '@/models/entities/note-reaction';
-import { Notes, Users } from '../index';
-import { Packed } from '@/misc/schema';
-import { convertLegacyReaction } from '@/misc/reaction-lib';
-import { User } from '@/models/entities/user';
+import { NoteReaction } from '@/models/entities/note-reaction.js';
+import { Notes, Users } from '../index.js';
+import { Packed } from '@/misc/schema.js';
+import { convertLegacyReaction } from '@/misc/reaction-lib.js';
+import { User } from '@/models/entities/user.js';
@EntityRepository(NoteReaction)
export class NoteReactionRepository extends Repository {
@@ -23,10 +23,10 @@ export class NoteReactionRepository extends Repository {
return {
id: reaction.id,
createdAt: reaction.createdAt.toISOString(),
- user: await Users.pack(reaction.userId, me),
+ user: await Users.pack(reaction.user ?? reaction.userId, me),
type: convertLegacyReaction(reaction.reaction),
...(opts.withNote ? {
- note: await Notes.pack(reaction.noteId, me),
+ note: await Notes.pack(reaction.note ?? reaction.noteId, me),
} : {}),
};
}
diff --git a/packages/backend/src/models/repositories/note.ts b/packages/backend/src/models/repositories/note.ts
index 9a7fef497..418d6e234 100644
--- a/packages/backend/src/models/repositories/note.ts
+++ b/packages/backend/src/models/repositories/note.ts
@@ -1,21 +1,17 @@
import { EntityRepository, Repository, In } from 'typeorm';
import * as mfm from 'mfm-js';
-import { Note } from '@/models/entities/note';
-import { User } from '@/models/entities/user';
-import { Users, PollVotes, DriveFiles, NoteReactions, Followings, Polls, Channels } from '../index';
-import { Packed } from '@/misc/schema';
-import { nyaize } from '@/misc/nyaize';
-import { awaitAll } from '@/prelude/await-all';
-import { convertLegacyReaction, convertLegacyReactions, decodeReaction } from '@/misc/reaction-lib';
-import { NoteReaction } from '@/models/entities/note-reaction';
-import { aggregateNoteEmojis, populateEmojis, prefetchEmojis } from '@/misc/populate-emojis';
+import { Note } from '@/models/entities/note.js';
+import { User } from '@/models/entities/user.js';
+import { Users, PollVotes, DriveFiles, NoteReactions, Followings, Polls, Channels } from '../index.js';
+import { Packed } from '@/misc/schema.js';
+import { nyaize } from '@/misc/nyaize.js';
+import { awaitAll } from '@/prelude/await-all.js';
+import { convertLegacyReaction, convertLegacyReactions, decodeReaction } from '@/misc/reaction-lib.js';
+import { NoteReaction } from '@/models/entities/note-reaction.js';
+import { aggregateNoteEmojis, populateEmojis, prefetchEmojis } from '@/misc/populate-emojis.js';
@EntityRepository(Note)
export class NoteRepository extends Repository {
- public validateCw(x: string) {
- return x.trim().length <= 100;
- }
-
public async isVisibleForMe(note: Note, meId: User['id'] | null): Promise {
// visibility が specified かつ自分が指定されていなかったら非表示
if (note.visibility === 'specified') {
@@ -206,8 +202,8 @@ export class NoteRepository extends Repository {
let text = note.text;
- if (note.name && (note.url || note.uri)) {
- text = `【${note.name}】\n${(note.text || '').trim()}\n\n${note.url || note.uri}`;
+ if (note.name && (note.url ?? note.uri)) {
+ text = `【${note.name}】\n${(note.text || '').trim()}\n\n${note.url ?? note.uri}`;
}
const channel = note.channelId
@@ -222,7 +218,7 @@ export class NoteRepository extends Repository {
id: note.id,
createdAt: note.createdAt.toISOString(),
userId: note.userId,
- user: Users.pack(note.user || note.userId, me, {
+ user: Users.pack(note.user ?? note.userId, me, {
detail: false,
}),
text: text,
diff --git a/packages/backend/src/models/repositories/notification.ts b/packages/backend/src/models/repositories/notification.ts
index 5e4279889..8e72d8aab 100644
--- a/packages/backend/src/models/repositories/notification.ts
+++ b/packages/backend/src/models/repositories/notification.ts
@@ -1,13 +1,13 @@
import { EntityRepository, In, Repository } from 'typeorm';
-import { Users, Notes, UserGroupInvitations, AccessTokens, NoteReactions } from '../index';
-import { Notification } from '@/models/entities/notification';
-import { awaitAll } from '@/prelude/await-all';
-import { Packed } from '@/misc/schema';
-import { Note } from '@/models/entities/note';
-import { NoteReaction } from '@/models/entities/note-reaction';
-import { User } from '@/models/entities/user';
-import { aggregateNoteEmojis, prefetchEmojis } from '@/misc/populate-emojis';
-import { notificationTypes } from '@/types';
+import { Users, Notes, UserGroupInvitations, AccessTokens, NoteReactions } from '../index.js';
+import { Notification } from '@/models/entities/notification.js';
+import { awaitAll } from '@/prelude/await-all.js';
+import { Packed } from '@/misc/schema.js';
+import { Note } from '@/models/entities/note.js';
+import { NoteReaction } from '@/models/entities/note-reaction.js';
+import { User } from '@/models/entities/user.js';
+import { aggregateNoteEmojis, prefetchEmojis } from '@/misc/populate-emojis.js';
+import { notificationTypes } from '@/types.js';
@EntityRepository(Notification)
export class NotificationRepository extends Repository {
@@ -67,6 +67,12 @@ export class NotificationRepository extends Repository {
}),
choice: notification.choice,
} : {}),
+ ...(notification.type === 'pollEnded' ? {
+ note: Notes.pack(notification.note || notification.noteId!, { id: notification.notifieeId }, {
+ detail: true,
+ _hint_: options._hintForEachNotes_,
+ }),
+ } : {}),
...(notification.type === 'groupInvited' ? {
invitation: UserGroupInvitations.pack(notification.userGroupInvitationId!),
} : {}),
diff --git a/packages/backend/src/models/repositories/page-like.ts b/packages/backend/src/models/repositories/page-like.ts
index 28f34254d..66d780584 100644
--- a/packages/backend/src/models/repositories/page-like.ts
+++ b/packages/backend/src/models/repositories/page-like.ts
@@ -1,7 +1,7 @@
import { EntityRepository, Repository } from 'typeorm';
-import { PageLike } from '@/models/entities/page-like';
-import { Pages } from '../index';
-import { User } from '@/models/entities/user';
+import { PageLike } from '@/models/entities/page-like.js';
+import { Pages } from '../index.js';
+import { User } from '@/models/entities/user.js';
@EntityRepository(PageLike)
export class PageLikeRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/page.ts b/packages/backend/src/models/repositories/page.ts
index ec76c2e41..037c13c43 100644
--- a/packages/backend/src/models/repositories/page.ts
+++ b/packages/backend/src/models/repositories/page.ts
@@ -1,10 +1,10 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Page } from '@/models/entities/page';
-import { Packed } from '@/misc/schema';
-import { Users, DriveFiles, PageLikes } from '../index';
-import { awaitAll } from '@/prelude/await-all';
-import { DriveFile } from '@/models/entities/drive-file';
-import { User } from '@/models/entities/user';
+import { Page } from '@/models/entities/page.js';
+import { Packed } from '@/misc/schema.js';
+import { Users, DriveFiles, PageLikes } from '../index.js';
+import { awaitAll } from '@/prelude/await-all.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { User } from '@/models/entities/user.js';
@EntityRepository(Page)
export class PageRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/relay.ts b/packages/backend/src/models/repositories/relay.ts
index 72ead899f..160ca60f7 100644
--- a/packages/backend/src/models/repositories/relay.ts
+++ b/packages/backend/src/models/repositories/relay.ts
@@ -1,5 +1,5 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Relay } from '@/models/entities/relay';
+import { Relay } from '@/models/entities/relay.js';
@EntityRepository(Relay)
export class RelayRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/signin.ts b/packages/backend/src/models/repositories/signin.ts
index f375f9b5c..a0e2ce152 100644
--- a/packages/backend/src/models/repositories/signin.ts
+++ b/packages/backend/src/models/repositories/signin.ts
@@ -1,5 +1,5 @@
import { EntityRepository, Repository } from 'typeorm';
-import { Signin } from '@/models/entities/signin';
+import { Signin } from '@/models/entities/signin.js';
@EntityRepository(Signin)
export class SigninRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/user-group-invitation.ts b/packages/backend/src/models/repositories/user-group-invitation.ts
index 638603d6e..e338242c6 100644
--- a/packages/backend/src/models/repositories/user-group-invitation.ts
+++ b/packages/backend/src/models/repositories/user-group-invitation.ts
@@ -1,6 +1,6 @@
import { EntityRepository, Repository } from 'typeorm';
-import { UserGroupInvitation } from '@/models/entities/user-group-invitation';
-import { UserGroups } from '../index';
+import { UserGroupInvitation } from '@/models/entities/user-group-invitation.js';
+import { UserGroups } from '../index.js';
@EntityRepository(UserGroupInvitation)
export class UserGroupInvitationRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/user-group.ts b/packages/backend/src/models/repositories/user-group.ts
index 3ed37ca0e..a9ffe7369 100644
--- a/packages/backend/src/models/repositories/user-group.ts
+++ b/packages/backend/src/models/repositories/user-group.ts
@@ -1,7 +1,7 @@
import { EntityRepository, Repository } from 'typeorm';
-import { UserGroup } from '@/models/entities/user-group';
-import { UserGroupJoinings } from '../index';
-import { Packed } from '@/misc/schema';
+import { UserGroup } from '@/models/entities/user-group.js';
+import { UserGroupJoinings } from '../index.js';
+import { Packed } from '@/misc/schema.js';
@EntityRepository(UserGroup)
export class UserGroupRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/user-list.ts b/packages/backend/src/models/repositories/user-list.ts
index a2bffe835..0ea26427f 100644
--- a/packages/backend/src/models/repositories/user-list.ts
+++ b/packages/backend/src/models/repositories/user-list.ts
@@ -1,7 +1,7 @@
import { EntityRepository, Repository } from 'typeorm';
-import { UserList } from '@/models/entities/user-list';
-import { UserListJoinings } from '../index';
-import { Packed } from '@/misc/schema';
+import { UserList } from '@/models/entities/user-list.js';
+import { UserListJoinings } from '../index.js';
+import { Packed } from '@/misc/schema.js';
@EntityRepository(UserList)
export class UserListRepository extends Repository {
diff --git a/packages/backend/src/models/repositories/user.ts b/packages/backend/src/models/repositories/user.ts
index 33b2b32fe..a909ab3ba 100644
--- a/packages/backend/src/models/repositories/user.ts
+++ b/packages/backend/src/models/repositories/user.ts
@@ -1,13 +1,13 @@
-import $ from 'cafy';
import { EntityRepository, Repository, In, Not } from 'typeorm';
-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 config from '@/config/index';
-import { Packed } from '@/misc/schema';
-import { awaitAll, Promiseable } from '@/prelude/await-all';
-import { populateEmojis } from '@/misc/populate-emojis';
-import { getAntennas } from '@/misc/antenna-cache';
-import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const';
+import Ajv from 'ajv';
+import { User, ILocalUser, IRemoteUser } from '@/models/entities/user.js';
+import { Notes, NoteUnreads, FollowRequests, Notifications, MessagingMessages, UserNotePinings, Followings, Blockings, Mutings, UserProfiles, UserSecurityKeys, UserGroupJoinings, Pages, Announcements, AnnouncementReads, Antennas, AntennaNotes, ChannelFollowings, Instances, DriveFiles } from '../index.js';
+import config from '@/config/index.js';
+import { Packed } from '@/misc/schema.js';
+import { awaitAll, Promiseable } from '@/prelude/await-all.js';
+import { populateEmojis } from '@/misc/populate-emojis.js';
+import { getAntennas } from '@/misc/antenna-cache.js';
+import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const.js';
type IsUserDetailed = Detailed extends true ? Packed<'UserDetailed'> : Packed<'UserLite'>;
type IsMeAndIsUserDetailed =
@@ -17,8 +17,26 @@ type IsMeAndIsUserDetailed :
Packed<'UserLite'>;
+const ajv = new Ajv();
+
@EntityRepository(User)
export class UserRepository extends Repository {
+ 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']) {
const [following1, following2, followReq1, followReq2, toBlocking, fromBlocked, mute] = await Promise.all([
Followings.findOne({
@@ -164,13 +182,18 @@ export class UserRepository extends Repository {
}
public getAvatarUrl(user: User): string {
- if (user.avatarUrl) {
- return user.avatarUrl;
+ // TODO: avatarIdがあるがavatarがない(JOINされてない)場合のハンドリング
+ if (user.avatar) {
+ return DriveFiles.getPublicUrl(user.avatar, true) || this.getIdenticonUrl(user.id);
} else {
- return `${config.url}/identicon/${user.id}`;
+ return this.getIdenticonUrl(user.id);
}
}
+ public getIdenticonUrl(userId: User['id']): string {
+ return `${config.url}/identicon/${userId}`;
+ }
+
public async pack(
src: User['id'] | User,
me?: { id: User['id'] } | null | undefined,
@@ -184,7 +207,18 @@ export class UserRepository extends Repository {
includeSecrets: false,
}, options);
- const user = typeof src === 'object' ? src : await this.findOneOrFail(src);
+ let user: User;
+
+ if (typeof src === 'object') {
+ user = src;
+ if (src.avatar === undefined && src.avatarId) src.avatar = await DriveFiles.findOne(src.avatarId) ?? null;
+ if (src.banner === undefined && src.bannerId) src.banner = await DriveFiles.findOne(src.bannerId) ?? null;
+ } else {
+ user = await this.findOneOrFail(src, {
+ relations: ['avatar', 'banner'],
+ });
+ }
+
const meId = me ? me.id : null;
const isMe = meId === user.id;
@@ -214,7 +248,7 @@ export class UserRepository extends Repository {
username: user.username,
host: user.host,
avatarUrl: this.getAvatarUrl(user),
- avatarBlurhash: user.avatarBlurhash,
+ avatarBlurhash: user.avatar?.blurhash || null,
avatarColor: null, // 後方互換性のため
isAdmin: user.isAdmin || falsy,
isModerator: user.isModerator || falsy,
@@ -238,8 +272,8 @@ export class UserRepository extends Repository {
createdAt: user.createdAt.toISOString(),
updatedAt: user.updatedAt ? user.updatedAt.toISOString() : null,
lastFetchedAt: user.lastFetchedAt ? user.lastFetchedAt.toISOString() : null,
- bannerUrl: user.bannerUrl,
- bannerBlurhash: user.bannerBlurhash,
+ bannerUrl: user.banner ? DriveFiles.getPublicUrl(user.banner, false) : null,
+ bannerBlurhash: user.banner?.blurhash || null,
bannerColor: null, // 後方互換性のため
isLocked: user.isLocked,
isSilenced: user.isSilenced || falsy,
@@ -351,13 +385,4 @@ export class UserRepository extends Repository {
public isRemoteUser(user: User | { host: User['host'] }): boolean {
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
}
diff --git a/packages/backend/src/models/schema/federation-instance.ts b/packages/backend/src/models/schema/federation-instance.ts
index eef2f9e24..c4e7b3f18 100644
--- a/packages/backend/src/models/schema/federation-instance.ts
+++ b/packages/backend/src/models/schema/federation-instance.ts
@@ -1,4 +1,4 @@
-import config from "@/config";
+import config from '@/config/index.js';
export const packedFederationInstanceSchema = {
type: 'object',
@@ -34,14 +34,6 @@ export const packedFederationInstanceSchema = {
type: 'number',
optional: false, nullable: false,
},
- driveUsage: {
- type: 'number',
- optional: false, nullable: false,
- },
- driveFiles: {
- type: 'number',
- optional: false, nullable: false,
- },
latestRequestSentAt: {
type: 'string',
optional: false, nullable: true,
diff --git a/packages/backend/src/models/schema/muting.ts b/packages/backend/src/models/schema/muting.ts
index d75a4fbfe..3ab99e17e 100644
--- a/packages/backend/src/models/schema/muting.ts
+++ b/packages/backend/src/models/schema/muting.ts
@@ -12,6 +12,11 @@ export const packedMutingSchema = {
optional: false, nullable: false,
format: 'date-time',
},
+ expiresAt: {
+ type: 'string',
+ optional: false, nullable: true,
+ format: 'date-time',
+ },
muteeId: {
type: 'string',
optional: false, nullable: false,
diff --git a/packages/backend/src/models/schema/notification.ts b/packages/backend/src/models/schema/notification.ts
index f3c293c48..d3f2405cd 100644
--- a/packages/backend/src/models/schema/notification.ts
+++ b/packages/backend/src/models/schema/notification.ts
@@ -1,4 +1,4 @@
-import { notificationTypes } from "@/types";
+import { notificationTypes } from '@/types.js';
export const packedNotificationSchema = {
type: 'object',
diff --git a/packages/backend/src/prelude/array.ts b/packages/backend/src/prelude/array.ts
index 1e9e62b89..0b2830cb7 100644
--- a/packages/backend/src/prelude/array.ts
+++ b/packages/backend/src/prelude/array.ts
@@ -1,4 +1,4 @@
-import { EndoRelation, Predicate } from './relation';
+import { EndoRelation, Predicate } from './relation.js';
/**
* Count the number of elements that satisfy the predicate
diff --git a/packages/backend/src/queue/get-job-info.ts b/packages/backend/src/queue/get-job-info.ts
index f601ae62d..d33e349c3 100644
--- a/packages/backend/src/queue/get-job-info.ts
+++ b/packages/backend/src/queue/get-job-info.ts
@@ -1,4 +1,4 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
export function getJobInfo(job: Bull.Job, increment = false) {
const age = Date.now() - job.timestamp;
diff --git a/packages/backend/src/queue/index.ts b/packages/backend/src/queue/index.ts
index 62f372f3a..50bcccbb7 100644
--- a/packages/backend/src/queue/index.ts
+++ b/packages/backend/src/queue/index.ts
@@ -1,19 +1,20 @@
-import * as httpSignature from 'http-signature';
+import httpSignature from 'http-signature';
-import config from '@/config/index';
-import { envOption } from '../env';
+import config from '@/config/index.js';
+import { envOption } from '../env.js';
-import processDeliver from './processors/deliver';
-import processInbox from './processors/inbox';
-import processDb from './processors/db/index';
-import processObjectStorage from './processors/object-storage/index';
-import processSystemQueue from './processors/system/index';
-import { queueLogger } from './logger';
-import { DriveFile } from '@/models/entities/drive-file';
-import { getJobInfo } from './get-job-info';
-import { systemQueue, dbQueue, deliverQueue, inboxQueue, objectStorageQueue } from './queues';
-import { ThinUser } from './types';
-import { IActivity } from '@/remote/activitypub/type';
+import processDeliver from './processors/deliver.js';
+import processInbox from './processors/inbox.js';
+import processDb from './processors/db/index.js';
+import processObjectStorage from './processors/object-storage/index.js';
+import processSystemQueue from './processors/system/index.js';
+import { endedPollNotification } from './processors/ended-poll-notification.js';
+import { queueLogger } from './logger.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { getJobInfo } from './get-job-info.js';
+import { systemQueue, dbQueue, deliverQueue, inboxQueue, objectStorageQueue, endedPollNotificationQueue } from './queues.js';
+import { ThinUser } from './types.js';
+import { IActivity } from '@/remote/activitypub/type.js';
function renderError(e: Error): any {
return {
@@ -255,6 +256,7 @@ export default function() {
deliverQueue.process(config.deliverJobConcurrency || 128, processDeliver);
inboxQueue.process(config.inboxJobConcurrency || 16, processInbox);
+ endedPollNotificationQueue.process(endedPollNotification);
processDb(dbQueue);
processObjectStorage(objectStorageQueue);
@@ -273,6 +275,11 @@ export default function() {
repeat: { cron: '0 0 * * *' },
});
+ systemQueue.add('checkExpiredMutings', {
+ }, {
+ repeat: { cron: '*/5 * * * *' },
+ });
+
processSystemQueue(systemQueue);
}
diff --git a/packages/backend/src/queue/initialize.ts b/packages/backend/src/queue/initialize.ts
index af9acb3ce..1db118ca9 100644
--- a/packages/backend/src/queue/initialize.ts
+++ b/packages/backend/src/queue/initialize.ts
@@ -1,5 +1,5 @@
-import * as Bull from 'bull';
-import config from '@/config/index';
+import Bull from 'bull';
+import config from '@/config/index.js';
export function initialize(name: string, limitPerSec = -1) {
return new Bull(name, {
diff --git a/packages/backend/src/queue/logger.ts b/packages/backend/src/queue/logger.ts
index f789b9d07..2843a3c26 100644
--- a/packages/backend/src/queue/logger.ts
+++ b/packages/backend/src/queue/logger.ts
@@ -1,3 +1,3 @@
-import Logger from '@/services/logger';
+import Logger from '@/services/logger.js';
export const queueLogger = new Logger('queue', 'orange');
diff --git a/packages/backend/src/queue/processors/db/delete-account.ts b/packages/backend/src/queue/processors/db/delete-account.ts
index 4b620842a..dbc1f16a4 100644
--- a/packages/backend/src/queue/processors/db/delete-account.ts
+++ b/packages/backend/src/queue/processors/db/delete-account.ts
@@ -1,12 +1,12 @@
-import * as Bull from 'bull';
-import { queueLogger } from '../../logger';
-import { DriveFiles, Notes, UserProfiles, Users } from '@/models/index';
-import { DbUserDeleteJobData } from '@/queue/types';
-import { Note } from '@/models/entities/note';
-import { DriveFile } from '@/models/entities/drive-file';
+import Bull from 'bull';
+import { queueLogger } from '../../logger.js';
+import { DriveFiles, Notes, UserProfiles, Users } from '@/models/index.js';
+import { DbUserDeleteJobData } from '@/queue/types.js';
+import { Note } from '@/models/entities/note.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
import { MoreThan } from 'typeorm';
-import { deleteFileSync } from '@/services/drive/delete-file';
-import { sendEmail } from '@/services/send-email';
+import { deleteFileSync } from '@/services/drive/delete-file.js';
+import { sendEmail } from '@/services/send-email.js';
const logger = queueLogger.createSubLogger('delete-account');
@@ -31,7 +31,7 @@ export async function deleteAccount(job: Bull.Job): Promise
order: {
id: 1,
},
- });
+ }) as Note[];
if (notes.length === 0) {
break;
@@ -58,7 +58,7 @@ export async function deleteAccount(job: Bull.Job): Promise
order: {
id: 1,
},
- });
+ }) as DriveFile[];
if (files.length === 0) {
break;
diff --git a/packages/backend/src/queue/processors/db/delete-drive-files.ts b/packages/backend/src/queue/processors/db/delete-drive-files.ts
index d26f5a47c..f6a869985 100644
--- a/packages/backend/src/queue/processors/db/delete-drive-files.ts
+++ b/packages/backend/src/queue/processors/db/delete-drive-files.ts
@@ -1,10 +1,10 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
-import { queueLogger } from '../../logger';
-import { deleteFileSync } from '@/services/drive/delete-file';
-import { Users, DriveFiles } from '@/models/index';
+import { queueLogger } from '../../logger.js';
+import { deleteFileSync } from '@/services/drive/delete-file.js';
+import { Users, DriveFiles } from '@/models/index.js';
import { MoreThan } from 'typeorm';
-import { DbUserJobData } from '@/queue/types';
+import { DbUserJobData } from '@/queue/types.js';
const logger = queueLogger.createSubLogger('delete-drive-files');
diff --git a/packages/backend/src/queue/processors/db/export-blocking.ts b/packages/backend/src/queue/processors/db/export-blocking.ts
index f4de9ce00..83f1ec8fd 100644
--- a/packages/backend/src/queue/processors/db/export-blocking.ts
+++ b/packages/backend/src/queue/processors/db/export-blocking.ts
@@ -1,14 +1,14 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
import * as tmp from 'tmp';
-import * as fs from 'fs';
+import * as fs from 'node:fs';
-import { queueLogger } from '../../logger';
-import { addFile } from '@/services/drive/add-file';
+import { queueLogger } from '../../logger.js';
+import { addFile } from '@/services/drive/add-file.js';
import { format as dateFormat } from 'date-fns';
-import { getFullApAccount } from '@/misc/convert-host';
-import { Users, Blockings } from '@/models/index';
+import { getFullApAccount } from '@/misc/convert-host.js';
+import { Users, Blockings } from '@/models/index.js';
import { MoreThan } from 'typeorm';
-import { DbUserJobData } from '@/queue/types';
+import { DbUserJobData } from '@/queue/types.js';
const logger = queueLogger.createSubLogger('export-blocking');
diff --git a/packages/backend/src/queue/processors/db/export-custom-emojis.ts b/packages/backend/src/queue/processors/db/export-custom-emojis.ts
index 2f7505f15..a65b46cc0 100644
--- a/packages/backend/src/queue/processors/db/export-custom-emojis.ts
+++ b/packages/backend/src/queue/processors/db/export-custom-emojis.ts
@@ -1,17 +1,17 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
import * as tmp from 'tmp';
-import * as fs from 'fs';
+import * as fs from 'node:fs';
import { ulid } from 'ulid';
-const mime = require('mime-types');
-const archiver = require('archiver');
-import { queueLogger } from '../../logger';
-import { addFile } from '@/services/drive/add-file';
+import mime from 'mime-types';
+import archiver from 'archiver';
+import { queueLogger } from '../../logger.js';
+import { addFile } from '@/services/drive/add-file.js';
import { format as dateFormat } from 'date-fns';
-import { Users, Emojis } from '@/models/index';
-import { } from '@/queue/types';
-import { downloadUrl } from '@/misc/download-url';
-import config from '@/config/index';
+import { Users, Emojis } from '@/models/index.js';
+import { } from '@/queue/types.js';
+import { downloadUrl } from '@/misc/download-url.js';
+import config from '@/config/index.js';
const logger = queueLogger.createSubLogger('export-custom-emojis');
@@ -75,7 +75,7 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi
await downloadUrl(emoji.originalUrl, emojiPath);
downloaded = true;
} catch (e) { // TODO: 何度か再試行
- logger.error(e);
+ logger.error(e instanceof Error ? e : new Error(e as string));
}
if (!downloaded) {
diff --git a/packages/backend/src/queue/processors/db/export-following.ts b/packages/backend/src/queue/processors/db/export-following.ts
index 2ac558381..162862180 100644
--- a/packages/backend/src/queue/processors/db/export-following.ts
+++ b/packages/backend/src/queue/processors/db/export-following.ts
@@ -1,15 +1,15 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
import * as tmp from 'tmp';
-import * as fs from 'fs';
+import * as fs from 'node:fs';
-import { queueLogger } from '../../logger';
-import { addFile } from '@/services/drive/add-file';
+import { queueLogger } from '../../logger.js';
+import { addFile } from '@/services/drive/add-file.js';
import { format as dateFormat } from 'date-fns';
-import { getFullApAccount } from '@/misc/convert-host';
-import { Users, Followings, Mutings } from '@/models/index';
+import { getFullApAccount } from '@/misc/convert-host.js';
+import { Users, Followings, Mutings } from '@/models/index.js';
import { In, MoreThan, Not } from 'typeorm';
-import { DbUserJobData } from '@/queue/types';
-import { Following } from '@/models/entities/following';
+import { DbUserJobData } from '@/queue/types.js';
+import { Following } from '@/models/entities/following.js';
const logger = queueLogger.createSubLogger('export-following');
@@ -51,7 +51,7 @@ export async function exportFollowing(job: Bull.Job, done: () =>
order: {
id: 1,
},
- });
+ }) as Following[];
if (followings.length === 0) {
break;
diff --git a/packages/backend/src/queue/processors/db/export-mute.ts b/packages/backend/src/queue/processors/db/export-mute.ts
index 9e917ccbf..9fb144abb 100644
--- a/packages/backend/src/queue/processors/db/export-mute.ts
+++ b/packages/backend/src/queue/processors/db/export-mute.ts
@@ -1,14 +1,14 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
import * as tmp from 'tmp';
-import * as fs from 'fs';
+import * as fs from 'node:fs';
-import { queueLogger } from '../../logger';
-import { addFile } from '@/services/drive/add-file';
+import { queueLogger } from '../../logger.js';
+import { addFile } from '@/services/drive/add-file.js';
import { format as dateFormat } from 'date-fns';
-import { getFullApAccount } from '@/misc/convert-host';
-import { Users, Mutings } from '@/models/index';
-import { MoreThan } from 'typeorm';
-import { DbUserJobData } from '@/queue/types';
+import { getFullApAccount } from '@/misc/convert-host.js';
+import { Users, Mutings } from '@/models/index.js';
+import { IsNull, MoreThan } from 'typeorm';
+import { DbUserJobData } from '@/queue/types.js';
const logger = queueLogger.createSubLogger('export-mute');
@@ -40,6 +40,7 @@ export async function exportMute(job: Bull.Job, done: any): Promi
const mutes = await Mutings.find({
where: {
muterId: user.id,
+ expiresAt: IsNull(),
...(cursor ? { id: MoreThan(cursor) } : {}),
},
take: 100,
diff --git a/packages/backend/src/queue/processors/db/export-notes.ts b/packages/backend/src/queue/processors/db/export-notes.ts
index 0e65cb884..c79679366 100644
--- a/packages/backend/src/queue/processors/db/export-notes.ts
+++ b/packages/backend/src/queue/processors/db/export-notes.ts
@@ -1,15 +1,15 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
import * as tmp from 'tmp';
-import * as fs from 'fs';
+import * as fs from 'node:fs';
-import { queueLogger } from '../../logger';
-import { addFile } from '@/services/drive/add-file';
+import { queueLogger } from '../../logger.js';
+import { addFile } from '@/services/drive/add-file.js';
import { format as dateFormat } from 'date-fns';
-import { Users, Notes, Polls } from '@/models/index';
+import { Users, Notes, Polls } from '@/models/index.js';
import { MoreThan } from 'typeorm';
-import { Note } from '@/models/entities/note';
-import { Poll } from '@/models/entities/poll';
-import { DbUserJobData } from '@/queue/types';
+import { Note } from '@/models/entities/note.js';
+import { Poll } from '@/models/entities/poll.js';
+import { DbUserJobData } from '@/queue/types.js';
const logger = queueLogger.createSubLogger('export-notes');
@@ -62,7 +62,7 @@ export async function exportNotes(job: Bull.Job, done: any): Prom
order: {
id: 1,
},
- });
+ }) as Note[];
if (notes.length === 0) {
job.progress(100);
diff --git a/packages/backend/src/queue/processors/db/export-user-lists.ts b/packages/backend/src/queue/processors/db/export-user-lists.ts
index fcd2ba336..1c04c3678 100644
--- a/packages/backend/src/queue/processors/db/export-user-lists.ts
+++ b/packages/backend/src/queue/processors/db/export-user-lists.ts
@@ -1,14 +1,14 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
import * as tmp from 'tmp';
-import * as fs from 'fs';
+import * as fs from 'node:fs';
-import { queueLogger } from '../../logger';
-import { addFile } from '@/services/drive/add-file';
+import { queueLogger } from '../../logger.js';
+import { addFile } from '@/services/drive/add-file.js';
import { format as dateFormat } from 'date-fns';
-import { getFullApAccount } from '@/misc/convert-host';
-import { Users, UserLists, UserListJoinings } from '@/models/index';
+import { getFullApAccount } from '@/misc/convert-host.js';
+import { Users, UserLists, UserListJoinings } from '@/models/index.js';
import { In } from 'typeorm';
-import { DbUserJobData } from '@/queue/types';
+import { DbUserJobData } from '@/queue/types.js';
const logger = queueLogger.createSubLogger('export-user-lists');
diff --git a/packages/backend/src/queue/processors/db/import-blocking.ts b/packages/backend/src/queue/processors/db/import-blocking.ts
index 42c3cd0a4..857c2629e 100644
--- a/packages/backend/src/queue/processors/db/import-blocking.ts
+++ b/packages/backend/src/queue/processors/db/import-blocking.ts
@@ -1,13 +1,13 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
-import { queueLogger } from '../../logger';
-import * as Acct from 'misskey-js/built/acct';
-import { resolveUser } from '@/remote/resolve-user';
-import { downloadTextFile } from '@/misc/download-text-file';
-import { isSelfHost, toPuny } from '@/misc/convert-host';
-import { Users, DriveFiles, Blockings } from '@/models/index';
-import { DbUserImportJobData } from '@/queue/types';
-import block from '@/services/blocking/create';
+import { queueLogger } from '../../logger.js';
+import * as Acct from '@/misc/acct.js';
+import { resolveUser } from '@/remote/resolve-user.js';
+import { downloadTextFile } from '@/misc/download-text-file.js';
+import { isSelfHost, toPuny } from '@/misc/convert-host.js';
+import { Users, DriveFiles, Blockings } from '@/models/index.js';
+import { DbUserImportJobData } from '@/queue/types.js';
+import block from '@/services/blocking/create.js';
const logger = queueLogger.createSubLogger('import-blocking');
diff --git a/packages/backend/src/queue/processors/db/import-custom-emojis.ts b/packages/backend/src/queue/processors/db/import-custom-emojis.ts
index b6c012653..f862276b4 100644
--- a/packages/backend/src/queue/processors/db/import-custom-emojis.ts
+++ b/packages/backend/src/queue/processors/db/import-custom-emojis.ts
@@ -1,15 +1,15 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
import * as tmp from 'tmp';
-import * as fs from 'fs';
-const unzipper = require('unzipper');
+import * as fs from 'node:fs';
+import unzipper from 'unzipper';
import { getConnection } from 'typeorm';
-import { queueLogger } from '../../logger';
-import { downloadUrl } from '@/misc/download-url';
-import { DriveFiles, Emojis } from '@/models/index';
-import { DbUserImportJobData } from '@/queue/types';
-import { addFile } from '@/services/drive/add-file';
-import { genId } from '@/misc/gen-id';
+import { queueLogger } from '../../logger.js';
+import { downloadUrl } from '@/misc/download-url.js';
+import { DriveFiles, Emojis } from '@/models/index.js';
+import { DbUserImportJobData } from '@/queue/types.js';
+import { addFile } from '@/services/drive/add-file.js';
+import { genId } from '@/misc/gen-id.js';
const logger = queueLogger.createSubLogger('import-custom-emojis');
diff --git a/packages/backend/src/queue/processors/db/import-following.ts b/packages/backend/src/queue/processors/db/import-following.ts
index f19296832..235fc2839 100644
--- a/packages/backend/src/queue/processors/db/import-following.ts
+++ b/packages/backend/src/queue/processors/db/import-following.ts
@@ -1,13 +1,13 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
-import { queueLogger } from '../../logger';
-import follow from '@/services/following/create';
-import * as Acct from 'misskey-js/built/acct';
-import { resolveUser } from '@/remote/resolve-user';
-import { downloadTextFile } from '@/misc/download-text-file';
-import { isSelfHost, toPuny } from '@/misc/convert-host';
-import { Users, DriveFiles } from '@/models/index';
-import { DbUserImportJobData } from '@/queue/types';
+import { queueLogger } from '../../logger.js';
+import follow from '@/services/following/create.js';
+import * as Acct from '@/misc/acct.js';
+import { resolveUser } from '@/remote/resolve-user.js';
+import { downloadTextFile } from '@/misc/download-text-file.js';
+import { isSelfHost, toPuny } from '@/misc/convert-host.js';
+import { Users, DriveFiles } from '@/models/index.js';
+import { DbUserImportJobData } from '@/queue/types.js';
const logger = queueLogger.createSubLogger('import-following');
diff --git a/packages/backend/src/queue/processors/db/import-muting.ts b/packages/backend/src/queue/processors/db/import-muting.ts
index 189740c29..32f5f6bbe 100644
--- a/packages/backend/src/queue/processors/db/import-muting.ts
+++ b/packages/backend/src/queue/processors/db/import-muting.ts
@@ -1,14 +1,14 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
-import { queueLogger } from '../../logger';
-import * as Acct from 'misskey-js/built/acct';
-import { resolveUser } from '@/remote/resolve-user';
-import { downloadTextFile } from '@/misc/download-text-file';
-import { isSelfHost, toPuny } from '@/misc/convert-host';
-import { Users, DriveFiles, Mutings } from '@/models/index';
-import { DbUserImportJobData } from '@/queue/types';
-import { User } from '@/models/entities/user';
-import { genId } from '@/misc/gen-id';
+import { queueLogger } from '../../logger.js';
+import * as Acct from '@/misc/acct.js';
+import { resolveUser } from '@/remote/resolve-user.js';
+import { downloadTextFile } from '@/misc/download-text-file.js';
+import { isSelfHost, toPuny } from '@/misc/convert-host.js';
+import { Users, DriveFiles, Mutings } from '@/models/index.js';
+import { DbUserImportJobData } from '@/queue/types.js';
+import { User } from '@/models/entities/user.js';
+import { genId } from '@/misc/gen-id.js';
const logger = queueLogger.createSubLogger('import-muting');
diff --git a/packages/backend/src/queue/processors/db/import-user-lists.ts b/packages/backend/src/queue/processors/db/import-user-lists.ts
index 9b3c0ed60..ae263e19b 100644
--- a/packages/backend/src/queue/processors/db/import-user-lists.ts
+++ b/packages/backend/src/queue/processors/db/import-user-lists.ts
@@ -1,14 +1,14 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
-import { queueLogger } from '../../logger';
-import * as Acct from 'misskey-js/built/acct';
-import { resolveUser } from '@/remote/resolve-user';
-import { pushUserToUserList } from '@/services/user-list/push';
-import { downloadTextFile } from '@/misc/download-text-file';
-import { isSelfHost, toPuny } from '@/misc/convert-host';
-import { DriveFiles, Users, UserLists, UserListJoinings } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { DbUserImportJobData } from '@/queue/types';
+import { queueLogger } from '../../logger.js';
+import * as Acct from '@/misc/acct.js';
+import { resolveUser } from '@/remote/resolve-user.js';
+import { pushUserToUserList } from '@/services/user-list/push.js';
+import { downloadTextFile } from '@/misc/download-text-file.js';
+import { isSelfHost, toPuny } from '@/misc/convert-host.js';
+import { DriveFiles, Users, UserLists, UserListJoinings } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { DbUserImportJobData } from '@/queue/types.js';
const logger = queueLogger.createSubLogger('import-user-lists');
diff --git a/packages/backend/src/queue/processors/db/index.ts b/packages/backend/src/queue/processors/db/index.ts
index 5fffa378f..e91d56977 100644
--- a/packages/backend/src/queue/processors/db/index.ts
+++ b/packages/backend/src/queue/processors/db/index.ts
@@ -1,18 +1,18 @@
-import * as Bull from 'bull';
-import { DbJobData } from '@/queue/types';
-import { deleteDriveFiles } from './delete-drive-files';
-import { exportCustomEmojis } from './export-custom-emojis';
-import { exportNotes } from './export-notes';
-import { exportFollowing } from './export-following';
-import { exportMute } from './export-mute';
-import { exportBlocking } from './export-blocking';
-import { exportUserLists } from './export-user-lists';
-import { importFollowing } from './import-following';
-import { importUserLists } from './import-user-lists';
-import { deleteAccount } from './delete-account';
-import { importMuting } from './import-muting';
-import { importBlocking } from './import-blocking';
-import { importCustomEmojis } from './import-custom-emojis';
+import Bull from 'bull';
+import { DbJobData } from '@/queue/types.js';
+import { deleteDriveFiles } from './delete-drive-files.js';
+import { exportCustomEmojis } from './export-custom-emojis.js';
+import { exportNotes } from './export-notes.js';
+import { exportFollowing } from './export-following.js';
+import { exportMute } from './export-mute.js';
+import { exportBlocking } from './export-blocking.js';
+import { exportUserLists } from './export-user-lists.js';
+import { importFollowing } from './import-following.js';
+import { importUserLists } from './import-user-lists.js';
+import { deleteAccount } from './delete-account.js';
+import { importMuting } from './import-muting.js';
+import { importBlocking } from './import-blocking.js';
+import { importCustomEmojis } from './import-custom-emojis.js';
const jobs = {
deleteDriveFiles,
diff --git a/packages/backend/src/queue/processors/deliver.ts b/packages/backend/src/queue/processors/deliver.ts
index bd91dfc3b..291c05766 100644
--- a/packages/backend/src/queue/processors/deliver.ts
+++ b/packages/backend/src/queue/processors/deliver.ts
@@ -1,17 +1,17 @@
-import { URL } from 'url';
-import * as Bull from 'bull';
-import request from '@/remote/activitypub/request';
-import { registerOrFetchInstanceDoc } from '@/services/register-or-fetch-instance-doc';
-import Logger from '@/services/logger';
-import { Instances } from '@/models/index';
-import { apRequestChart, federationChart, instanceChart } from '@/services/chart/index';
-import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { toPuny } from '@/misc/convert-host';
-import { Cache } from '@/misc/cache';
-import { Instance } from '@/models/entities/instance';
-import { DeliverJobData } from '../types';
-import { StatusError } from '@/misc/fetch';
+import { URL } from 'node:url';
+import Bull from 'bull';
+import request from '@/remote/activitypub/request.js';
+import { registerOrFetchInstanceDoc } from '@/services/register-or-fetch-instance-doc.js';
+import Logger from '@/services/logger.js';
+import { Instances } from '@/models/index.js';
+import { apRequestChart, federationChart, instanceChart } from '@/services/chart/index.js';
+import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { toPuny } from '@/misc/convert-host.js';
+import { Cache } from '@/misc/cache.js';
+import { Instance } from '@/models/entities/instance.js';
+import { DeliverJobData } from '../types.js';
+import { StatusError } from '@/misc/fetch.js';
const logger = new Logger('deliver');
diff --git a/packages/backend/src/queue/processors/ended-poll-notification.ts b/packages/backend/src/queue/processors/ended-poll-notification.ts
new file mode 100644
index 000000000..afac27921
--- /dev/null
+++ b/packages/backend/src/queue/processors/ended-poll-notification.ts
@@ -0,0 +1,33 @@
+import Bull from 'bull';
+import { In } from 'typeorm';
+import { Notes, Polls, PollVotes } from '@/models/index.js';
+import { queueLogger } from '../logger.js';
+import { EndedPollNotificationJobData } from '@/queue/types.js';
+import { createNotification } from '@/services/create-notification.js';
+
+const logger = queueLogger.createSubLogger('ended-poll-notification');
+
+export async function endedPollNotification(job: Bull.Job, done: any): Promise {
+ const note = await Notes.findOne(job.data.noteId);
+ if (note == null || !note.hasPoll) {
+ done();
+ return;
+ }
+
+ const votes = await PollVotes.createQueryBuilder('vote')
+ .select('vote.userId')
+ .where('vote.noteId = :noteId', { noteId: note.id })
+ .innerJoinAndSelect('vote.user', 'user')
+ .andWhere('user.host IS NULL')
+ .getMany();
+
+ const userIds = [...new Set([note.userId, ...votes.map(v => v.userId)])];
+
+ for (const userId of userIds) {
+ createNotification(userId, 'pollEnded', {
+ noteId: note.id,
+ });
+ }
+
+ done();
+}
diff --git a/packages/backend/src/queue/processors/inbox.ts b/packages/backend/src/queue/processors/inbox.ts
index c189256c3..1b3f94b70 100644
--- a/packages/backend/src/queue/processors/inbox.ts
+++ b/packages/backend/src/queue/processors/inbox.ts
@@ -1,20 +1,20 @@
-import { URL } from 'url';
-import * as Bull from 'bull';
-import * as httpSignature from 'http-signature';
-import perform from '@/remote/activitypub/perform';
-import Logger from '@/services/logger';
-import { registerOrFetchInstanceDoc } from '@/services/register-or-fetch-instance-doc';
-import { Instances } from '@/models/index';
-import { apRequestChart, federationChart, instanceChart } from '@/services/chart/index';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { toPuny, extractDbHost } from '@/misc/convert-host';
-import { getApId } from '@/remote/activitypub/type';
-import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata';
-import { InboxJobData } from '../types';
-import DbResolver from '@/remote/activitypub/db-resolver';
-import { resolvePerson } from '@/remote/activitypub/models/person';
-import { LdSignature } from '@/remote/activitypub/misc/ld-signature';
-import { StatusError } from '@/misc/fetch';
+import { URL } from 'node:url';
+import Bull from 'bull';
+import httpSignature from 'http-signature';
+import perform from '@/remote/activitypub/perform.js';
+import Logger from '@/services/logger.js';
+import { registerOrFetchInstanceDoc } from '@/services/register-or-fetch-instance-doc.js';
+import { Instances } from '@/models/index.js';
+import { apRequestChart, federationChart, instanceChart } from '@/services/chart/index.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { toPuny, extractDbHost } from '@/misc/convert-host.js';
+import { getApId } from '@/remote/activitypub/type.js';
+import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata.js';
+import { InboxJobData } from '../types.js';
+import DbResolver from '@/remote/activitypub/db-resolver.js';
+import { resolvePerson } from '@/remote/activitypub/models/person.js';
+import { LdSignature } from '@/remote/activitypub/misc/ld-signature.js';
+import { StatusError } from '@/misc/fetch.js';
const logger = new Logger('inbox');
diff --git a/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts b/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts
index 788383a0a..7d71a20ad 100644
--- a/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts
+++ b/packages/backend/src/queue/processors/object-storage/clean-remote-files.ts
@@ -1,8 +1,8 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
-import { queueLogger } from '../../logger';
-import { deleteFileSync } from '@/services/drive/delete-file';
-import { DriveFiles } from '@/models/index';
+import { queueLogger } from '../../logger.js';
+import { deleteFileSync } from '@/services/drive/delete-file.js';
+import { DriveFiles } from '@/models/index.js';
import { MoreThan, Not, IsNull } from 'typeorm';
const logger = queueLogger.createSubLogger('clean-remote-files');
diff --git a/packages/backend/src/queue/processors/object-storage/delete-file.ts b/packages/backend/src/queue/processors/object-storage/delete-file.ts
index ed22968a2..c271e3ddd 100644
--- a/packages/backend/src/queue/processors/object-storage/delete-file.ts
+++ b/packages/backend/src/queue/processors/object-storage/delete-file.ts
@@ -1,6 +1,6 @@
-import { ObjectStorageFileJobData } from '@/queue/types';
-import * as Bull from 'bull';
-import { deleteObjectStorageFile } from '@/services/drive/delete-file';
+import { ObjectStorageFileJobData } from '@/queue/types.js';
+import Bull from 'bull';
+import { deleteObjectStorageFile } from '@/services/drive/delete-file.js';
export default async (job: Bull.Job) => {
const key: string = job.data.key;
diff --git a/packages/backend/src/queue/processors/object-storage/index.ts b/packages/backend/src/queue/processors/object-storage/index.ts
index 0d9570e17..ae6c481fe 100644
--- a/packages/backend/src/queue/processors/object-storage/index.ts
+++ b/packages/backend/src/queue/processors/object-storage/index.ts
@@ -1,7 +1,7 @@
-import * as Bull from 'bull';
-import { ObjectStorageJobData } from '@/queue/types';
-import deleteFile from './delete-file';
-import cleanRemoteFiles from './clean-remote-files';
+import Bull from 'bull';
+import { ObjectStorageJobData } from '@/queue/types.js';
+import deleteFile from './delete-file.js';
+import cleanRemoteFiles from './clean-remote-files.js';
const jobs = {
deleteFile,
diff --git a/packages/backend/src/queue/processors/system/check-expired-mutings.ts b/packages/backend/src/queue/processors/system/check-expired-mutings.ts
new file mode 100644
index 000000000..621269e7e
--- /dev/null
+++ b/packages/backend/src/queue/processors/system/check-expired-mutings.ts
@@ -0,0 +1,30 @@
+import Bull from 'bull';
+import { In } from 'typeorm';
+import { Mutings } from '@/models/index.js';
+import { queueLogger } from '../../logger.js';
+import { publishUserEvent } from '@/services/stream.js';
+
+const logger = queueLogger.createSubLogger('check-expired-mutings');
+
+export async function checkExpiredMutings(job: Bull.Job>, done: any): Promise {
+ logger.info(`Checking expired mutings...`);
+
+ const expired = await Mutings.createQueryBuilder('muting')
+ .where('muting.expiresAt IS NOT NULL')
+ .andWhere('muting.expiresAt < :now', { now: new Date() })
+ .innerJoinAndSelect('muting.mutee', 'mutee')
+ .getMany();
+
+ if (expired.length > 0) {
+ await Mutings.delete({
+ id: In(expired.map(m => m.id)),
+ });
+
+ for (const m of expired) {
+ publishUserEvent(m.muterId, 'unmute', m.mutee!);
+ }
+ }
+
+ logger.succ(`All expired mutings checked.`);
+ done();
+}
diff --git a/packages/backend/src/queue/processors/system/clean-charts.ts b/packages/backend/src/queue/processors/system/clean-charts.ts
index 3ae0f495f..c9169d5ac 100644
--- a/packages/backend/src/queue/processors/system/clean-charts.ts
+++ b/packages/backend/src/queue/processors/system/clean-charts.ts
@@ -1,7 +1,7 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
-import { queueLogger } from '../../logger';
-import { activeUsersChart, driveChart, federationChart, hashtagChart, instanceChart, notesChart, perUserDriveChart, perUserFollowingChart, perUserNotesChart, perUserReactionsChart, usersChart, apRequestChart } from '@/services/chart/index';
+import { queueLogger } from '../../logger.js';
+import { activeUsersChart, driveChart, federationChart, hashtagChart, instanceChart, notesChart, perUserDriveChart, perUserFollowingChart, perUserNotesChart, perUserReactionsChart, usersChart, apRequestChart } from '@/services/chart/index.js';
const logger = queueLogger.createSubLogger('clean-charts');
diff --git a/packages/backend/src/queue/processors/system/index.ts b/packages/backend/src/queue/processors/system/index.ts
index 1513ea4a8..f90f6efaf 100644
--- a/packages/backend/src/queue/processors/system/index.ts
+++ b/packages/backend/src/queue/processors/system/index.ts
@@ -1,12 +1,14 @@
-import * as Bull from 'bull';
-import { tickCharts } from './tick-charts';
-import { resyncCharts } from './resync-charts';
-import { cleanCharts } from './clean-charts';
+import Bull from 'bull';
+import { tickCharts } from './tick-charts.js';
+import { resyncCharts } from './resync-charts.js';
+import { cleanCharts } from './clean-charts.js';
+import { checkExpiredMutings } from './check-expired-mutings.js';
const jobs = {
tickCharts,
resyncCharts,
cleanCharts,
+ checkExpiredMutings,
} as Record> | Bull.ProcessPromiseFunction>>;
export default function(dbQueue: Bull.Queue>) {
diff --git a/packages/backend/src/queue/processors/system/resync-charts.ts b/packages/backend/src/queue/processors/system/resync-charts.ts
index 78a70bb98..20012513a 100644
--- a/packages/backend/src/queue/processors/system/resync-charts.ts
+++ b/packages/backend/src/queue/processors/system/resync-charts.ts
@@ -1,7 +1,7 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
-import { queueLogger } from '../../logger';
-import { driveChart, notesChart, usersChart } from '@/services/chart/index';
+import { queueLogger } from '../../logger.js';
+import { driveChart, notesChart, usersChart } from '@/services/chart/index.js';
const logger = queueLogger.createSubLogger('resync-charts');
diff --git a/packages/backend/src/queue/processors/system/tick-charts.ts b/packages/backend/src/queue/processors/system/tick-charts.ts
index d53089f89..13403f8f7 100644
--- a/packages/backend/src/queue/processors/system/tick-charts.ts
+++ b/packages/backend/src/queue/processors/system/tick-charts.ts
@@ -1,7 +1,7 @@
-import * as Bull from 'bull';
+import Bull from 'bull';
-import { queueLogger } from '../../logger';
-import { activeUsersChart, driveChart, federationChart, hashtagChart, instanceChart, notesChart, perUserDriveChart, perUserFollowingChart, perUserNotesChart, perUserReactionsChart, usersChart, apRequestChart } from '@/services/chart/index';
+import { queueLogger } from '../../logger.js';
+import { activeUsersChart, driveChart, federationChart, hashtagChart, instanceChart, notesChart, perUserDriveChart, perUserFollowingChart, perUserNotesChart, perUserReactionsChart, usersChart, apRequestChart } from '@/services/chart/index.js';
const logger = queueLogger.createSubLogger('tick-charts');
diff --git a/packages/backend/src/queue/queues.ts b/packages/backend/src/queue/queues.ts
index b1d790fcb..02df58736 100644
--- a/packages/backend/src/queue/queues.ts
+++ b/packages/backend/src/queue/queues.ts
@@ -1,8 +1,9 @@
-import config from '@/config/index';
-import { initialize as initializeQueue } from './initialize';
-import { DeliverJobData, InboxJobData, DbJobData, ObjectStorageJobData } from './types';
+import config from '@/config/index.js';
+import { initialize as initializeQueue } from './initialize.js';
+import { DeliverJobData, InboxJobData, DbJobData, ObjectStorageJobData, EndedPollNotificationJobData } from './types.js';
export const systemQueue = initializeQueue>('system');
+export const endedPollNotificationQueue = initializeQueue('endedPollNotification');
export const deliverQueue = initializeQueue('deliver', config.deliverJobPerSec || 128);
export const inboxQueue = initializeQueue('inbox', config.inboxJobPerSec || 16);
export const dbQueue = initializeQueue('db');
diff --git a/packages/backend/src/queue/types.ts b/packages/backend/src/queue/types.ts
index 91036177d..5191caea4 100644
--- a/packages/backend/src/queue/types.ts
+++ b/packages/backend/src/queue/types.ts
@@ -1,7 +1,8 @@
-import { DriveFile } from '@/models/entities/drive-file';
-import { User } from '@/models/entities/user';
-import { IActivity } from '@/remote/activitypub/type';
-import * as httpSignature from 'http-signature';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { Note } from '@/models/entities/note';
+import { User } from '@/models/entities/user.js';
+import { IActivity } from '@/remote/activitypub/type.js';
+import httpSignature from 'http-signature';
export type DeliverJobData = {
/** Actor */
@@ -41,6 +42,10 @@ export type ObjectStorageFileJobData = {
key: string;
};
+export type EndedPollNotificationJobData = {
+ noteId: Note['id'];
+};
+
export type ThinUser = {
id: User['id'];
};
diff --git a/packages/backend/src/remote/activitypub/ap-request.ts b/packages/backend/src/remote/activitypub/ap-request.ts
index c75f44f2e..96bfec3b1 100644
--- a/packages/backend/src/remote/activitypub/ap-request.ts
+++ b/packages/backend/src/remote/activitypub/ap-request.ts
@@ -1,5 +1,5 @@
-import * as crypto from 'crypto';
-import { URL } from 'url';
+import * as crypto from 'node:crypto';
+import { URL } from 'node:url';
type Request = {
url: string;
diff --git a/packages/backend/src/remote/activitypub/audience.ts b/packages/backend/src/remote/activitypub/audience.ts
index e82ed94a6..ba69b11e8 100644
--- a/packages/backend/src/remote/activitypub/audience.ts
+++ b/packages/backend/src/remote/activitypub/audience.ts
@@ -1,9 +1,9 @@
-import { ApObject, getApIds } from './type';
-import Resolver from './resolver';
-import { resolvePerson } from './models/person';
-import { unique, concat } from '@/prelude/array';
-import * as promiseLimit from 'promise-limit';
-import { User, IRemoteUser } from '@/models/entities/user';
+import { ApObject, getApIds } from './type.js';
+import Resolver from './resolver.js';
+import { resolvePerson } from './models/person.js';
+import { unique, concat } from '@/prelude/array.js';
+import promiseLimit from 'promise-limit';
+import { User, IRemoteUser } from '@/models/entities/user.js';
type Visibility = 'public' | 'home' | 'followers' | 'specified';
diff --git a/packages/backend/src/remote/activitypub/db-resolver.ts b/packages/backend/src/remote/activitypub/db-resolver.ts
index f2064cf26..9281e494d 100644
--- a/packages/backend/src/remote/activitypub/db-resolver.ts
+++ b/packages/backend/src/remote/activitypub/db-resolver.ts
@@ -1,12 +1,12 @@
-import config from '@/config/index';
-import { Note } from '@/models/entities/note';
-import { User, IRemoteUser } from '@/models/entities/user';
-import { UserPublickey } from '@/models/entities/user-publickey';
-import { MessagingMessage } from '@/models/entities/messaging-message';
-import { Notes, Users, UserPublickeys, MessagingMessages } from '@/models/index';
-import { IObject, getApId } from './type';
-import { resolvePerson } from './models/person';
-import escapeRegexp = require('escape-regexp');
+import config from '@/config/index.js';
+import { Note } from '@/models/entities/note.js';
+import { User, IRemoteUser } from '@/models/entities/user.js';
+import { UserPublickey } from '@/models/entities/user-publickey.js';
+import { MessagingMessage } from '@/models/entities/messaging-message.js';
+import { Notes, Users, UserPublickeys, MessagingMessages } from '@/models/index.js';
+import { IObject, getApId } from './type.js';
+import { resolvePerson } from './models/person.js';
+import escapeRegexp from 'escape-regexp';
export default class DbResolver {
constructor() {
diff --git a/packages/backend/src/remote/activitypub/deliver-manager.ts b/packages/backend/src/remote/activitypub/deliver-manager.ts
index b16f90769..9c4e3418f 100644
--- a/packages/backend/src/remote/activitypub/deliver-manager.ts
+++ b/packages/backend/src/remote/activitypub/deliver-manager.ts
@@ -1,6 +1,6 @@
-import { Users, Followings } from '@/models/index';
-import { ILocalUser, IRemoteUser, User } from '@/models/entities/user';
-import { deliver } from '@/queue/index';
+import { Users, Followings } from '@/models/index.js';
+import { ILocalUser, IRemoteUser, User } from '@/models/entities/user.js';
+import { deliver } from '@/queue/index.js';
//#region types
interface IRecipe {
diff --git a/packages/backend/src/remote/activitypub/kernel/accept/follow.ts b/packages/backend/src/remote/activitypub/kernel/accept/follow.ts
index 1afb733ab..393516add 100644
--- a/packages/backend/src/remote/activitypub/kernel/accept/follow.ts
+++ b/packages/backend/src/remote/activitypub/kernel/accept/follow.ts
@@ -1,8 +1,8 @@
-import { IRemoteUser } from '@/models/entities/user';
-import accept from '@/services/following/requests/accept';
-import { IFollow } from '../../type';
-import DbResolver from '../../db-resolver';
-import { relayAccepted } from '@/services/relay';
+import { IRemoteUser } from '@/models/entities/user.js';
+import accept from '@/services/following/requests/accept.js';
+import { IFollow } from '../../type.js';
+import DbResolver from '../../db-resolver.js';
+import { relayAccepted } from '@/services/relay.js';
export default async (actor: IRemoteUser, activity: IFollow): Promise => {
// ※ activityはこっちから投げたフォローリクエストなので、activity.actorは存在するローカルユーザーである必要がある
diff --git a/packages/backend/src/remote/activitypub/kernel/accept/index.ts b/packages/backend/src/remote/activitypub/kernel/accept/index.ts
index 5c6f81b2e..354bd4f6e 100644
--- a/packages/backend/src/remote/activitypub/kernel/accept/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/accept/index.ts
@@ -1,8 +1,8 @@
-import Resolver from '../../resolver';
-import { IRemoteUser } from '@/models/entities/user';
-import acceptFollow from './follow';
-import { IAccept, isFollow, getApType } from '../../type';
-import { apLogger } from '../../logger';
+import Resolver from '../../resolver.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import acceptFollow from './follow.js';
+import { IAccept, isFollow, getApType } from '../../type.js';
+import { apLogger } from '../../logger.js';
const logger = apLogger;
diff --git a/packages/backend/src/remote/activitypub/kernel/add/index.ts b/packages/backend/src/remote/activitypub/kernel/add/index.ts
index b33be0cc8..9a2fac1e7 100644
--- a/packages/backend/src/remote/activitypub/kernel/add/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/add/index.ts
@@ -1,7 +1,7 @@
-import { IRemoteUser } from '@/models/entities/user';
-import { IAdd } from '../../type';
-import { resolveNote } from '../../models/note';
-import { addPinned } from '@/services/i/pin';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { IAdd } from '../../type.js';
+import { resolveNote } from '../../models/note.js';
+import { addPinned } from '@/services/i/pin.js';
export default async (actor: IRemoteUser, activity: IAdd): Promise => {
if ('actor' in activity && actor.uri !== activity.actor) {
diff --git a/packages/backend/src/remote/activitypub/kernel/announce/index.ts b/packages/backend/src/remote/activitypub/kernel/announce/index.ts
index 581357e57..7e2e73bdd 100644
--- a/packages/backend/src/remote/activitypub/kernel/announce/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/announce/index.ts
@@ -1,8 +1,8 @@
-import Resolver from '../../resolver';
-import { IRemoteUser } from '@/models/entities/user';
-import announceNote from './note';
-import { IAnnounce, getApId } from '../../type';
-import { apLogger } from '../../logger';
+import Resolver from '../../resolver.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import announceNote from './note.js';
+import { IAnnounce, getApId } from '../../type.js';
+import { apLogger } from '../../logger.js';
const logger = apLogger;
diff --git a/packages/backend/src/remote/activitypub/kernel/announce/note.ts b/packages/backend/src/remote/activitypub/kernel/announce/note.ts
index eae92d418..f6068fac7 100644
--- a/packages/backend/src/remote/activitypub/kernel/announce/note.ts
+++ b/packages/backend/src/remote/activitypub/kernel/announce/note.ts
@@ -1,14 +1,14 @@
-import Resolver from '../../resolver';
-import post from '@/services/note/create';
-import { IRemoteUser } from '@/models/entities/user';
-import { IAnnounce, getApId } from '../../type';
-import { fetchNote, resolveNote } from '../../models/note';
-import { apLogger } from '../../logger';
-import { extractDbHost } from '@/misc/convert-host';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { getApLock } from '@/misc/app-lock';
-import { parseAudience } from '../../audience';
-import { StatusError } from '@/misc/fetch';
+import Resolver from '../../resolver.js';
+import post from '@/services/note/create.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { IAnnounce, getApId } from '../../type.js';
+import { fetchNote, resolveNote } from '../../models/note.js';
+import { apLogger } from '../../logger.js';
+import { extractDbHost } from '@/misc/convert-host.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { getApLock } from '@/misc/app-lock.js';
+import { parseAudience } from '../../audience.js';
+import { StatusError } from '@/misc/fetch.js';
const logger = apLogger;
diff --git a/packages/backend/src/remote/activitypub/kernel/block/index.ts b/packages/backend/src/remote/activitypub/kernel/block/index.ts
index 4fd1e07b9..9e4f1b316 100644
--- a/packages/backend/src/remote/activitypub/kernel/block/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/block/index.ts
@@ -1,7 +1,7 @@
-import { IBlock } from '../../type';
-import block from '@/services/blocking/create';
-import { IRemoteUser } from '@/models/entities/user';
-import DbResolver from '../../db-resolver';
+import { IBlock } from '../../type.js';
+import block from '@/services/blocking/create.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import DbResolver from '../../db-resolver.js';
export default async (actor: IRemoteUser, activity: IBlock): Promise => {
// ※ activity.objectにブロック対象があり、それは存在するローカルユーザーのはず
diff --git a/packages/backend/src/remote/activitypub/kernel/create/index.ts b/packages/backend/src/remote/activitypub/kernel/create/index.ts
index ce039a363..1187b95ac 100644
--- a/packages/backend/src/remote/activitypub/kernel/create/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/create/index.ts
@@ -1,9 +1,9 @@
-import Resolver from '../../resolver';
-import { IRemoteUser } from '@/models/entities/user';
-import createNote from './note';
-import { ICreate, getApId, isPost, getApType } from '../../type';
-import { apLogger } from '../../logger';
-import { toArray, concat, unique } from '@/prelude/array';
+import Resolver from '../../resolver.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import createNote from './note.js';
+import { ICreate, getApId, isPost, getApType } from '../../type.js';
+import { apLogger } from '../../logger.js';
+import { toArray, concat, unique } from '@/prelude/array.js';
const logger = apLogger;
diff --git a/packages/backend/src/remote/activitypub/kernel/create/note.ts b/packages/backend/src/remote/activitypub/kernel/create/note.ts
index 14e311e4c..b5c47990a 100644
--- a/packages/backend/src/remote/activitypub/kernel/create/note.ts
+++ b/packages/backend/src/remote/activitypub/kernel/create/note.ts
@@ -1,10 +1,10 @@
-import Resolver from '../../resolver';
-import { IRemoteUser } from '@/models/entities/user';
-import { createNote, fetchNote } from '../../models/note';
-import { getApId, IObject, ICreate } from '../../type';
-import { getApLock } from '@/misc/app-lock';
-import { extractDbHost } from '@/misc/convert-host';
-import { StatusError } from '@/misc/fetch';
+import Resolver from '../../resolver.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { createNote, fetchNote } from '../../models/note.js';
+import { getApId, IObject, ICreate } from '../../type.js';
+import { getApLock } from '@/misc/app-lock.js';
+import { extractDbHost } from '@/misc/convert-host.js';
+import { StatusError } from '@/misc/fetch.js';
/**
* 投稿作成アクティビティを捌きます
diff --git a/packages/backend/src/remote/activitypub/kernel/delete/actor.ts b/packages/backend/src/remote/activitypub/kernel/delete/actor.ts
index 502f8d5ab..2f75841e5 100644
--- a/packages/backend/src/remote/activitypub/kernel/delete/actor.ts
+++ b/packages/backend/src/remote/activitypub/kernel/delete/actor.ts
@@ -1,7 +1,7 @@
-import { apLogger } from '../../logger';
-import { createDeleteAccountJob } from '@/queue';
-import { IRemoteUser } from '@/models/entities/user';
-import { Users } from '@/models/index';
+import { apLogger } from '../../logger.js';
+import { createDeleteAccountJob } from '@/queue/index.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { Users } from '@/models/index.js';
const logger = apLogger;
diff --git a/packages/backend/src/remote/activitypub/kernel/delete/index.ts b/packages/backend/src/remote/activitypub/kernel/delete/index.ts
index 86a452de7..b6d5e96d0 100644
--- a/packages/backend/src/remote/activitypub/kernel/delete/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/delete/index.ts
@@ -1,8 +1,8 @@
-import deleteNote from './note';
-import { IRemoteUser } from '@/models/entities/user';
-import { IDelete, getApId, isTombstone, IObject, validPost, validActor } from '../../type';
-import { toSingle } from '@/prelude/array';
-import { deleteActor } from './actor';
+import deleteNote from './note.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { IDelete, getApId, isTombstone, IObject, validPost, validActor } from '../../type.js';
+import { toSingle } from '@/prelude/array.js';
+import { deleteActor } from './actor.js';
/**
* 削除アクティビティを捌きます
diff --git a/packages/backend/src/remote/activitypub/kernel/delete/note.ts b/packages/backend/src/remote/activitypub/kernel/delete/note.ts
index 3875a33d1..ad5e1a2ed 100644
--- a/packages/backend/src/remote/activitypub/kernel/delete/note.ts
+++ b/packages/backend/src/remote/activitypub/kernel/delete/note.ts
@@ -1,9 +1,9 @@
-import { IRemoteUser } from '@/models/entities/user';
-import deleteNode from '@/services/note/delete';
-import { apLogger } from '../../logger';
-import DbResolver from '../../db-resolver';
-import { getApLock } from '@/misc/app-lock';
-import { deleteMessage } from '@/services/messages/delete';
+import { IRemoteUser } from '@/models/entities/user.js';
+import deleteNode from '@/services/note/delete.js';
+import { apLogger } from '../../logger.js';
+import DbResolver from '../../db-resolver.js';
+import { getApLock } from '@/misc/app-lock.js';
+import { deleteMessage } from '@/services/messages/delete.js';
const logger = apLogger;
diff --git a/packages/backend/src/remote/activitypub/kernel/flag/index.ts b/packages/backend/src/remote/activitypub/kernel/flag/index.ts
index d910e2ebe..e80e63278 100644
--- a/packages/backend/src/remote/activitypub/kernel/flag/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/flag/index.ts
@@ -1,9 +1,9 @@
-import { IRemoteUser } from '@/models/entities/user';
-import config from '@/config/index';
-import { IFlag, getApIds } from '../../type';
-import { AbuseUserReports, Users } from '@/models/index';
+import { IRemoteUser } from '@/models/entities/user.js';
+import config from '@/config/index.js';
+import { IFlag, getApIds } from '../../type.js';
+import { AbuseUserReports, Users } from '@/models/index.js';
import { In } from 'typeorm';
-import { genId } from '@/misc/gen-id';
+import { genId } from '@/misc/gen-id.js';
export default async (actor: IRemoteUser, activity: IFlag): Promise => {
// objectは `(User|Note) | (User|Note)[]` だけど、全パターンDBスキーマと対応させられないので
diff --git a/packages/backend/src/remote/activitypub/kernel/follow.ts b/packages/backend/src/remote/activitypub/kernel/follow.ts
index 3183207af..49c1a7ee0 100644
--- a/packages/backend/src/remote/activitypub/kernel/follow.ts
+++ b/packages/backend/src/remote/activitypub/kernel/follow.ts
@@ -1,7 +1,7 @@
-import { IRemoteUser } from '@/models/entities/user';
-import follow from '@/services/following/create';
-import { IFollow } from '../type';
-import DbResolver from '../db-resolver';
+import { IRemoteUser } from '@/models/entities/user.js';
+import follow from '@/services/following/create.js';
+import { IFollow } from '../type.js';
+import DbResolver from '../db-resolver.js';
export default async (actor: IRemoteUser, activity: IFollow): Promise => {
const dbResolver = new DbResolver();
diff --git a/packages/backend/src/remote/activitypub/kernel/index.ts b/packages/backend/src/remote/activitypub/kernel/index.ts
index a103e5a1b..6aea8e57c 100644
--- a/packages/backend/src/remote/activitypub/kernel/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/index.ts
@@ -1,22 +1,22 @@
-import { IObject, isCreate, isDelete, isUpdate, isRead, isFollow, isAccept, isReject, isAdd, isRemove, isAnnounce, isLike, isUndo, isBlock, isCollectionOrOrderedCollection, isCollection, isFlag } from '../type';
-import { IRemoteUser } from '@/models/entities/user';
-import create from './create/index';
-import performDeleteActivity from './delete/index';
-import performUpdateActivity from './update/index';
-import { performReadActivity } from './read';
-import follow from './follow';
-import undo from './undo/index';
-import like from './like';
-import announce from './announce/index';
-import accept from './accept/index';
-import reject from './reject/index';
-import add from './add/index';
-import remove from './remove/index';
-import block from './block/index';
-import flag from './flag/index';
-import { apLogger } from '../logger';
-import Resolver from '../resolver';
-import { toArray } from '@/prelude/array';
+import { IObject, isCreate, isDelete, isUpdate, isRead, isFollow, isAccept, isReject, isAdd, isRemove, isAnnounce, isLike, isUndo, isBlock, isCollectionOrOrderedCollection, isCollection, isFlag } from '../type.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import create from './create/index.js';
+import performDeleteActivity from './delete/index.js';
+import performUpdateActivity from './update/index.js';
+import { performReadActivity } from './read.js';
+import follow from './follow.js';
+import undo from './undo/index.js';
+import like from './like.js';
+import announce from './announce/index.js';
+import accept from './accept/index.js';
+import reject from './reject/index.js';
+import add from './add/index.js';
+import remove from './remove/index.js';
+import block from './block/index.js';
+import flag from './flag/index.js';
+import { apLogger } from '../logger.js';
+import Resolver from '../resolver.js';
+import { toArray } from '@/prelude/array.js';
export async function performActivity(actor: IRemoteUser, activity: IObject) {
if (isCollectionOrOrderedCollection(activity)) {
diff --git a/packages/backend/src/remote/activitypub/kernel/like.ts b/packages/backend/src/remote/activitypub/kernel/like.ts
index 58d5aefef..715cc379b 100644
--- a/packages/backend/src/remote/activitypub/kernel/like.ts
+++ b/packages/backend/src/remote/activitypub/kernel/like.ts
@@ -1,7 +1,7 @@
-import { IRemoteUser } from '@/models/entities/user';
-import { ILike, getApId } from '../type';
-import create from '@/services/note/reaction/create';
-import { fetchNote, extractEmojis } from '../models/note';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { ILike, getApId } from '../type.js';
+import create from '@/services/note/reaction/create.js';
+import { fetchNote, extractEmojis } from '../models/note.js';
export default async (actor: IRemoteUser, activity: ILike) => {
const targetUri = getApId(activity.object);
diff --git a/packages/backend/src/remote/activitypub/kernel/read.ts b/packages/backend/src/remote/activitypub/kernel/read.ts
index 11a173186..93cc36ec4 100644
--- a/packages/backend/src/remote/activitypub/kernel/read.ts
+++ b/packages/backend/src/remote/activitypub/kernel/read.ts
@@ -1,8 +1,8 @@
-import { IRemoteUser } from '@/models/entities/user';
-import { IRead, getApId } from '../type';
-import { isSelfHost, extractDbHost } from '@/misc/convert-host';
-import { MessagingMessages } from '@/models/index';
-import { readUserMessagingMessage } from '../../../server/api/common/read-messaging-message';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { IRead, getApId } from '../type.js';
+import { isSelfHost, extractDbHost } from '@/misc/convert-host.js';
+import { MessagingMessages } from '@/models/index.js';
+import { readUserMessagingMessage } from '../../../server/api/common/read-messaging-message.js';
export const performReadActivity = async (actor: IRemoteUser, activity: IRead): Promise => {
const id = await getApId(activity.object);
diff --git a/packages/backend/src/remote/activitypub/kernel/reject/follow.ts b/packages/backend/src/remote/activitypub/kernel/reject/follow.ts
index 049437b18..72751e83c 100644
--- a/packages/backend/src/remote/activitypub/kernel/reject/follow.ts
+++ b/packages/backend/src/remote/activitypub/kernel/reject/follow.ts
@@ -1,9 +1,9 @@
-import { IRemoteUser } from '@/models/entities/user';
-import { remoteReject } from '@/services/following/reject';
-import { IFollow } from '../../type';
-import DbResolver from '../../db-resolver';
-import { relayRejected } from '@/services/relay';
-import { Users } from '@/models';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { remoteReject } from '@/services/following/reject.js';
+import { IFollow } from '../../type.js';
+import DbResolver from '../../db-resolver.js';
+import { relayRejected } from '@/services/relay.js';
+import { Users } from '@/models/index.js';
export default async (actor: IRemoteUser, activity: IFollow): Promise => {
// ※ activityはこっちから投げたフォローリクエストなので、activity.actorは存在するローカルユーザーである必要がある
diff --git a/packages/backend/src/remote/activitypub/kernel/reject/index.ts b/packages/backend/src/remote/activitypub/kernel/reject/index.ts
index d0de9c329..ed86a4aa2 100644
--- a/packages/backend/src/remote/activitypub/kernel/reject/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/reject/index.ts
@@ -1,8 +1,8 @@
-import Resolver from '../../resolver';
-import { IRemoteUser } from '@/models/entities/user';
-import rejectFollow from './follow';
-import { IReject, isFollow, getApType } from '../../type';
-import { apLogger } from '../../logger';
+import Resolver from '../../resolver.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import rejectFollow from './follow.js';
+import { IReject, isFollow, getApType } from '../../type.js';
+import { apLogger } from '../../logger.js';
const logger = apLogger;
diff --git a/packages/backend/src/remote/activitypub/kernel/remove/index.ts b/packages/backend/src/remote/activitypub/kernel/remove/index.ts
index d59953e65..7d7b3386c 100644
--- a/packages/backend/src/remote/activitypub/kernel/remove/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/remove/index.ts
@@ -1,7 +1,7 @@
-import { IRemoteUser } from '@/models/entities/user';
-import { IRemove } from '../../type';
-import { resolveNote } from '../../models/note';
-import { removePinned } from '@/services/i/pin';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { IRemove } from '../../type.js';
+import { resolveNote } from '../../models/note.js';
+import { removePinned } from '@/services/i/pin.js';
export default async (actor: IRemoteUser, activity: IRemove): Promise => {
if ('actor' in activity && actor.uri !== activity.actor) {
diff --git a/packages/backend/src/remote/activitypub/kernel/undo/accept.ts b/packages/backend/src/remote/activitypub/kernel/undo/accept.ts
index 10c8a9c9d..2383eea5b 100644
--- a/packages/backend/src/remote/activitypub/kernel/undo/accept.ts
+++ b/packages/backend/src/remote/activitypub/kernel/undo/accept.ts
@@ -1,9 +1,9 @@
-import unfollow from '@/services/following/delete';
-import cancelRequest from '@/services/following/requests/cancel';
-import {IAccept} from '../../type';
-import { IRemoteUser } from '@/models/entities/user';
-import { Followings } from '@/models/index';
-import DbResolver from '../../db-resolver';
+import unfollow from '@/services/following/delete.js';
+import cancelRequest from '@/services/following/requests/cancel.js';
+import {IAccept} from '../../type.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { Followings } from '@/models/index.js';
+import DbResolver from '../../db-resolver.js';
export default async (actor: IRemoteUser, activity: IAccept): Promise => {
const dbResolver = new DbResolver();
diff --git a/packages/backend/src/remote/activitypub/kernel/undo/announce.ts b/packages/backend/src/remote/activitypub/kernel/undo/announce.ts
index 7f302a616..822c1e494 100644
--- a/packages/backend/src/remote/activitypub/kernel/undo/announce.ts
+++ b/packages/backend/src/remote/activitypub/kernel/undo/announce.ts
@@ -1,7 +1,7 @@
-import { Notes } from '@/models/index';
-import { IRemoteUser } from '@/models/entities/user';
-import { IAnnounce, getApId } from '../../type';
-import deleteNote from '@/services/note/delete';
+import { Notes } from '@/models/index.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { IAnnounce, getApId } from '../../type.js';
+import deleteNote from '@/services/note/delete.js';
export const undoAnnounce = async (actor: IRemoteUser, activity: IAnnounce): Promise => {
const uri = getApId(activity);
diff --git a/packages/backend/src/remote/activitypub/kernel/undo/block.ts b/packages/backend/src/remote/activitypub/kernel/undo/block.ts
index 61940486b..844b067e2 100644
--- a/packages/backend/src/remote/activitypub/kernel/undo/block.ts
+++ b/packages/backend/src/remote/activitypub/kernel/undo/block.ts
@@ -1,7 +1,7 @@
-import { IBlock } from '../../type';
-import unblock from '@/services/blocking/delete';
-import { IRemoteUser } from '@/models/entities/user';
-import DbResolver from '../../db-resolver';
+import { IBlock } from '../../type.js';
+import unblock from '@/services/blocking/delete.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import DbResolver from '../../db-resolver.js';
export default async (actor: IRemoteUser, activity: IBlock): Promise => {
const dbResolver = new DbResolver();
diff --git a/packages/backend/src/remote/activitypub/kernel/undo/follow.ts b/packages/backend/src/remote/activitypub/kernel/undo/follow.ts
index 783e5acf1..6715adcf7 100644
--- a/packages/backend/src/remote/activitypub/kernel/undo/follow.ts
+++ b/packages/backend/src/remote/activitypub/kernel/undo/follow.ts
@@ -1,9 +1,9 @@
-import unfollow from '@/services/following/delete';
-import cancelRequest from '@/services/following/requests/cancel';
-import { IFollow } from '../../type';
-import { IRemoteUser } from '@/models/entities/user';
-import { FollowRequests, Followings } from '@/models/index';
-import DbResolver from '../../db-resolver';
+import unfollow from '@/services/following/delete.js';
+import cancelRequest from '@/services/following/requests/cancel.js';
+import { IFollow } from '../../type.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { FollowRequests, Followings } from '@/models/index.js';
+import DbResolver from '../../db-resolver.js';
export default async (actor: IRemoteUser, activity: IFollow): Promise => {
const dbResolver = new DbResolver();
diff --git a/packages/backend/src/remote/activitypub/kernel/undo/index.ts b/packages/backend/src/remote/activitypub/kernel/undo/index.ts
index 8de78420e..05937c685 100644
--- a/packages/backend/src/remote/activitypub/kernel/undo/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/undo/index.ts
@@ -1,12 +1,12 @@
-import { IRemoteUser } from '@/models/entities/user';
-import {IUndo, isFollow, isBlock, isLike, isAnnounce, getApType, isAccept} from '../../type';
-import unfollow from './follow';
-import unblock from './block';
-import undoLike from './like';
-import undoAccept from './accept';
-import { undoAnnounce } from './announce';
-import Resolver from '../../resolver';
-import { apLogger } from '../../logger';
+import { IRemoteUser } from '@/models/entities/user.js';
+import {IUndo, isFollow, isBlock, isLike, isAnnounce, getApType, isAccept} from '../../type.js';
+import unfollow from './follow.js';
+import unblock from './block.js';
+import undoLike from './like.js';
+import undoAccept from './accept.js';
+import { undoAnnounce } from './announce.js';
+import Resolver from '../../resolver.js';
+import { apLogger } from '../../logger.js';
const logger = apLogger;
diff --git a/packages/backend/src/remote/activitypub/kernel/undo/like.ts b/packages/backend/src/remote/activitypub/kernel/undo/like.ts
index 107d3053e..08ac63035 100644
--- a/packages/backend/src/remote/activitypub/kernel/undo/like.ts
+++ b/packages/backend/src/remote/activitypub/kernel/undo/like.ts
@@ -1,7 +1,7 @@
-import { IRemoteUser } from '@/models/entities/user';
-import { ILike, getApId } from '../../type';
-import deleteReaction from '@/services/note/reaction/delete';
-import { fetchNote } from '../../models/note';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { ILike, getApId } from '../../type.js';
+import deleteReaction from '@/services/note/reaction/delete.js';
+import { fetchNote } from '../../models/note.js';
/**
* Process Undo.Like activity
diff --git a/packages/backend/src/remote/activitypub/kernel/update/index.ts b/packages/backend/src/remote/activitypub/kernel/update/index.ts
index 52bfc5002..7888c698e 100644
--- a/packages/backend/src/remote/activitypub/kernel/update/index.ts
+++ b/packages/backend/src/remote/activitypub/kernel/update/index.ts
@@ -1,9 +1,9 @@
-import { IRemoteUser } from '@/models/entities/user';
-import { getApType, IUpdate, isActor } from '../../type';
-import { apLogger } from '../../logger';
-import { updateQuestion } from '../../models/question';
-import Resolver from '../../resolver';
-import { updatePerson } from '../../models/person';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { getApType, IUpdate, isActor } from '../../type.js';
+import { apLogger } from '../../logger.js';
+import { updateQuestion } from '../../models/question.js';
+import Resolver from '../../resolver.js';
+import { updatePerson } from '../../models/person.js';
/**
* Updateアクティビティを捌きます
diff --git a/packages/backend/src/remote/activitypub/logger.ts b/packages/backend/src/remote/activitypub/logger.ts
index e13add01d..cab51b3bf 100644
--- a/packages/backend/src/remote/activitypub/logger.ts
+++ b/packages/backend/src/remote/activitypub/logger.ts
@@ -1,3 +1,3 @@
-import { remoteLogger } from '../logger';
+import { remoteLogger } from '../logger.js';
export const apLogger = remoteLogger.createSubLogger('ap', 'magenta');
diff --git a/packages/backend/src/remote/activitypub/misc/get-note-html.ts b/packages/backend/src/remote/activitypub/misc/get-note-html.ts
index 043335a5b..3800b4060 100644
--- a/packages/backend/src/remote/activitypub/misc/get-note-html.ts
+++ b/packages/backend/src/remote/activitypub/misc/get-note-html.ts
@@ -1,6 +1,6 @@
import * as mfm from 'mfm-js';
-import { Note } from '@/models/entities/note';
-import { toHtml } from '../../../mfm/to-html';
+import { Note } from '@/models/entities/note.js';
+import { toHtml } from '../../../mfm/to-html.js';
export default function(note: Note) {
let html = note.text ? toHtml(mfm.parse(note.text), JSON.parse(note.mentionedRemoteUsers)) : null;
diff --git a/packages/backend/src/remote/activitypub/misc/html-to-mfm.ts b/packages/backend/src/remote/activitypub/misc/html-to-mfm.ts
index 5cca04df2..bb1ba7925 100644
--- a/packages/backend/src/remote/activitypub/misc/html-to-mfm.ts
+++ b/packages/backend/src/remote/activitypub/misc/html-to-mfm.ts
@@ -1,6 +1,6 @@
-import { IObject } from '../type';
-import { extractApHashtagObjects } from '../models/tag';
-import { fromHtml } from '../../../mfm/from-html';
+import { IObject } from '../type.js';
+import { extractApHashtagObjects } from '../models/tag.js';
+import { fromHtml } from '../../../mfm/from-html.js';
export function htmlToMfm(html: string, tag?: IObject | IObject[]) {
const hashtagNames = extractApHashtagObjects(tag).map(x => x.name).filter((x): x is string => x != null);
diff --git a/packages/backend/src/remote/activitypub/misc/ld-signature.ts b/packages/backend/src/remote/activitypub/misc/ld-signature.ts
index 3b799c755..34294c935 100644
--- a/packages/backend/src/remote/activitypub/misc/ld-signature.ts
+++ b/packages/backend/src/remote/activitypub/misc/ld-signature.ts
@@ -1,8 +1,8 @@
-import * as crypto from 'crypto';
+import * as crypto from 'node:crypto';
import * as jsonld from 'jsonld';
-import { CONTEXTS } from './contexts';
+import { CONTEXTS } from './contexts.js';
import fetch from 'node-fetch';
-import { httpAgent, httpsAgent } from '@/misc/fetch';
+import { httpAgent, httpsAgent } from '@/misc/fetch.js';
// RsaSignature2017 based from https://github.com/transmute-industries/RsaSignature2017
diff --git a/packages/backend/src/remote/activitypub/models/image.ts b/packages/backend/src/remote/activitypub/models/image.ts
index 6f60b7827..b5e9181d3 100644
--- a/packages/backend/src/remote/activitypub/models/image.ts
+++ b/packages/backend/src/remote/activitypub/models/image.ts
@@ -1,12 +1,12 @@
-import { uploadFromUrl } from '@/services/drive/upload-from-url';
-import { IRemoteUser } from '@/models/entities/user';
-import Resolver from '../resolver';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { apLogger } from '../logger';
-import { DriveFile } from '@/models/entities/drive-file';
-import { DriveFiles } from '@/models/index';
-import { truncate } from '@/misc/truncate';
-import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/misc/hard-limits';
+import { uploadFromUrl } from '@/services/drive/upload-from-url.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import Resolver from '../resolver.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { apLogger } from '../logger.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { DriveFiles } from '@/models/index.js';
+import { truncate } from '@/misc/truncate.js';
+import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/misc/hard-limits.js';
const logger = apLogger;
diff --git a/packages/backend/src/remote/activitypub/models/mention.ts b/packages/backend/src/remote/activitypub/models/mention.ts
index ade9c9080..c5b0ea53c 100644
--- a/packages/backend/src/remote/activitypub/models/mention.ts
+++ b/packages/backend/src/remote/activitypub/models/mention.ts
@@ -1,9 +1,9 @@
-import { toArray, unique } from '@/prelude/array';
-import { IObject, isMention, IApMention } from '../type';
-import { resolvePerson } from './person';
-import * as promiseLimit from 'promise-limit';
-import Resolver from '../resolver';
-import { User } from '@/models/entities/user';
+import { toArray, unique } from '@/prelude/array.js';
+import { IObject, isMention, IApMention } from '../type.js';
+import { resolvePerson } from './person.js';
+import promiseLimit from 'promise-limit';
+import Resolver from '../resolver.js';
+import { User } from '@/models/entities/user.js';
export async function extractApMentions(tags: IObject | IObject[] | null | undefined) {
const hrefs = unique(extractApMentionObjects(tags).map(x => x.href as string));
diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts
index 6847925a5..dca64d0a6 100644
--- a/packages/backend/src/remote/activitypub/models/note.ts
+++ b/packages/backend/src/remote/activitypub/models/note.ts
@@ -1,32 +1,32 @@
-import * as promiseLimit from 'promise-limit';
+import promiseLimit from 'promise-limit';
-import config from '@/config/index';
-import Resolver from '../resolver';
-import post from '@/services/note/create';
-import { resolvePerson, updatePerson } from './person';
-import { resolveImage } from './image';
-import { IRemoteUser } from '@/models/entities/user';
-import { htmlToMfm } from '../misc/html-to-mfm';
-import { extractApHashtags } from './tag';
-import { unique, toArray, toSingle } from '@/prelude/array';
-import { extractPollFromQuestion } from './question';
-import vote from '@/services/note/polls/vote';
-import { apLogger } from '../logger';
-import { DriveFile } from '@/models/entities/drive-file';
-import { deliverQuestionUpdate } from '@/services/note/polls/update';
-import { extractDbHost, toPuny } from '@/misc/convert-host';
-import { Emojis, Polls, MessagingMessages } from '@/models/index';
-import { Note } from '@/models/entities/note';
-import { IObject, getOneApId, getApId, getOneApHrefNullable, validPost, IPost, isEmoji, getApType } from '../type';
-import { Emoji } from '@/models/entities/emoji';
-import { genId } from '@/misc/gen-id';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { getApLock } from '@/misc/app-lock';
-import { createMessage } from '@/services/messages/create';
-import { parseAudience } from '../audience';
-import { extractApMentions } from './mention';
-import DbResolver from '../db-resolver';
-import { StatusError } from '@/misc/fetch';
+import config from '@/config/index.js';
+import Resolver from '../resolver.js';
+import post from '@/services/note/create.js';
+import { resolvePerson, updatePerson } from './person.js';
+import { resolveImage } from './image.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { htmlToMfm } from '../misc/html-to-mfm.js';
+import { extractApHashtags } from './tag.js';
+import { unique, toArray, toSingle } from '@/prelude/array.js';
+import { extractPollFromQuestion } from './question.js';
+import vote from '@/services/note/polls/vote.js';
+import { apLogger } from '../logger.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { deliverQuestionUpdate } from '@/services/note/polls/update.js';
+import { extractDbHost, toPuny } from '@/misc/convert-host.js';
+import { Emojis, Polls, MessagingMessages } from '@/models/index.js';
+import { Note } from '@/models/entities/note.js';
+import { IObject, getOneApId, getApId, getOneApHrefNullable, validPost, IPost, isEmoji, getApType } from '../type.js';
+import { Emoji } from '@/models/entities/emoji.js';
+import { genId } from '@/misc/gen-id.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { getApLock } from '@/misc/app-lock.js';
+import { createMessage } from '@/services/messages/create.js';
+import { parseAudience } from '../audience.js';
+import { extractApMentions } from './mention.js';
+import DbResolver from '../db-resolver.js';
+import { StatusError } from '@/misc/fetch.js';
const logger = apLogger;
diff --git a/packages/backend/src/remote/activitypub/models/person.ts b/packages/backend/src/remote/activitypub/models/person.ts
index aaccf51fa..659d3ac9a 100644
--- a/packages/backend/src/remote/activitypub/models/person.ts
+++ b/packages/backend/src/remote/activitypub/models/person.ts
@@ -1,35 +1,35 @@
-import { URL } from 'url';
-import * as promiseLimit from 'promise-limit';
+import { URL } from 'node:url';
+import promiseLimit from 'promise-limit';
import $, { Context } from 'cafy';
-import config from '@/config/index';
-import Resolver from '../resolver';
-import { resolveImage } from './image';
-import { isCollectionOrOrderedCollection, isCollection, IActor, getApId, getOneApHrefNullable, IObject, isPropertyValue, IApPropertyValue, getApType, isActor } from '../type';
-import { fromHtml } from '../../../mfm/from-html';
-import { htmlToMfm } from '../misc/html-to-mfm';
-import { resolveNote, extractEmojis } from './note';
-import { registerOrFetchInstanceDoc } from '@/services/register-or-fetch-instance-doc';
-import { extractApHashtags } from './tag';
-import { apLogger } from '../logger';
-import { Note } from '@/models/entities/note';
-import { updateUsertags } from '@/services/update-hashtag';
-import { Users, Instances, DriveFiles, Followings, UserProfiles, UserPublickeys } from '@/models/index';
-import { User, IRemoteUser } from '@/models/entities/user';
-import { Emoji } from '@/models/entities/emoji';
-import { UserNotePining } from '@/models/entities/user-note-pining';
-import { genId } from '@/misc/gen-id';
-import { instanceChart, usersChart } from '@/services/chart/index';
-import { UserPublickey } from '@/models/entities/user-publickey';
-import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error';
-import { toPuny } from '@/misc/convert-host';
-import { UserProfile } from '@/models/entities/user-profile';
+import config from '@/config/index.js';
+import Resolver from '../resolver.js';
+import { resolveImage } from './image.js';
+import { isCollectionOrOrderedCollection, isCollection, IActor, getApId, getOneApHrefNullable, IObject, isPropertyValue, IApPropertyValue, getApType, isActor } from '../type.js';
+import { fromHtml } from '../../../mfm/from-html.js';
+import { htmlToMfm } from '../misc/html-to-mfm.js';
+import { resolveNote, extractEmojis } from './note.js';
+import { registerOrFetchInstanceDoc } from '@/services/register-or-fetch-instance-doc.js';
+import { extractApHashtags } from './tag.js';
+import { apLogger } from '../logger.js';
+import { Note } from '@/models/entities/note.js';
+import { updateUsertags } from '@/services/update-hashtag.js';
+import { Users, Instances, DriveFiles, Followings, UserProfiles, UserPublickeys } from '@/models/index.js';
+import { User, IRemoteUser } from '@/models/entities/user.js';
+import { Emoji } from '@/models/entities/emoji.js';
+import { UserNotePining } from '@/models/entities/user-note-pining.js';
+import { genId } from '@/misc/gen-id.js';
+import { instanceChart, usersChart } from '@/services/chart/index.js';
+import { UserPublickey } from '@/models/entities/user-publickey.js';
+import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error.js';
+import { toPuny } from '@/misc/convert-host.js';
+import { UserProfile } from '@/models/entities/user-profile.js';
import { getConnection } from 'typeorm';
-import { toArray } from '@/prelude/array';
-import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata';
-import { normalizeForSearch } from '@/misc/normalize-for-search';
-import { truncate } from '@/misc/truncate';
-import { StatusError } from '@/misc/fetch';
+import { toArray } from '@/prelude/array.js';
+import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata.js';
+import { normalizeForSearch } from '@/misc/normalize-for-search.js';
+import { truncate } from '@/misc/truncate.js';
+import { StatusError } from '@/misc/fetch.js';
const logger = apLogger;
@@ -57,15 +57,15 @@ function validateActor(x: IObject, uri: string): IActor {
if (e) throw new Error(`invalid Actor: ${name} ${e.message}`);
};
- validate('id', x.id, $.str.min(1));
- validate('inbox', x.inbox, $.str.min(1));
- validate('preferredUsername', x.preferredUsername, $.str.min(1).max(128).match(/^\w([\w-.]*\w)?$/));
+ validate('id', x.id, $.default.str.min(1));
+ validate('inbox', x.inbox, $.default.str.min(1));
+ validate('preferredUsername', x.preferredUsername, $.default.str.min(1).max(128).match(/^\w([\w-.]*\w)?$/));
// These fields are only informational, and some AP software allows these
// fields to be very long. If they are too long, we cut them off. This way
// we can at least see these users and their activities.
- validate('name', truncate(x.name, nameLength), $.optional.nullable.str);
- validate('summary', truncate(x.summary, summaryLength), $.optional.nullable.str);
+ validate('name', truncate(x.name, nameLength), $.default.optional.nullable.str);
+ validate('summary', truncate(x.summary, summaryLength), $.default.optional.nullable.str);
const idHost = toPuny(new URL(x.id!).hostname);
if (idHost !== expectHost) {
@@ -199,7 +199,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise {
if (resolver == null) resolver = new Resolver();
diff --git a/packages/backend/src/remote/activitypub/models/tag.ts b/packages/backend/src/remote/activitypub/models/tag.ts
index fbc6b9b42..964dabad0 100644
--- a/packages/backend/src/remote/activitypub/models/tag.ts
+++ b/packages/backend/src/remote/activitypub/models/tag.ts
@@ -1,5 +1,5 @@
-import { toArray } from '@/prelude/array';
-import { IObject, isHashtag, IApHashtag } from '../type';
+import { toArray } from '@/prelude/array.js';
+import { IObject, isHashtag, IApHashtag } from '../type.js';
export function extractApHashtags(tags: IObject | IObject[] | null | undefined) {
if (tags == null) return [];
diff --git a/packages/backend/src/remote/activitypub/perform.ts b/packages/backend/src/remote/activitypub/perform.ts
index 01f0e3676..3e1881558 100644
--- a/packages/backend/src/remote/activitypub/perform.ts
+++ b/packages/backend/src/remote/activitypub/perform.ts
@@ -1,6 +1,6 @@
-import { IObject } from './type';
-import { IRemoteUser } from '@/models/entities/user';
-import { performActivity } from './kernel/index';
+import { IObject } from './type.js';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { performActivity } from './kernel/index.js';
export default async (actor: IRemoteUser, activity: IObject): Promise => {
await performActivity(actor, activity);
diff --git a/packages/backend/src/remote/activitypub/renderer/accept.ts b/packages/backend/src/remote/activitypub/renderer/accept.ts
index 3bce2165c..cb01f6a91 100644
--- a/packages/backend/src/remote/activitypub/renderer/accept.ts
+++ b/packages/backend/src/remote/activitypub/renderer/accept.ts
@@ -1,5 +1,5 @@
-import config from '@/config/index';
-import { User } from '@/models/entities/user';
+import config from '@/config/index.js';
+import { User } from '@/models/entities/user.js';
export default (object: any, user: { id: User['id']; host: null }) => ({
type: 'Accept',
diff --git a/packages/backend/src/remote/activitypub/renderer/add.ts b/packages/backend/src/remote/activitypub/renderer/add.ts
index 960daf842..ec4788429 100644
--- a/packages/backend/src/remote/activitypub/renderer/add.ts
+++ b/packages/backend/src/remote/activitypub/renderer/add.ts
@@ -1,5 +1,5 @@
-import config from '@/config/index';
-import { ILocalUser } from '@/models/entities/user';
+import config from '@/config/index.js';
+import { ILocalUser } from '@/models/entities/user.js';
export default (user: ILocalUser, target: any, object: any) => ({
type: 'Add',
diff --git a/packages/backend/src/remote/activitypub/renderer/announce.ts b/packages/backend/src/remote/activitypub/renderer/announce.ts
index ab113b48e..2709fea51 100644
--- a/packages/backend/src/remote/activitypub/renderer/announce.ts
+++ b/packages/backend/src/remote/activitypub/renderer/announce.ts
@@ -1,5 +1,5 @@
-import config from '@/config/index';
-import { Note } from '@/models/entities/note';
+import config from '@/config/index.js';
+import { Note } from '@/models/entities/note.js';
export default (object: any, note: Note) => {
const attributedTo = `${config.url}/users/${note.userId}`;
diff --git a/packages/backend/src/remote/activitypub/renderer/block.ts b/packages/backend/src/remote/activitypub/renderer/block.ts
index bfb831daa..10a4fde51 100644
--- a/packages/backend/src/remote/activitypub/renderer/block.ts
+++ b/packages/backend/src/remote/activitypub/renderer/block.ts
@@ -1,5 +1,5 @@
-import config from '@/config/index';
-import { ILocalUser, IRemoteUser } from '@/models/entities/user';
+import config from '@/config/index.js';
+import { ILocalUser, IRemoteUser } from '@/models/entities/user.js';
export default (blocker: ILocalUser, blockee: IRemoteUser) => ({
type: 'Block',
diff --git a/packages/backend/src/remote/activitypub/renderer/create.ts b/packages/backend/src/remote/activitypub/renderer/create.ts
index ac9e69af2..281a3cb2a 100644
--- a/packages/backend/src/remote/activitypub/renderer/create.ts
+++ b/packages/backend/src/remote/activitypub/renderer/create.ts
@@ -1,5 +1,5 @@
-import config from '@/config/index';
-import { Note } from '@/models/entities/note';
+import config from '@/config/index.js';
+import { Note } from '@/models/entities/note.js';
export default (object: any, note: Note) => {
const activity = {
diff --git a/packages/backend/src/remote/activitypub/renderer/delete.ts b/packages/backend/src/remote/activitypub/renderer/delete.ts
index 176a6f7e2..4edd3a880 100644
--- a/packages/backend/src/remote/activitypub/renderer/delete.ts
+++ b/packages/backend/src/remote/activitypub/renderer/delete.ts
@@ -1,5 +1,5 @@
-import config from '@/config/index';
-import { User } from '@/models/entities/user';
+import config from '@/config/index.js';
+import { User } from '@/models/entities/user.js';
export default (object: any, user: { id: User['id']; host: null }) => ({
type: 'Delete',
diff --git a/packages/backend/src/remote/activitypub/renderer/document.ts b/packages/backend/src/remote/activitypub/renderer/document.ts
index a9d86dea1..c973de4c4 100644
--- a/packages/backend/src/remote/activitypub/renderer/document.ts
+++ b/packages/backend/src/remote/activitypub/renderer/document.ts
@@ -1,5 +1,5 @@
-import { DriveFile } from '@/models/entities/drive-file';
-import { DriveFiles } from '@/models/index';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { DriveFiles } from '@/models/index.js';
export default (file: DriveFile) => ({
type: 'Document',
diff --git a/packages/backend/src/remote/activitypub/renderer/emoji.ts b/packages/backend/src/remote/activitypub/renderer/emoji.ts
index e7ae7d959..0bf15eefd 100644
--- a/packages/backend/src/remote/activitypub/renderer/emoji.ts
+++ b/packages/backend/src/remote/activitypub/renderer/emoji.ts
@@ -1,5 +1,5 @@
-import config from '@/config/index';
-import { Emoji } from '@/models/entities/emoji';
+import config from '@/config/index.js';
+import { Emoji } from '@/models/entities/emoji.js';
export default (emoji: Emoji) => ({
id: `${config.url}/emojis/${emoji.name}`,
diff --git a/packages/backend/src/remote/activitypub/renderer/flag.ts b/packages/backend/src/remote/activitypub/renderer/flag.ts
index 60ac49650..6fbc11580 100644
--- a/packages/backend/src/remote/activitypub/renderer/flag.ts
+++ b/packages/backend/src/remote/activitypub/renderer/flag.ts
@@ -1,7 +1,7 @@
-import config from '@/config/index';
-import { IObject, IActivity } from '@/remote/activitypub/type';
-import { ILocalUser, IRemoteUser } from '@/models/entities/user';
-import { getInstanceActor } from '@/services/instance-actor';
+import config from '@/config/index.js';
+import { IObject, IActivity } from '@/remote/activitypub/type.js';
+import { ILocalUser, IRemoteUser } from '@/models/entities/user.js';
+import { getInstanceActor } from '@/services/instance-actor.js';
// to anonymise reporters, the reporting actor must be a system user
// object has to be a uri or array of uris
diff --git a/packages/backend/src/remote/activitypub/renderer/follow-relay.ts b/packages/backend/src/remote/activitypub/renderer/follow-relay.ts
index 38800267b..2c9678090 100644
--- a/packages/backend/src/remote/activitypub/renderer/follow-relay.ts
+++ b/packages/backend/src/remote/activitypub/renderer/follow-relay.ts
@@ -1,6 +1,6 @@
-import config from '@/config/index';
-import { Relay } from '@/models/entities/relay';
-import { ILocalUser } from '@/models/entities/user';
+import config from '@/config/index.js';
+import { Relay } from '@/models/entities/relay.js';
+import { ILocalUser } from '@/models/entities/user.js';
export function renderFollowRelay(relay: Relay, relayActor: ILocalUser) {
const follow = {
diff --git a/packages/backend/src/remote/activitypub/renderer/follow-user.ts b/packages/backend/src/remote/activitypub/renderer/follow-user.ts
index e3dde7f7f..ad1d63b93 100644
--- a/packages/backend/src/remote/activitypub/renderer/follow-user.ts
+++ b/packages/backend/src/remote/activitypub/renderer/follow-user.ts
@@ -1,6 +1,6 @@
-import config from '@/config/index';
-import { Users } from '@/models/index';
-import { User } from '@/models/entities/user';
+import config from '@/config/index.js';
+import { Users } from '@/models/index.js';
+import { User } from '@/models/entities/user.js';
/**
* Convert (local|remote)(Follower|Followee)ID to URL
diff --git a/packages/backend/src/remote/activitypub/renderer/follow.ts b/packages/backend/src/remote/activitypub/renderer/follow.ts
index 5258df7e9..9e9692b77 100644
--- a/packages/backend/src/remote/activitypub/renderer/follow.ts
+++ b/packages/backend/src/remote/activitypub/renderer/follow.ts
@@ -1,6 +1,6 @@
-import config from '@/config/index';
-import { User } from '@/models/entities/user';
-import { Users } from '@/models/index';
+import config from '@/config/index.js';
+import { User } from '@/models/entities/user.js';
+import { Users } from '@/models/index.js';
export default (follower: { id: User['id']; host: User['host']; uri: User['host'] }, followee: { id: User['id']; host: User['host']; uri: User['host'] }, requestId?: string) => {
const follow = {
diff --git a/packages/backend/src/remote/activitypub/renderer/hashtag.ts b/packages/backend/src/remote/activitypub/renderer/hashtag.ts
index d83a8e68b..a7b441e00 100644
--- a/packages/backend/src/remote/activitypub/renderer/hashtag.ts
+++ b/packages/backend/src/remote/activitypub/renderer/hashtag.ts
@@ -1,4 +1,4 @@
-import config from '@/config/index';
+import config from '@/config/index.js';
export default (tag: string) => ({
type: 'Hashtag',
diff --git a/packages/backend/src/remote/activitypub/renderer/image.ts b/packages/backend/src/remote/activitypub/renderer/image.ts
index ee3860be8..c7d5a31a2 100644
--- a/packages/backend/src/remote/activitypub/renderer/image.ts
+++ b/packages/backend/src/remote/activitypub/renderer/image.ts
@@ -1,5 +1,5 @@
-import { DriveFile } from '@/models/entities/drive-file';
-import { DriveFiles } from '@/models/index';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { DriveFiles } from '@/models/index.js';
export default (file: DriveFile) => ({
type: 'Image',
diff --git a/packages/backend/src/remote/activitypub/renderer/index.ts b/packages/backend/src/remote/activitypub/renderer/index.ts
index cffc9bfe0..5f6933226 100644
--- a/packages/backend/src/remote/activitypub/renderer/index.ts
+++ b/packages/backend/src/remote/activitypub/renderer/index.ts
@@ -1,9 +1,9 @@
-import config from '@/config/index';
+import config from '@/config/index.js';
import { v4 as uuid } from 'uuid';
-import { IActivity } from '../type';
-import { LdSignature } from '../misc/ld-signature';
-import { getUserKeypair } from '@/misc/keypair-store';
-import { User } from '@/models/entities/user';
+import { IActivity } from '../type.js';
+import { LdSignature } from '../misc/ld-signature.js';
+import { getUserKeypair } from '@/misc/keypair-store.js';
+import { User } from '@/models/entities/user.js';
export const renderActivity = (x: any): IActivity | null => {
if (x == null) return null;
diff --git a/packages/backend/src/remote/activitypub/renderer/key.ts b/packages/backend/src/remote/activitypub/renderer/key.ts
index 51bc888dd..c4f3d464f 100644
--- a/packages/backend/src/remote/activitypub/renderer/key.ts
+++ b/packages/backend/src/remote/activitypub/renderer/key.ts
@@ -1,7 +1,7 @@
-import config from '@/config/index';
-import { ILocalUser } from '@/models/entities/user';
-import { UserKeypair } from '@/models/entities/user-keypair';
-import { createPublicKey } from 'crypto';
+import config from '@/config/index.js';
+import { ILocalUser } from '@/models/entities/user.js';
+import { UserKeypair } from '@/models/entities/user-keypair.js';
+import { createPublicKey } from 'node:crypto';
export default (user: ILocalUser, key: UserKeypair, postfix?: string) => ({
id: `${config.url}/users/${user.id}${postfix || '/publickey'}`,
diff --git a/packages/backend/src/remote/activitypub/renderer/like.ts b/packages/backend/src/remote/activitypub/renderer/like.ts
index 2e4da9d26..1bf36d470 100644
--- a/packages/backend/src/remote/activitypub/renderer/like.ts
+++ b/packages/backend/src/remote/activitypub/renderer/like.ts
@@ -1,8 +1,8 @@
-import config from '@/config/index';
-import { NoteReaction } from '@/models/entities/note-reaction';
-import { Note } from '@/models/entities/note';
-import { Emojis } from '@/models/index';
-import renderEmoji from './emoji';
+import config from '@/config/index.js';
+import { NoteReaction } from '@/models/entities/note-reaction.js';
+import { Note } from '@/models/entities/note.js';
+import { Emojis } from '@/models/index.js';
+import renderEmoji from './emoji.js';
export const renderLike = async (noteReaction: NoteReaction, note: Note) => {
const reaction = noteReaction.reaction;
diff --git a/packages/backend/src/remote/activitypub/renderer/mention.ts b/packages/backend/src/remote/activitypub/renderer/mention.ts
index 06d2d33e5..c7e62e884 100644
--- a/packages/backend/src/remote/activitypub/renderer/mention.ts
+++ b/packages/backend/src/remote/activitypub/renderer/mention.ts
@@ -1,6 +1,6 @@
-import config from '@/config/index';
-import { User, ILocalUser } from '@/models/entities/user';
-import { Users } from '@/models/index';
+import config from '@/config/index.js';
+import { User, ILocalUser } from '@/models/entities/user.js';
+import { Users } from '@/models/index.js';
export default (mention: User) => ({
type: 'Mention',
diff --git a/packages/backend/src/remote/activitypub/renderer/note.ts b/packages/backend/src/remote/activitypub/renderer/note.ts
index 654ab6812..c3d9e120d 100644
--- a/packages/backend/src/remote/activitypub/renderer/note.ts
+++ b/packages/backend/src/remote/activitypub/renderer/note.ts
@@ -1,15 +1,15 @@
-import renderDocument from './document';
-import renderHashtag from './hashtag';
-import renderMention from './mention';
-import renderEmoji from './emoji';
-import config from '@/config/index';
-import toHtml from '../misc/get-note-html';
-import { Note, IMentionedRemoteUsers } from '@/models/entities/note';
-import { DriveFile } from '@/models/entities/drive-file';
-import { DriveFiles, Notes, Users, Emojis, Polls } from '@/models/index';
+import renderDocument from './document.js';
+import renderHashtag from './hashtag.js';
+import renderMention from './mention.js';
+import renderEmoji from './emoji.js';
+import config from '@/config/index.js';
+import toHtml from '../misc/get-note-html.js';
+import { Note, IMentionedRemoteUsers } from '@/models/entities/note.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { DriveFiles, Notes, Users, Emojis, Polls } from '@/models/index.js';
import { In } from 'typeorm';
-import { Emoji } from '@/models/entities/emoji';
-import { Poll } from '@/models/entities/poll';
+import { Emoji } from '@/models/entities/emoji.js';
+import { Poll } from '@/models/entities/poll.js';
export default async function renderNote(note: Note, dive = true, isTalk = false): Promise> {
const getPromisedFiles = async (ids: string[]) => {
diff --git a/packages/backend/src/remote/activitypub/renderer/person.ts b/packages/backend/src/remote/activitypub/renderer/person.ts
index d1c4c0040..3d86e37cc 100644
--- a/packages/backend/src/remote/activitypub/renderer/person.ts
+++ b/packages/backend/src/remote/activitypub/renderer/person.ts
@@ -1,16 +1,16 @@
-import { URL } from 'url';
+import { URL } from 'node:url';
import * as mfm from 'mfm-js';
-import renderImage from './image';
-import renderKey from './key';
-import config from '@/config/index';
-import { ILocalUser } from '@/models/entities/user';
-import { toHtml } from '../../../mfm/to-html';
-import { getEmojis } from './note';
-import renderEmoji from './emoji';
-import { IIdentifier } from '../models/identifier';
-import renderHashtag from './hashtag';
-import { DriveFiles, UserProfiles } from '@/models/index';
-import { getUserKeypair } from '@/misc/keypair-store';
+import renderImage from './image.js';
+import renderKey from './key.js';
+import config from '@/config/index.js';
+import { ILocalUser } from '@/models/entities/user.js';
+import { toHtml } from '../../../mfm/to-html.js';
+import { getEmojis } from './note.js';
+import renderEmoji from './emoji.js';
+import { IIdentifier } from '../models/identifier.js';
+import renderHashtag from './hashtag.js';
+import { DriveFiles, UserProfiles } from '@/models/index.js';
+import { getUserKeypair } from '@/misc/keypair-store.js';
export async function renderPerson(user: ILocalUser) {
const id = `${config.url}/users/${user.id}`;
diff --git a/packages/backend/src/remote/activitypub/renderer/question.ts b/packages/backend/src/remote/activitypub/renderer/question.ts
index 3cbff33ab..d4d1b590a 100644
--- a/packages/backend/src/remote/activitypub/renderer/question.ts
+++ b/packages/backend/src/remote/activitypub/renderer/question.ts
@@ -1,7 +1,7 @@
-import config from '@/config/index';
-import { User } from '@/models/entities/user';
-import { Note } from '@/models/entities/note';
-import { Poll } from '@/models/entities/poll';
+import config from '@/config/index.js';
+import { User } from '@/models/entities/user.js';
+import { Note } from '@/models/entities/note.js';
+import { Poll } from '@/models/entities/poll.js';
export default async function renderQuestion(user: { id: User['id'] }, note: Note, poll: Poll) {
const question = {
diff --git a/packages/backend/src/remote/activitypub/renderer/read.ts b/packages/backend/src/remote/activitypub/renderer/read.ts
index 2fe3b8e5e..a30e649f6 100644
--- a/packages/backend/src/remote/activitypub/renderer/read.ts
+++ b/packages/backend/src/remote/activitypub/renderer/read.ts
@@ -1,6 +1,6 @@
-import config from '@/config/index';
-import { User } from '@/models/entities/user';
-import { MessagingMessage } from '@/models/entities/messaging-message';
+import config from '@/config/index.js';
+import { User } from '@/models/entities/user.js';
+import { MessagingMessage } from '@/models/entities/messaging-message.js';
export const renderReadActivity = (user: { id: User['id'] }, message: MessagingMessage) => ({
type: 'Read',
diff --git a/packages/backend/src/remote/activitypub/renderer/reject.ts b/packages/backend/src/remote/activitypub/renderer/reject.ts
index 575ef52ab..ab4cc1646 100644
--- a/packages/backend/src/remote/activitypub/renderer/reject.ts
+++ b/packages/backend/src/remote/activitypub/renderer/reject.ts
@@ -1,5 +1,5 @@
-import config from '@/config/index';
-import { User } from '@/models/entities/user';
+import config from '@/config/index.js';
+import { User } from '@/models/entities/user.js';
export default (object: any, user: { id: User['id'] }) => ({
type: 'Reject',
diff --git a/packages/backend/src/remote/activitypub/renderer/remove.ts b/packages/backend/src/remote/activitypub/renderer/remove.ts
index 8afaf199c..1be3edc5d 100644
--- a/packages/backend/src/remote/activitypub/renderer/remove.ts
+++ b/packages/backend/src/remote/activitypub/renderer/remove.ts
@@ -1,5 +1,5 @@
-import config from '@/config/index';
-import { User } from '@/models/entities/user';
+import config from '@/config/index.js';
+import { User } from '@/models/entities/user.js';
export default (user: { id: User['id'] }, target: any, object: any) => ({
type: 'Remove',
diff --git a/packages/backend/src/remote/activitypub/renderer/undo.ts b/packages/backend/src/remote/activitypub/renderer/undo.ts
index 14115b788..d28778e22 100644
--- a/packages/backend/src/remote/activitypub/renderer/undo.ts
+++ b/packages/backend/src/remote/activitypub/renderer/undo.ts
@@ -1,5 +1,5 @@
-import config from '@/config/index';
-import { ILocalUser, User } from '@/models/entities/user';
+import config from '@/config/index.js';
+import { ILocalUser, User } from '@/models/entities/user.js';
export default (object: any, user: { id: User['id'] }) => {
if (object == null) return null;
diff --git a/packages/backend/src/remote/activitypub/renderer/update.ts b/packages/backend/src/remote/activitypub/renderer/update.ts
index 8bb415d11..cf880f03f 100644
--- a/packages/backend/src/remote/activitypub/renderer/update.ts
+++ b/packages/backend/src/remote/activitypub/renderer/update.ts
@@ -1,5 +1,5 @@
-import config from '@/config/index';
-import { User } from '@/models/entities/user';
+import config from '@/config/index.js';
+import { User } from '@/models/entities/user.js';
export default (object: any, user: { id: User['id'] }) => {
const activity = {
diff --git a/packages/backend/src/remote/activitypub/renderer/vote.ts b/packages/backend/src/remote/activitypub/renderer/vote.ts
index fd7bc9dbe..b6eb8e095 100644
--- a/packages/backend/src/remote/activitypub/renderer/vote.ts
+++ b/packages/backend/src/remote/activitypub/renderer/vote.ts
@@ -1,8 +1,8 @@
-import config from '@/config/index';
-import { Note } from '@/models/entities/note';
-import { IRemoteUser, User } from '@/models/entities/user';
-import { PollVote } from '@/models/entities/poll-vote';
-import { Poll } from '@/models/entities/poll';
+import config from '@/config/index.js';
+import { Note } from '@/models/entities/note.js';
+import { IRemoteUser, User } from '@/models/entities/user.js';
+import { PollVote } from '@/models/entities/poll-vote.js';
+import { Poll } from '@/models/entities/poll.js';
export default async function renderVote(user: { id: User['id'] }, vote: PollVote, note: Note, poll: Poll, pollOwner: IRemoteUser): Promise {
return {
diff --git a/packages/backend/src/remote/activitypub/request.ts b/packages/backend/src/remote/activitypub/request.ts
index 715937e2a..5cbfd8c25 100644
--- a/packages/backend/src/remote/activitypub/request.ts
+++ b/packages/backend/src/remote/activitypub/request.ts
@@ -1,8 +1,8 @@
-import config from '@/config/index';
-import { getUserKeypair } from '@/misc/keypair-store';
-import { User } from '@/models/entities/user';
-import { getResponse } from '../../misc/fetch';
-import { createSignedPost, createSignedGet } from './ap-request';
+import config from '@/config/index.js';
+import { getUserKeypair } from '@/misc/keypair-store.js';
+import { User } from '@/models/entities/user.js';
+import { getResponse } from '../../misc/fetch.js';
+import { createSignedPost, createSignedGet } from './ap-request.js';
export default async (user: { id: User['id'] }, url: string, object: any) => {
const body = JSON.stringify(object);
diff --git a/packages/backend/src/remote/activitypub/resolver.ts b/packages/backend/src/remote/activitypub/resolver.ts
index f392a65e3..c1269c75c 100644
--- a/packages/backend/src/remote/activitypub/resolver.ts
+++ b/packages/backend/src/remote/activitypub/resolver.ts
@@ -1,11 +1,11 @@
-import config from '@/config/index';
-import { getJson } from '@/misc/fetch';
-import { ILocalUser } from '@/models/entities/user';
-import { getInstanceActor } from '@/services/instance-actor';
-import { signedGet } from './request';
-import { IObject, isCollectionOrOrderedCollection, ICollection, IOrderedCollection } from './type';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { extractDbHost } from '@/misc/convert-host';
+import config from '@/config/index.js';
+import { getJson } from '@/misc/fetch.js';
+import { ILocalUser } from '@/models/entities/user.js';
+import { getInstanceActor } from '@/services/instance-actor.js';
+import { signedGet } from './request.js';
+import { IObject, isCollectionOrOrderedCollection, ICollection, IOrderedCollection } from './type.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { extractDbHost } from '@/misc/convert-host.js';
export default class Resolver {
private history: Set;
diff --git a/packages/backend/src/remote/logger.ts b/packages/backend/src/remote/logger.ts
index 9ffad4d71..4921f53bd 100644
--- a/packages/backend/src/remote/logger.ts
+++ b/packages/backend/src/remote/logger.ts
@@ -1,3 +1,3 @@
-import Logger from '@/services/logger';
+import Logger from '@/services/logger.js';
export const remoteLogger = new Logger('remote', 'cyan');
diff --git a/packages/backend/src/remote/resolve-user.ts b/packages/backend/src/remote/resolve-user.ts
index 747735eca..aa37013c4 100644
--- a/packages/backend/src/remote/resolve-user.ts
+++ b/packages/backend/src/remote/resolve-user.ts
@@ -1,12 +1,12 @@
-import { URL } from 'url';
-import webFinger from './webfinger';
-import config from '@/config/index';
-import { createPerson, updatePerson } from './activitypub/models/person';
-import { remoteLogger } from './logger';
-import * as chalk from 'chalk';
-import { User, IRemoteUser } from '@/models/entities/user';
-import { Users } from '@/models/index';
-import { toPuny } from '@/misc/convert-host';
+import { URL } from 'node:url';
+import webFinger from './webfinger.js';
+import config from '@/config/index.js';
+import { createPerson, updatePerson } from './activitypub/models/person.js';
+import { remoteLogger } from './logger.js';
+import chalk from 'chalk';
+import { User, IRemoteUser } from '@/models/entities/user.js';
+import { Users } from '@/models/index.js';
+import { toPuny } from '@/misc/convert-host.js';
const logger = remoteLogger.createSubLogger('resolve-user');
@@ -26,7 +26,7 @@ export async function resolveUser(username: string, host: string | null, option?
host = toPuny(host);
- if (config.host == host) {
+ if (config.host === host) {
logger.info(`return local user: ${usernameLower}`);
return await Users.findOne({ usernameLower, host: null }).then(u => {
if (u == null) {
diff --git a/packages/backend/src/remote/webfinger.ts b/packages/backend/src/remote/webfinger.ts
index f63fd0362..9d3bfab24 100644
--- a/packages/backend/src/remote/webfinger.ts
+++ b/packages/backend/src/remote/webfinger.ts
@@ -1,6 +1,6 @@
-import { URL } from 'url';
-import { getJson } from '@/misc/fetch';
-import { query as urlQuery } from '@/prelude/url';
+import { URL } from 'node:url';
+import { getJson } from '@/misc/fetch.js';
+import { query as urlQuery } from '@/prelude/url.js';
type ILink = {
href: string;
diff --git a/packages/backend/src/server/activitypub.ts b/packages/backend/src/server/activitypub.ts
index bbbc231b8..21be0a251 100644
--- a/packages/backend/src/server/activitypub.ts
+++ b/packages/backend/src/server/activitypub.ts
@@ -1,23 +1,23 @@
-import * as Router from '@koa/router';
-import * as json from 'koa-json-body';
-import * as httpSignature from 'http-signature';
+import Router from '@koa/router';
+import json from 'koa-json-body';
+import httpSignature from 'http-signature';
-import { renderActivity } from '@/remote/activitypub/renderer/index';
-import renderNote from '@/remote/activitypub/renderer/note';
-import renderKey from '@/remote/activitypub/renderer/key';
-import { renderPerson } from '@/remote/activitypub/renderer/person';
-import renderEmoji from '@/remote/activitypub/renderer/emoji';
-import Outbox, { packActivity } from './activitypub/outbox';
-import Followers from './activitypub/followers';
-import Following from './activitypub/following';
-import Featured from './activitypub/featured';
-import { inbox as processInbox } from '@/queue/index';
-import { isSelfHost } from '@/misc/convert-host';
-import { Notes, Users, Emojis, NoteReactions } from '@/models/index';
-import { ILocalUser, User } from '@/models/entities/user';
+import { renderActivity } from '@/remote/activitypub/renderer/index.js';
+import renderNote from '@/remote/activitypub/renderer/note.js';
+import renderKey from '@/remote/activitypub/renderer/key.js';
+import { renderPerson } from '@/remote/activitypub/renderer/person.js';
+import renderEmoji from '@/remote/activitypub/renderer/emoji.js';
+import Outbox, { packActivity } from './activitypub/outbox.js';
+import Followers from './activitypub/followers.js';
+import Following from './activitypub/following.js';
+import Featured from './activitypub/featured.js';
+import { inbox as processInbox } from '@/queue/index.js';
+import { isSelfHost } from '@/misc/convert-host.js';
+import { Notes, Users, Emojis, NoteReactions } from '@/models/index.js';
+import { ILocalUser, User } from '@/models/entities/user.js';
import { In } from 'typeorm';
-import { renderLike } from '@/remote/activitypub/renderer/like';
-import { getUserKeypair } from '@/misc/keypair-store';
+import { renderLike } from '@/remote/activitypub/renderer/like.js';
+import { getUserKeypair } from '@/misc/keypair-store.js';
// Init router
const router = new Router();
diff --git a/packages/backend/src/server/activitypub/featured.ts b/packages/backend/src/server/activitypub/featured.ts
index ed5bfc426..129881a71 100644
--- a/packages/backend/src/server/activitypub/featured.ts
+++ b/packages/backend/src/server/activitypub/featured.ts
@@ -1,10 +1,10 @@
-import * as Router from '@koa/router';
-import config from '@/config/index';
-import { renderActivity } from '@/remote/activitypub/renderer/index';
-import renderOrderedCollection from '@/remote/activitypub/renderer/ordered-collection';
-import { setResponseType } from '../activitypub';
-import renderNote from '@/remote/activitypub/renderer/note';
-import { Users, Notes, UserNotePinings } from '@/models/index';
+import Router from '@koa/router';
+import config from '@/config/index.js';
+import { renderActivity } from '@/remote/activitypub/renderer/index.js';
+import renderOrderedCollection from '@/remote/activitypub/renderer/ordered-collection.js';
+import { setResponseType } from '../activitypub.js';
+import renderNote from '@/remote/activitypub/renderer/note.js';
+import { Users, Notes, UserNotePinings } from '@/models/index.js';
export default async (ctx: Router.RouterContext) => {
const userId = ctx.params.user;
diff --git a/packages/backend/src/server/activitypub/followers.ts b/packages/backend/src/server/activitypub/followers.ts
index 927fb5d18..5d1d7c59e 100644
--- a/packages/backend/src/server/activitypub/followers.ts
+++ b/packages/backend/src/server/activitypub/followers.ts
@@ -1,24 +1,24 @@
-import * as Router from '@koa/router';
-import config from '@/config/index';
+import Router from '@koa/router';
+import config from '@/config/index.js';
import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import * as url from '@/prelude/url';
-import { renderActivity } from '@/remote/activitypub/renderer/index';
-import renderOrderedCollection from '@/remote/activitypub/renderer/ordered-collection';
-import renderOrderedCollectionPage from '@/remote/activitypub/renderer/ordered-collection-page';
-import renderFollowUser from '@/remote/activitypub/renderer/follow-user';
-import { setResponseType } from '../activitypub';
-import { Users, Followings, UserProfiles } from '@/models/index';
+import { ID } from '@/misc/cafy-id.js';
+import * as url from '@/prelude/url.js';
+import { renderActivity } from '@/remote/activitypub/renderer/index.js';
+import renderOrderedCollection from '@/remote/activitypub/renderer/ordered-collection.js';
+import renderOrderedCollectionPage from '@/remote/activitypub/renderer/ordered-collection-page.js';
+import renderFollowUser from '@/remote/activitypub/renderer/follow-user.js';
+import { setResponseType } from '../activitypub.js';
+import { Users, Followings, UserProfiles } from '@/models/index.js';
import { LessThan } from 'typeorm';
export default async (ctx: Router.RouterContext) => {
const userId = ctx.params.user;
// Get 'cursor' parameter
- const [cursor, cursorErr] = $.optional.type(ID).get(ctx.request.query.cursor);
+ const [cursor, cursorErr] = $.default.optional.type(ID).get(ctx.request.query.cursor);
// Get 'page' parameter
- const pageErr = !$.optional.str.or(['true', 'false']).ok(ctx.request.query.page);
+ const pageErr = !$.default.optional.str.or(['true', 'false']).ok(ctx.request.query.page);
const page: boolean = ctx.request.query.page === 'true';
// Validate parameters
diff --git a/packages/backend/src/server/activitypub/following.ts b/packages/backend/src/server/activitypub/following.ts
index a3237582a..23110ce87 100644
--- a/packages/backend/src/server/activitypub/following.ts
+++ b/packages/backend/src/server/activitypub/following.ts
@@ -1,25 +1,25 @@
-import * as Router from '@koa/router';
-import config from '@/config/index';
+import Router from '@koa/router';
+import config from '@/config/index.js';
import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import * as url from '@/prelude/url';
-import { renderActivity } from '@/remote/activitypub/renderer/index';
-import renderOrderedCollection from '@/remote/activitypub/renderer/ordered-collection';
-import renderOrderedCollectionPage from '@/remote/activitypub/renderer/ordered-collection-page';
-import renderFollowUser from '@/remote/activitypub/renderer/follow-user';
-import { setResponseType } from '../activitypub';
-import { Users, Followings, UserProfiles } from '@/models/index';
+import { ID } from '@/misc/cafy-id.js';
+import * as url from '@/prelude/url.js';
+import { renderActivity } from '@/remote/activitypub/renderer/index.js';
+import renderOrderedCollection from '@/remote/activitypub/renderer/ordered-collection.js';
+import renderOrderedCollectionPage from '@/remote/activitypub/renderer/ordered-collection-page.js';
+import renderFollowUser from '@/remote/activitypub/renderer/follow-user.js';
+import { setResponseType } from '../activitypub.js';
+import { Users, Followings, UserProfiles } from '@/models/index.js';
import { LessThan, FindConditions } from 'typeorm';
-import { Following } from '@/models/entities/following';
+import { Following } from '@/models/entities/following.js';
export default async (ctx: Router.RouterContext) => {
const userId = ctx.params.user;
// Get 'cursor' parameter
- const [cursor, cursorErr] = $.optional.type(ID).get(ctx.request.query.cursor);
+ const [cursor, cursorErr] = $.default.optional.type(ID).get(ctx.request.query.cursor);
// Get 'page' parameter
- const pageErr = !$.optional.str.or(['true', 'false']).ok(ctx.request.query.page);
+ const pageErr = !$.default.optional.str.or(['true', 'false']).ok(ctx.request.query.page);
const page: boolean = ctx.request.query.page === 'true';
// Validate parameters
diff --git a/packages/backend/src/server/activitypub/outbox.ts b/packages/backend/src/server/activitypub/outbox.ts
index ba6b46a0c..57c126752 100644
--- a/packages/backend/src/server/activitypub/outbox.ts
+++ b/packages/backend/src/server/activitypub/outbox.ts
@@ -1,32 +1,32 @@
-import * as Router from '@koa/router';
-import config from '@/config/index';
+import Router from '@koa/router';
+import config from '@/config/index.js';
import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { renderActivity } from '@/remote/activitypub/renderer/index';
-import renderOrderedCollection from '@/remote/activitypub/renderer/ordered-collection';
-import renderOrderedCollectionPage from '@/remote/activitypub/renderer/ordered-collection-page';
-import { setResponseType } from '../activitypub';
-import renderNote from '@/remote/activitypub/renderer/note';
-import renderCreate from '@/remote/activitypub/renderer/create';
-import renderAnnounce from '@/remote/activitypub/renderer/announce';
-import { countIf } from '@/prelude/array';
-import * as url from '@/prelude/url';
-import { Users, Notes } from '@/models/index';
-import { makePaginationQuery } from '../api/common/make-pagination-query';
+import { ID } from '@/misc/cafy-id.js';
+import { renderActivity } from '@/remote/activitypub/renderer/index.js';
+import renderOrderedCollection from '@/remote/activitypub/renderer/ordered-collection.js';
+import renderOrderedCollectionPage from '@/remote/activitypub/renderer/ordered-collection-page.js';
+import { setResponseType } from '../activitypub.js';
+import renderNote from '@/remote/activitypub/renderer/note.js';
+import renderCreate from '@/remote/activitypub/renderer/create.js';
+import renderAnnounce from '@/remote/activitypub/renderer/announce.js';
+import { countIf } from '@/prelude/array.js';
+import * as url from '@/prelude/url.js';
+import { Users, Notes } from '@/models/index.js';
+import { makePaginationQuery } from '../api/common/make-pagination-query.js';
import { Brackets } from 'typeorm';
-import { Note } from '@/models/entities/note';
+import { Note } from '@/models/entities/note.js';
export default async (ctx: Router.RouterContext) => {
const userId = ctx.params.user;
// Get 'sinceId' parameter
- const [sinceId, sinceIdErr] = $.optional.type(ID).get(ctx.request.query.since_id);
+ const [sinceId, sinceIdErr] = $.default.optional.type(ID).get(ctx.request.query.since_id);
// Get 'untilId' parameter
- const [untilId, untilIdErr] = $.optional.type(ID).get(ctx.request.query.until_id);
+ const [untilId, untilIdErr] = $.default.optional.type(ID).get(ctx.request.query.until_id);
// Get 'page' parameter
- const pageErr = !$.optional.str.or(['true', 'false']).ok(ctx.request.query.page);
+ const pageErr = !$.default.optional.str.or(['true', 'false']).ok(ctx.request.query.page);
const page: boolean = ctx.request.query.page === 'true';
// Validate parameters
diff --git a/packages/backend/src/server/api/2fa.ts b/packages/backend/src/server/api/2fa.ts
index 2a69e49c8..e1c226979 100644
--- a/packages/backend/src/server/api/2fa.ts
+++ b/packages/backend/src/server/api/2fa.ts
@@ -1,5 +1,5 @@
-import * as crypto from 'crypto';
-import config from '@/config/index';
+import * as crypto from 'node:crypto';
+import config from '@/config/index.js';
import * as jsrsasign from 'jsrsasign';
const ECC_PRELUDE = Buffer.from([0x04]);
diff --git a/packages/backend/src/server/api/api-handler.ts b/packages/backend/src/server/api/api-handler.ts
index 362bbb0f5..f97c3dd39 100644
--- a/packages/backend/src/server/api/api-handler.ts
+++ b/packages/backend/src/server/api/api-handler.ts
@@ -1,11 +1,11 @@
-import * as Koa from 'koa';
+import Koa from 'koa';
-import { IEndpoint } from './endpoints';
-import authenticate, { AuthenticationError } from './authenticate';
-import call from './call';
-import { ApiError } from './error';
+import { IEndpoint } from './endpoints.js';
+import authenticate, { AuthenticationError } from './authenticate.js';
+import call from './call.js';
+import { ApiError } from './error.js';
-export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise((res) => {
+export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise((res) => {
const body = ctx.request.body;
const reply = (x?: any, y?: ApiError) => {
diff --git a/packages/backend/src/server/api/authenticate.ts b/packages/backend/src/server/api/authenticate.ts
index 9e2f3eb74..7fdf14666 100644
--- a/packages/backend/src/server/api/authenticate.ts
+++ b/packages/backend/src/server/api/authenticate.ts
@@ -1,7 +1,7 @@
-import isNativeToken from './common/is-native-token';
-import { User } from '@/models/entities/user';
-import { Users, AccessTokens, Apps } from '@/models/index';
-import { AccessToken } from '@/models/entities/access-token';
+import isNativeToken from './common/is-native-token.js';
+import { User } from '@/models/entities/user.js';
+import { Users, AccessTokens, Apps } from '@/models/index.js';
+import { AccessToken } from '@/models/entities/access-token.js';
export class AuthenticationError extends Error {
constructor(message: string) {
diff --git a/packages/backend/src/server/api/call.ts b/packages/backend/src/server/api/call.ts
index 18143340a..5c5ef6601 100644
--- a/packages/backend/src/server/api/call.ts
+++ b/packages/backend/src/server/api/call.ts
@@ -1,11 +1,11 @@
-import * as Koa from 'koa';
+import Koa from 'koa';
import { performance } from 'perf_hooks';
-import { limiter } from './limiter';
-import { User } from '@/models/entities/user';
-import endpoints from './endpoints';
-import { ApiError } from './error';
-import { apiLogger } from './logger';
-import { AccessToken } from '@/models/entities/access-token';
+import { limiter } from './limiter.js';
+import { User } from '@/models/entities/user.js';
+import endpoints, { IEndpoint } from './endpoints.js';
+import { ApiError } from './error.js';
+import { apiLogger } from './logger.js';
+import { AccessToken } from '@/models/entities/access-token.js';
const accessDenied = {
message: 'Access denied.',
@@ -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) {
// Rate limit
- await limiter(ep, user!).catch(e => {
+ await limiter(ep as IEndpoint & { meta: { limit: NonNullable } }, user!).catch(e => {
throw new ApiError({
message: 'Rate limit exceeded. Please try again later.',
code: 'RATE_LIMIT_EXCEEDED',
@@ -78,10 +78,10 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
}
// Cast non JSON input
- if (ep.meta.requireFile && ep.meta.params) {
- for (const k of Object.keys(ep.meta.params)) {
- const param = ep.meta.params[k];
- if (['Boolean', 'Number'].includes(param.validator.name) && typeof data[k] === 'string') {
+ if (ep.meta.requireFile && ep.params.properties) {
+ for (const k of Object.keys(ep.params.properties)) {
+ const param = ep.params.properties![k];
+ if (['boolean', 'number', 'integer'].includes(param.type ?? '') && typeof data[k] === 'string') {
try {
data[k] = JSON.parse(data[k]);
} catch (e) {
@@ -91,8 +91,8 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
id: '0b5f1631-7c1a-41a6-b399-cce335f34d85',
}, {
param: k,
- reason: `cannot cast to ${param.validator.name}`,
- })
+ reason: `cannot cast to ${param.type}`,
+ });
}
}
}
diff --git a/packages/backend/src/server/api/common/generate-block-query.ts b/packages/backend/src/server/api/common/generate-block-query.ts
index 4fd618473..60db1e731 100644
--- a/packages/backend/src/server/api/common/generate-block-query.ts
+++ b/packages/backend/src/server/api/common/generate-block-query.ts
@@ -1,5 +1,5 @@
-import { User } from '@/models/entities/user';
-import { Blockings } from '@/models/index';
+import { User } from '@/models/entities/user.js';
+import { Blockings } from '@/models/index.js';
import { Brackets, SelectQueryBuilder } from 'typeorm';
// ここでいうBlockedは被Blockedの意
diff --git a/packages/backend/src/server/api/common/generate-channel-query.ts b/packages/backend/src/server/api/common/generate-channel-query.ts
index 80a0acf7f..333bb73b8 100644
--- a/packages/backend/src/server/api/common/generate-channel-query.ts
+++ b/packages/backend/src/server/api/common/generate-channel-query.ts
@@ -1,5 +1,5 @@
-import { User } from '@/models/entities/user';
-import { ChannelFollowings } from '@/models/index';
+import { User } from '@/models/entities/user.js';
+import { ChannelFollowings } from '@/models/index.js';
import { Brackets, SelectQueryBuilder } from 'typeorm';
export function generateChannelQuery(q: SelectQueryBuilder, me?: { id: User['id'] } | null) {
diff --git a/packages/backend/src/server/api/common/generate-muted-instance-query.ts b/packages/backend/src/server/api/common/generate-muted-instance-query.ts
index dbc9fc98f..72a6fec68 100644
--- a/packages/backend/src/server/api/common/generate-muted-instance-query.ts
+++ b/packages/backend/src/server/api/common/generate-muted-instance-query.ts
@@ -1,6 +1,6 @@
-import { User } from '@/models/entities/user';
-import { id } from '@/models/id';
-import { UserProfiles } from '@/models/index';
+import { User } from '@/models/entities/user.js';
+import { id } from '@/models/id.js';
+import { UserProfiles } from '@/models/index.js';
import { SelectQueryBuilder, Brackets } from 'typeorm';
function createMutesQuery(id: string) {
diff --git a/packages/backend/src/server/api/common/generate-muted-note-query.ts b/packages/backend/src/server/api/common/generate-muted-note-query.ts
index 073784261..f544e334d 100644
--- a/packages/backend/src/server/api/common/generate-muted-note-query.ts
+++ b/packages/backend/src/server/api/common/generate-muted-note-query.ts
@@ -1,5 +1,5 @@
-import { User } from '@/models/entities/user';
-import { MutedNotes } from '@/models/index';
+import { User } from '@/models/entities/user.js';
+import { MutedNotes } from '@/models/index.js';
import { SelectQueryBuilder } from 'typeorm';
export function generateMutedNoteQuery(q: SelectQueryBuilder, me: { id: User['id'] }) {
diff --git a/packages/backend/src/server/api/common/generate-muted-note-thread-query.ts b/packages/backend/src/server/api/common/generate-muted-note-thread-query.ts
index 7e2cbd498..7263ea2e6 100644
--- a/packages/backend/src/server/api/common/generate-muted-note-thread-query.ts
+++ b/packages/backend/src/server/api/common/generate-muted-note-thread-query.ts
@@ -1,5 +1,5 @@
-import { User } from '@/models/entities/user';
-import { NoteThreadMutings } from '@/models/index';
+import { User } from '@/models/entities/user.js';
+import { NoteThreadMutings } from '@/models/index.js';
import { Brackets, SelectQueryBuilder } from 'typeorm';
export function generateMutedNoteThreadQuery(q: SelectQueryBuilder, me: { id: User['id'] }) {
diff --git a/packages/backend/src/server/api/common/generate-muted-user-query.ts b/packages/backend/src/server/api/common/generate-muted-user-query.ts
index 7e200b87e..79cb3ff89 100644
--- a/packages/backend/src/server/api/common/generate-muted-user-query.ts
+++ b/packages/backend/src/server/api/common/generate-muted-user-query.ts
@@ -1,5 +1,5 @@
-import { User } from '@/models/entities/user';
-import { Mutings } from '@/models/index';
+import { User } from '@/models/entities/user.js';
+import { Mutings } from '@/models/index.js';
import { SelectQueryBuilder, Brackets } from 'typeorm';
export function generateMutedUserQuery(q: SelectQueryBuilder, me: { id: User['id'] }, exclude?: User) {
diff --git a/packages/backend/src/server/api/common/generate-native-user-token.ts b/packages/backend/src/server/api/common/generate-native-user-token.ts
index 1f791c57c..5d8a4c537 100644
--- a/packages/backend/src/server/api/common/generate-native-user-token.ts
+++ b/packages/backend/src/server/api/common/generate-native-user-token.ts
@@ -1,3 +1,3 @@
-import { secureRndstr } from '@/misc/secure-rndstr';
+import { secureRndstr } from '@/misc/secure-rndstr.js';
export default () => secureRndstr(16, true);
diff --git a/packages/backend/src/server/api/common/generate-replies-query.ts b/packages/backend/src/server/api/common/generate-replies-query.ts
index 249064d58..301782eab 100644
--- a/packages/backend/src/server/api/common/generate-replies-query.ts
+++ b/packages/backend/src/server/api/common/generate-replies-query.ts
@@ -1,4 +1,4 @@
-import { User } from '@/models/entities/user';
+import { User } from '@/models/entities/user.js';
import { Brackets, SelectQueryBuilder } from 'typeorm';
export function generateRepliesQuery(q: SelectQueryBuilder, me?: Pick | null) {
@@ -10,7 +10,7 @@ export function generateRepliesQuery(q: SelectQueryBuilder, me?: Pick { qb
.where(`note.replyId IS NULL`) // 返信ではない
.orWhere('note.replyUserId = :meId', { meId: me.id }) // 返信だけど自分のノートへの返信
diff --git a/packages/backend/src/server/api/common/generate-visibility-query.ts b/packages/backend/src/server/api/common/generate-visibility-query.ts
index 813e8b6c0..715982934 100644
--- a/packages/backend/src/server/api/common/generate-visibility-query.ts
+++ b/packages/backend/src/server/api/common/generate-visibility-query.ts
@@ -1,5 +1,5 @@
-import { User } from '@/models/entities/user';
-import { Followings } from '@/models/index';
+import { User } from '@/models/entities/user.js';
+import { Followings } from '@/models/index.js';
import { Brackets, SelectQueryBuilder } from 'typeorm';
export function generateVisibilityQuery(q: SelectQueryBuilder, me?: { id: User['id'] } | null) {
diff --git a/packages/backend/src/server/api/common/getters.ts b/packages/backend/src/server/api/common/getters.ts
index 4b2ee8f1d..c5a47876d 100644
--- a/packages/backend/src/server/api/common/getters.ts
+++ b/packages/backend/src/server/api/common/getters.ts
@@ -1,7 +1,7 @@
-import { IdentifiableError } from '@/misc/identifiable-error';
-import { User } from '@/models/entities/user';
-import { Note } from '@/models/entities/note';
-import { Notes, Users } from '@/models/index';
+import { IdentifiableError } from '@/misc/identifiable-error.js';
+import { User } from '@/models/entities/user.js';
+import { Note } from '@/models/entities/note.js';
+import { Notes, Users } from '@/models/index.js';
/**
* Get note for API processing
diff --git a/packages/backend/src/server/api/common/inject-featured.ts b/packages/backend/src/server/api/common/inject-featured.ts
index 1dc13c83e..b7dd8028b 100644
--- a/packages/backend/src/server/api/common/inject-featured.ts
+++ b/packages/backend/src/server/api/common/inject-featured.ts
@@ -1,9 +1,9 @@
import rndstr from 'rndstr';
-import { Note } from '@/models/entities/note';
-import { User } from '@/models/entities/user';
-import { Notes, UserProfiles, NoteReactions } from '@/models/index';
-import { generateMutedUserQuery } from './generate-muted-user-query';
-import { generateBlockedUserQuery } from './generate-block-query';
+import { Note } from '@/models/entities/note.js';
+import { User } from '@/models/entities/user.js';
+import { Notes, UserProfiles, NoteReactions } from '@/models/index.js';
+import { generateMutedUserQuery } from './generate-muted-user-query.js';
+import { generateBlockedUserQuery } from './generate-block-query.js';
// TODO: リアクション、Renote、返信などをしたノートは除外する
diff --git a/packages/backend/src/server/api/common/inject-promo.ts b/packages/backend/src/server/api/common/inject-promo.ts
index 06a384199..b467b7b70 100644
--- a/packages/backend/src/server/api/common/inject-promo.ts
+++ b/packages/backend/src/server/api/common/inject-promo.ts
@@ -1,7 +1,7 @@
import rndstr from 'rndstr';
-import { Note } from '@/models/entities/note';
-import { User } from '@/models/entities/user';
-import { PromoReads, PromoNotes, Notes, Users } from '@/models/index';
+import { Note } from '@/models/entities/note.js';
+import { User } from '@/models/entities/user.js';
+import { PromoReads, PromoNotes, Notes, Users } from '@/models/index.js';
export async function injectPromo(timeline: Note[], user?: User | null) {
if (timeline.length < 5) return;
diff --git a/packages/backend/src/server/api/common/read-messaging-message.ts b/packages/backend/src/server/api/common/read-messaging-message.ts
index 928333e59..b0ce54d37 100644
--- a/packages/backend/src/server/api/common/read-messaging-message.ts
+++ b/packages/backend/src/server/api/common/read-messaging-message.ts
@@ -1,17 +1,17 @@
-import { publishMainStream, publishGroupMessagingStream } from '@/services/stream';
-import { publishMessagingStream } from '@/services/stream';
-import { publishMessagingIndexStream } from '@/services/stream';
-import { User, IRemoteUser } from '@/models/entities/user';
-import { MessagingMessage } from '@/models/entities/messaging-message';
-import { MessagingMessages, UserGroupJoinings, Users } from '@/models/index';
+import { publishMainStream, publishGroupMessagingStream } from '@/services/stream.js';
+import { publishMessagingStream } from '@/services/stream.js';
+import { publishMessagingIndexStream } from '@/services/stream.js';
+import { User, IRemoteUser } from '@/models/entities/user.js';
+import { MessagingMessage } from '@/models/entities/messaging-message.js';
+import { MessagingMessages, UserGroupJoinings, Users } from '@/models/index.js';
import { In } from 'typeorm';
-import { IdentifiableError } from '@/misc/identifiable-error';
-import { UserGroup } from '@/models/entities/user-group';
-import { toArray } from '@/prelude/array';
-import { renderReadActivity } from '@/remote/activitypub/renderer/read';
-import { renderActivity } from '@/remote/activitypub/renderer/index';
-import { deliver } from '@/queue/index';
-import orderedCollection from '@/remote/activitypub/renderer/ordered-collection';
+import { IdentifiableError } from '@/misc/identifiable-error.js';
+import { UserGroup } from '@/models/entities/user-group.js';
+import { toArray } from '@/prelude/array.js';
+import { renderReadActivity } from '@/remote/activitypub/renderer/read.js';
+import { renderActivity } from '@/remote/activitypub/renderer/index.js';
+import { deliver } from '@/queue/index.js';
+import orderedCollection from '@/remote/activitypub/renderer/ordered-collection.js';
/**
* Mark messages as read
diff --git a/packages/backend/src/server/api/common/read-notification.ts b/packages/backend/src/server/api/common/read-notification.ts
index 049a7feed..1f575042a 100644
--- a/packages/backend/src/server/api/common/read-notification.ts
+++ b/packages/backend/src/server/api/common/read-notification.ts
@@ -1,7 +1,7 @@
-import { publishMainStream } from '@/services/stream';
-import { User } from '@/models/entities/user';
-import { Notification } from '@/models/entities/notification';
-import { Notifications, Users } from '@/models/index';
+import { publishMainStream } from '@/services/stream.js';
+import { User } from '@/models/entities/user.js';
+import { Notification } from '@/models/entities/notification.js';
+import { Notifications, Users } from '@/models/index.js';
import { In } from 'typeorm';
export async function readNotification(
diff --git a/packages/backend/src/server/api/common/signin.ts b/packages/backend/src/server/api/common/signin.ts
index df986fc45..163f132a4 100644
--- a/packages/backend/src/server/api/common/signin.ts
+++ b/packages/backend/src/server/api/common/signin.ts
@@ -1,10 +1,10 @@
-import * as Koa from 'koa';
+import Koa from 'koa';
-import config from '@/config/index';
-import { ILocalUser } from '@/models/entities/user';
-import { Signins } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { publishMainStream } from '@/services/stream';
+import config from '@/config/index.js';
+import { ILocalUser } from '@/models/entities/user.js';
+import { Signins } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { publishMainStream } from '@/services/stream.js';
export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
if (redirect) {
diff --git a/packages/backend/src/server/api/common/signup.ts b/packages/backend/src/server/api/common/signup.ts
index f8db7e374..7689e8233 100644
--- a/packages/backend/src/server/api/common/signup.ts
+++ b/packages/backend/src/server/api/common/signup.ts
@@ -1,15 +1,15 @@
-import * as bcrypt from 'bcryptjs';
-import { generateKeyPair } from 'crypto';
-import generateUserToken from './generate-native-user-token';
-import { User } from '@/models/entities/user';
-import { Users, UsedUsernames } from '@/models/index';
-import { UserProfile } from '@/models/entities/user-profile';
+import bcrypt from 'bcryptjs';
+import { generateKeyPair } from 'node:crypto';
+import generateUserToken from './generate-native-user-token.js';
+import { User } from '@/models/entities/user.js';
+import { Users, UsedUsernames } from '@/models/index.js';
+import { UserProfile } from '@/models/entities/user-profile.js';
import { getConnection } from 'typeorm';
-import { genId } from '@/misc/gen-id';
-import { toPunyNullable } from '@/misc/convert-host';
-import { UserKeypair } from '@/models/entities/user-keypair';
-import { usersChart } from '@/services/chart/index';
-import { UsedUsername } from '@/models/entities/used-username';
+import { genId } from '@/misc/gen-id.js';
+import { toPunyNullable } from '@/misc/convert-host.js';
+import { UserKeypair } from '@/models/entities/user-keypair.js';
+import { usersChart } from '@/services/chart/index.js';
+import { UsedUsername } from '@/models/entities/used-username.js';
export async function signup(opts: {
username: User['username'];
@@ -21,13 +21,13 @@ export async function signup(opts: {
let hash = passwordHash;
// Validate username
- if (!Users.validateLocalUsername.ok(username)) {
+ if (!Users.validateLocalUsername(username)) {
throw new Error('INVALID_USERNAME');
}
if (password != null && passwordHash == null) {
// Validate password
- if (!Users.validatePassword.ok(password)) {
+ if (!Users.validatePassword(password)) {
throw new Error('INVALID_PASSWORD');
}
diff --git a/packages/backend/src/server/api/define.ts b/packages/backend/src/server/api/define.ts
index e0720e2ad..9094fcffc 100644
--- a/packages/backend/src/server/api/define.ts
+++ b/packages/backend/src/server/api/define.ts
@@ -1,11 +1,10 @@
-import * as fs from 'fs';
-import { ILocalUser } from '@/models/entities/user';
-import { IEndpointMeta } from './endpoints';
-import { ApiError } from './error';
-import { SchemaType } from '@/misc/schema';
-import { AccessToken } from '@/models/entities/access-token';
-
-type NonOptional = T extends undefined ? never : T;
+import * as fs from 'node:fs';
+import Ajv from 'ajv';
+import { ILocalUser } from '@/models/entities/user.js';
+import { IEndpointMeta } from './endpoints.js';
+import { ApiError } from './error.js';
+import { Schema, SchemaType } from '@/misc/schema.js';
+import { AccessToken } from '@/models/entities/access-token.js';
type SimpleUserInfo = {
id: ILocalUser['id'];
@@ -18,24 +17,27 @@ type SimpleUserInfo = {
isAdmin: ILocalUser['isAdmin'];
isModerator: ILocalUser['isModerator'];
isSilenced: ILocalUser['isSilenced'];
-};
-
-type Params = {
- [P in keyof T['params']]: NonNullable[P]['transform'] extends () => any
- ? ReturnType[P]['transform']>
- : NonNullable[P]['default'] extends null | number | string
- ? NonOptional[P]['validator']['get']>[0]>
- : ReturnType[P]['validator']['get']>[0];
+ showTimelineReplies: ILocalUser['showTimelineReplies'];
};
export type Response = Record | void;
-type executor =
- (params: Params, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any, cleanup?: () => any) =>
+// TODO: paramsの型をT['params']のスキーマ定義から推論する
+type executor =
+ (params: SchemaType, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any, cleanup?: () => any) =>
Promise>>;
-export default function (meta: T, cb: executor)
+const ajv = new Ajv({
+ useDefaults: true,
+});
+
+ajv.addFormat('misskey:id', /^[a-z0-9]+$/);
+
+export default function (meta: T, paramDef: Ps, cb: executor)
: (params: any, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any) => Promise {
+
+ const validate = ajv.compile(paramDef);
+
return (params: any, user: T['requireCredential'] extends true ? SimpleUserInfo : SimpleUserInfo | null, token: AccessToken | null, file?: any) => {
function cleanup() {
fs.unlink(file.path, () => {});
@@ -47,42 +49,22 @@ export default function (meta: T, cb: executor)
id: '4267801e-70d1-416a-b011-4ee502885d8b',
}));
- const [ps, pserr] = getParams(meta, params);
- if (pserr) {
+ const valid = validate(params);
+ if (!valid) {
if (file) cleanup();
- return Promise.reject(pserr);
- }
- return cb(ps, user, token, file, cleanup);
- };
-}
-
-function getParams(defs: T, params: any): [Params, 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({
+ const errors = validate.errors!;
+ const err = new ApiError({
message: 'Invalid param.',
code: 'INVALID_PARAM',
id: '3d81ceae-475f-4600-b2a8-2bc116157532',
}, {
- param: k,
- reason: e.message,
+ param: errors[0].schemaPath,
+ reason: errors[0].message,
});
- return true;
- } 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 Promise.reject(err);
}
- });
- return [x, err];
+
+ return cb(params as SchemaType, user, token, file, cleanup);
+ };
}
diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts
index bb4e972b8..6b4eff078 100644
--- a/packages/backend/src/server/api/endpoints.ts
+++ b/packages/backend/src/server/api/endpoints.ts
@@ -1,31 +1,618 @@
-import { fileURLToPath } from 'url';
-import { dirname } from 'path';
-import { Context } from 'cafy';
-import * as path from 'path';
-import * as glob from 'glob';
-import { Schema } from '@/misc/schema';
+import { Schema } from '@/misc/schema.js';
-//const _filename = fileURLToPath(import.meta.url);
-const _filename = __filename;
-const _dirname = dirname(_filename);
+import * as ep___admin_abuseUserReports from './endpoints/admin/abuse-user-reports.js';
+import * as ep___admin_accounts_create from './endpoints/admin/accounts/create.js';
+import * as ep___admin_accounts_delete from './endpoints/admin/accounts/delete.js';
+import * as ep___admin_ad_create from './endpoints/admin/ad/create.js';
+import * as ep___admin_ad_delete from './endpoints/admin/ad/delete.js';
+import * as ep___admin_ad_list from './endpoints/admin/ad/list.js';
+import * as ep___admin_ad_update from './endpoints/admin/ad/update.js';
+import * as ep___admin_announcements_create from './endpoints/admin/announcements/create.js';
+import * as ep___admin_announcements_delete from './endpoints/admin/announcements/delete.js';
+import * as ep___admin_announcements_list from './endpoints/admin/announcements/list.js';
+import * as ep___admin_announcements_update from './endpoints/admin/announcements/update.js';
+import * as ep___admin_deleteAllFilesOfAUser from './endpoints/admin/delete-all-files-of-a-user.js';
+import * as ep___admin_drive_cleanRemoteFiles from './endpoints/admin/drive/clean-remote-files.js';
+import * as ep___admin_drive_cleanup from './endpoints/admin/drive/cleanup.js';
+import * as ep___admin_drive_files from './endpoints/admin/drive/files.js';
+import * as ep___admin_drive_showFile from './endpoints/admin/drive/show-file.js';
+import * as ep___admin_emoji_addAliasesBulk from './endpoints/admin/emoji/add-aliases-bulk.js';
+import * as ep___admin_emoji_add from './endpoints/admin/emoji/add.js';
+import * as ep___admin_emoji_copy from './endpoints/admin/emoji/copy.js';
+import * as ep___admin_emoji_deleteBulk from './endpoints/admin/emoji/delete-bulk.js';
+import * as ep___admin_emoji_delete from './endpoints/admin/emoji/delete.js';
+import * as ep___admin_emoji_importZip from './endpoints/admin/emoji/import-zip.js';
+import * as ep___admin_emoji_listRemote from './endpoints/admin/emoji/list-remote.js';
+import * as ep___admin_emoji_list from './endpoints/admin/emoji/list.js';
+import * as ep___admin_emoji_removeAliasesBulk from './endpoints/admin/emoji/remove-aliases-bulk.js';
+import * as ep___admin_emoji_setAliasesBulk from './endpoints/admin/emoji/set-aliases-bulk.js';
+import * as ep___admin_emoji_setCategoryBulk from './endpoints/admin/emoji/set-category-bulk.js';
+import * as ep___admin_emoji_update from './endpoints/admin/emoji/update.js';
+import * as ep___admin_federation_deleteAllFiles from './endpoints/admin/federation/delete-all-files.js';
+import * as ep___admin_federation_refreshRemoteInstanceMetadata from './endpoints/admin/federation/refresh-remote-instance-metadata.js';
+import * as ep___admin_federation_removeAllFollowing from './endpoints/admin/federation/remove-all-following.js';
+import * as ep___admin_federation_updateInstance from './endpoints/admin/federation/update-instance.js';
+import * as ep___admin_getIndexStats from './endpoints/admin/get-index-stats.js';
+import * as ep___admin_getTableStats from './endpoints/admin/get-table-stats.js';
+import * as ep___admin_invite from './endpoints/admin/invite.js';
+import * as ep___admin_moderators_add from './endpoints/admin/moderators/add.js';
+import * as ep___admin_moderators_remove from './endpoints/admin/moderators/remove.js';
+import * as ep___admin_promo_create from './endpoints/admin/promo/create.js';
+import * as ep___admin_queue_clear from './endpoints/admin/queue/clear.js';
+import * as ep___admin_queue_deliverDelayed from './endpoints/admin/queue/deliver-delayed.js';
+import * as ep___admin_queue_inboxDelayed from './endpoints/admin/queue/inbox-delayed.js';
+import * as ep___admin_queue_stats from './endpoints/admin/queue/stats.js';
+import * as ep___admin_relays_add from './endpoints/admin/relays/add.js';
+import * as ep___admin_relays_list from './endpoints/admin/relays/list.js';
+import * as ep___admin_relays_remove from './endpoints/admin/relays/remove.js';
+import * as ep___admin_resetPassword from './endpoints/admin/reset-password.js';
+import * as ep___admin_resolveAbuseUserReport from './endpoints/admin/resolve-abuse-user-report.js';
+import * as ep___admin_sendEmail from './endpoints/admin/send-email.js';
+import * as ep___admin_serverInfo from './endpoints/admin/server-info.js';
+import * as ep___admin_showModerationLogs from './endpoints/admin/show-moderation-logs.js';
+import * as ep___admin_showUser from './endpoints/admin/show-user.js';
+import * as ep___admin_showUsers from './endpoints/admin/show-users.js';
+import * as ep___admin_silenceUser from './endpoints/admin/silence-user.js';
+import * as ep___admin_suspendUser from './endpoints/admin/suspend-user.js';
+import * as ep___admin_unsilenceUser from './endpoints/admin/unsilence-user.js';
+import * as ep___admin_unsuspendUser from './endpoints/admin/unsuspend-user.js';
+import * as ep___admin_updateMeta from './endpoints/admin/update-meta.js';
+import * as ep___admin_vacuum from './endpoints/admin/vacuum.js';
+import * as ep___announcements from './endpoints/announcements.js';
+import * as ep___antennas_create from './endpoints/antennas/create.js';
+import * as ep___antennas_delete from './endpoints/antennas/delete.js';
+import * as ep___antennas_list from './endpoints/antennas/list.js';
+import * as ep___antennas_notes from './endpoints/antennas/notes.js';
+import * as ep___antennas_show from './endpoints/antennas/show.js';
+import * as ep___antennas_update from './endpoints/antennas/update.js';
+import * as ep___ap_get from './endpoints/ap/get.js';
+import * as ep___ap_show from './endpoints/ap/show.js';
+import * as ep___app_create from './endpoints/app/create.js';
+import * as ep___app_show from './endpoints/app/show.js';
+import * as ep___auth_accept from './endpoints/auth/accept.js';
+import * as ep___auth_session_generate from './endpoints/auth/session/generate.js';
+import * as ep___auth_session_show from './endpoints/auth/session/show.js';
+import * as ep___auth_session_userkey from './endpoints/auth/session/userkey.js';
+import * as ep___blocking_create from './endpoints/blocking/create.js';
+import * as ep___blocking_delete from './endpoints/blocking/delete.js';
+import * as ep___blocking_list from './endpoints/blocking/list.js';
+import * as ep___channels_create from './endpoints/channels/create.js';
+import * as ep___channels_featured from './endpoints/channels/featured.js';
+import * as ep___channels_follow from './endpoints/channels/follow.js';
+import * as ep___channels_followed from './endpoints/channels/followed.js';
+import * as ep___channels_owned from './endpoints/channels/owned.js';
+import * as ep___channels_show from './endpoints/channels/show.js';
+import * as ep___channels_timeline from './endpoints/channels/timeline.js';
+import * as ep___channels_unfollow from './endpoints/channels/unfollow.js';
+import * as ep___channels_update from './endpoints/channels/update.js';
+import * as ep___charts_activeUsers from './endpoints/charts/active-users.js';
+import * as ep___charts_apRequest from './endpoints/charts/ap-request.js';
+import * as ep___charts_drive from './endpoints/charts/drive.js';
+import * as ep___charts_federation from './endpoints/charts/federation.js';
+import * as ep___charts_hashtag from './endpoints/charts/hashtag.js';
+import * as ep___charts_instance from './endpoints/charts/instance.js';
+import * as ep___charts_notes from './endpoints/charts/notes.js';
+import * as ep___charts_user_drive from './endpoints/charts/user/drive.js';
+import * as ep___charts_user_following from './endpoints/charts/user/following.js';
+import * as ep___charts_user_notes from './endpoints/charts/user/notes.js';
+import * as ep___charts_user_reactions from './endpoints/charts/user/reactions.js';
+import * as ep___charts_users from './endpoints/charts/users.js';
+import * as ep___clips_addNote from './endpoints/clips/add-note.js';
+import * as ep___clips_create from './endpoints/clips/create.js';
+import * as ep___clips_delete from './endpoints/clips/delete.js';
+import * as ep___clips_list from './endpoints/clips/list.js';
+import * as ep___clips_notes from './endpoints/clips/notes.js';
+import * as ep___clips_show from './endpoints/clips/show.js';
+import * as ep___clips_update from './endpoints/clips/update.js';
+import * as ep___drive from './endpoints/drive.js';
+import * as ep___drive_files from './endpoints/drive/files.js';
+import * as ep___drive_files_attachedNotes from './endpoints/drive/files/attached-notes.js';
+import * as ep___drive_files_checkExistence from './endpoints/drive/files/check-existence.js';
+import * as ep___drive_files_create from './endpoints/drive/files/create.js';
+import * as ep___drive_files_delete from './endpoints/drive/files/delete.js';
+import * as ep___drive_files_findByHash from './endpoints/drive/files/find-by-hash.js';
+import * as ep___drive_files_find from './endpoints/drive/files/find.js';
+import * as ep___drive_files_show from './endpoints/drive/files/show.js';
+import * as ep___drive_files_update from './endpoints/drive/files/update.js';
+import * as ep___drive_files_uploadFromUrl from './endpoints/drive/files/upload-from-url.js';
+import * as ep___drive_folders from './endpoints/drive/folders.js';
+import * as ep___drive_folders_create from './endpoints/drive/folders/create.js';
+import * as ep___drive_folders_delete from './endpoints/drive/folders/delete.js';
+import * as ep___drive_folders_find from './endpoints/drive/folders/find.js';
+import * as ep___drive_folders_show from './endpoints/drive/folders/show.js';
+import * as ep___drive_folders_update from './endpoints/drive/folders/update.js';
+import * as ep___drive_stream from './endpoints/drive/stream.js';
+import * as ep___emailAddress_available from './endpoints/email-address/available.js';
+import * as ep___endpoint from './endpoints/endpoint.js';
+import * as ep___endpoints from './endpoints/endpoints.js';
+import * as ep___exportCustomEmojis from './endpoints/export-custom-emojis.js';
+import * as ep___federation_followers from './endpoints/federation/followers.js';
+import * as ep___federation_following from './endpoints/federation/following.js';
+import * as ep___federation_instances from './endpoints/federation/instances.js';
+import * as ep___federation_showInstance from './endpoints/federation/show-instance.js';
+import * as ep___federation_updateRemoteUser from './endpoints/federation/update-remote-user.js';
+import * as ep___federation_users from './endpoints/federation/users.js';
+import * as ep___following_create from './endpoints/following/create.js';
+import * as ep___following_delete from './endpoints/following/delete.js';
+import * as ep___following_invalidate from './endpoints/following/invalidate.js';
+import * as ep___following_requests_accept from './endpoints/following/requests/accept.js';
+import * as ep___following_requests_cancel from './endpoints/following/requests/cancel.js';
+import * as ep___following_requests_list from './endpoints/following/requests/list.js';
+import * as ep___following_requests_reject from './endpoints/following/requests/reject.js';
+import * as ep___gallery_featured from './endpoints/gallery/featured.js';
+import * as ep___gallery_popular from './endpoints/gallery/popular.js';
+import * as ep___gallery_posts from './endpoints/gallery/posts.js';
+import * as ep___gallery_posts_create from './endpoints/gallery/posts/create.js';
+import * as ep___gallery_posts_delete from './endpoints/gallery/posts/delete.js';
+import * as ep___gallery_posts_like from './endpoints/gallery/posts/like.js';
+import * as ep___gallery_posts_show from './endpoints/gallery/posts/show.js';
+import * as ep___gallery_posts_unlike from './endpoints/gallery/posts/unlike.js';
+import * as ep___gallery_posts_update from './endpoints/gallery/posts/update.js';
+import * as ep___getOnlineUsersCount from './endpoints/get-online-users-count.js';
+import * as ep___hashtags_list from './endpoints/hashtags/list.js';
+import * as ep___hashtags_search from './endpoints/hashtags/search.js';
+import * as ep___hashtags_show from './endpoints/hashtags/show.js';
+import * as ep___hashtags_trend from './endpoints/hashtags/trend.js';
+import * as ep___hashtags_users from './endpoints/hashtags/users.js';
+import * as ep___i from './endpoints/i.js';
+import * as ep___i_2fa_done from './endpoints/i/2fa/done.js';
+import * as ep___i_2fa_keyDone from './endpoints/i/2fa/key-done.js';
+import * as ep___i_2fa_passwordLess from './endpoints/i/2fa/password-less.js';
+import * as ep___i_2fa_registerKey from './endpoints/i/2fa/register-key.js';
+import * as ep___i_2fa_register from './endpoints/i/2fa/register.js';
+import * as ep___i_2fa_removeKey from './endpoints/i/2fa/remove-key.js';
+import * as ep___i_2fa_unregister from './endpoints/i/2fa/unregister.js';
+import * as ep___i_apps from './endpoints/i/apps.js';
+import * as ep___i_authorizedApps from './endpoints/i/authorized-apps.js';
+import * as ep___i_changePassword from './endpoints/i/change-password.js';
+import * as ep___i_deleteAccount from './endpoints/i/delete-account.js';
+import * as ep___i_exportBlocking from './endpoints/i/export-blocking.js';
+import * as ep___i_exportFollowing from './endpoints/i/export-following.js';
+import * as ep___i_exportMute from './endpoints/i/export-mute.js';
+import * as ep___i_exportNotes from './endpoints/i/export-notes.js';
+import * as ep___i_exportUserLists from './endpoints/i/export-user-lists.js';
+import * as ep___i_favorites from './endpoints/i/favorites.js';
+import * as ep___i_gallery_likes from './endpoints/i/gallery/likes.js';
+import * as ep___i_gallery_posts from './endpoints/i/gallery/posts.js';
+import * as ep___i_getWordMutedNotesCount from './endpoints/i/get-word-muted-notes-count.js';
+import * as ep___i_importBlocking from './endpoints/i/import-blocking.js';
+import * as ep___i_importFollowing from './endpoints/i/import-following.js';
+import * as ep___i_importMuting from './endpoints/i/import-muting.js';
+import * as ep___i_importUserLists from './endpoints/i/import-user-lists.js';
+import * as ep___i_notifications from './endpoints/i/notifications.js';
+import * as ep___i_pageLikes from './endpoints/i/page-likes.js';
+import * as ep___i_pages from './endpoints/i/pages.js';
+import * as ep___i_pin from './endpoints/i/pin.js';
+import * as ep___i_readAllMessagingMessages from './endpoints/i/read-all-messaging-messages.js';
+import * as ep___i_readAllUnreadNotes from './endpoints/i/read-all-unread-notes.js';
+import * as ep___i_readAnnouncement from './endpoints/i/read-announcement.js';
+import * as ep___i_regenerateToken from './endpoints/i/regenerate-token.js';
+import * as ep___i_registry_getAll from './endpoints/i/registry/get-all.js';
+import * as ep___i_registry_getDetail from './endpoints/i/registry/get-detail.js';
+import * as ep___i_registry_get from './endpoints/i/registry/get.js';
+import * as ep___i_registry_keysWithType from './endpoints/i/registry/keys-with-type.js';
+import * as ep___i_registry_keys from './endpoints/i/registry/keys.js';
+import * as ep___i_registry_remove from './endpoints/i/registry/remove.js';
+import * as ep___i_registry_scopes from './endpoints/i/registry/scopes.js';
+import * as ep___i_registry_set from './endpoints/i/registry/set.js';
+import * as ep___i_revokeToken from './endpoints/i/revoke-token.js';
+import * as ep___i_signinHistory from './endpoints/i/signin-history.js';
+import * as ep___i_unpin from './endpoints/i/unpin.js';
+import * as ep___i_updateEmail from './endpoints/i/update-email.js';
+import * as ep___i_update from './endpoints/i/update.js';
+import * as ep___i_userGroupInvites from './endpoints/i/user-group-invites.js';
+import * as ep___messaging_history from './endpoints/messaging/history.js';
+import * as ep___messaging_messages from './endpoints/messaging/messages.js';
+import * as ep___messaging_messages_create from './endpoints/messaging/messages/create.js';
+import * as ep___messaging_messages_delete from './endpoints/messaging/messages/delete.js';
+import * as ep___messaging_messages_read from './endpoints/messaging/messages/read.js';
+import * as ep___meta from './endpoints/meta.js';
+import * as ep___miauth_genToken from './endpoints/miauth/gen-token.js';
+import * as ep___mute_create from './endpoints/mute/create.js';
+import * as ep___mute_delete from './endpoints/mute/delete.js';
+import * as ep___mute_list from './endpoints/mute/list.js';
+import * as ep___my_apps from './endpoints/my/apps.js';
+import * as ep___notes from './endpoints/notes.js';
+import * as ep___notes_children from './endpoints/notes/children.js';
+import * as ep___notes_clips from './endpoints/notes/clips.js';
+import * as ep___notes_conversation from './endpoints/notes/conversation.js';
+import * as ep___notes_create from './endpoints/notes/create.js';
+import * as ep___notes_delete from './endpoints/notes/delete.js';
+import * as ep___notes_favorites_create from './endpoints/notes/favorites/create.js';
+import * as ep___notes_favorites_delete from './endpoints/notes/favorites/delete.js';
+import * as ep___notes_featured from './endpoints/notes/featured.js';
+import * as ep___notes_globalTimeline from './endpoints/notes/global-timeline.js';
+import * as ep___notes_hybridTimeline from './endpoints/notes/hybrid-timeline.js';
+import * as ep___notes_localTimeline from './endpoints/notes/local-timeline.js';
+import * as ep___notes_mentions from './endpoints/notes/mentions.js';
+import * as ep___notes_polls_recommendation from './endpoints/notes/polls/recommendation.js';
+import * as ep___notes_polls_vote from './endpoints/notes/polls/vote.js';
+import * as ep___notes_reactions from './endpoints/notes/reactions.js';
+import * as ep___notes_reactions_create from './endpoints/notes/reactions/create.js';
+import * as ep___notes_reactions_delete from './endpoints/notes/reactions/delete.js';
+import * as ep___notes_renotes from './endpoints/notes/renotes.js';
+import * as ep___notes_replies from './endpoints/notes/replies.js';
+import * as ep___notes_searchByTag from './endpoints/notes/search-by-tag.js';
+import * as ep___notes_search from './endpoints/notes/search.js';
+import * as ep___notes_show from './endpoints/notes/show.js';
+import * as ep___notes_state from './endpoints/notes/state.js';
+import * as ep___notes_threadMuting_create from './endpoints/notes/thread-muting/create.js';
+import * as ep___notes_threadMuting_delete from './endpoints/notes/thread-muting/delete.js';
+import * as ep___notes_timeline from './endpoints/notes/timeline.js';
+import * as ep___notes_translate from './endpoints/notes/translate.js';
+import * as ep___notes_unrenote from './endpoints/notes/unrenote.js';
+import * as ep___notes_userListTimeline from './endpoints/notes/user-list-timeline.js';
+import * as ep___notes_watching_create from './endpoints/notes/watching/create.js';
+import * as ep___notes_watching_delete from './endpoints/notes/watching/delete.js';
+import * as ep___notifications_create from './endpoints/notifications/create.js';
+import * as ep___notifications_markAllAsRead from './endpoints/notifications/mark-all-as-read.js';
+import * as ep___notifications_read from './endpoints/notifications/read.js';
+import * as ep___pagePush from './endpoints/page-push.js';
+import * as ep___pages_create from './endpoints/pages/create.js';
+import * as ep___pages_delete from './endpoints/pages/delete.js';
+import * as ep___pages_featured from './endpoints/pages/featured.js';
+import * as ep___pages_like from './endpoints/pages/like.js';
+import * as ep___pages_show from './endpoints/pages/show.js';
+import * as ep___pages_unlike from './endpoints/pages/unlike.js';
+import * as ep___pages_update from './endpoints/pages/update.js';
+import * as ep___ping from './endpoints/ping.js';
+import * as ep___pinnedUsers from './endpoints/pinned-users.js';
+import * as ep___promo_read from './endpoints/promo/read.js';
+import * as ep___requestResetPassword from './endpoints/request-reset-password.js';
+import * as ep___resetDb from './endpoints/reset-db.js';
+import * as ep___resetPassword from './endpoints/reset-password.js';
+import * as ep___serverInfo from './endpoints/server-info.js';
+import * as ep___stats from './endpoints/stats.js';
+import * as ep___sw_register from './endpoints/sw/register.js';
+import * as ep___sw_unregister from './endpoints/sw/unregister.js';
+import * as ep___test from './endpoints/test.js';
+import * as ep___username_available from './endpoints/username/available.js';
+import * as ep___users from './endpoints/users.js';
+import * as ep___users_clips from './endpoints/users/clips.js';
+import * as ep___users_followers from './endpoints/users/followers.js';
+import * as ep___users_following from './endpoints/users/following.js';
+import * as ep___users_gallery_posts from './endpoints/users/gallery/posts.js';
+import * as ep___users_getFrequentlyRepliedUsers from './endpoints/users/get-frequently-replied-users.js';
+import * as ep___users_groups_create from './endpoints/users/groups/create.js';
+import * as ep___users_groups_delete from './endpoints/users/groups/delete.js';
+import * as ep___users_groups_invitations_accept from './endpoints/users/groups/invitations/accept.js';
+import * as ep___users_groups_invitations_reject from './endpoints/users/groups/invitations/reject.js';
+import * as ep___users_groups_invite from './endpoints/users/groups/invite.js';
+import * as ep___users_groups_joined from './endpoints/users/groups/joined.js';
+import * as ep___users_groups_leave from './endpoints/users/groups/leave.js';
+import * as ep___users_groups_owned from './endpoints/users/groups/owned.js';
+import * as ep___users_groups_pull from './endpoints/users/groups/pull.js';
+import * as ep___users_groups_show from './endpoints/users/groups/show.js';
+import * as ep___users_groups_transfer from './endpoints/users/groups/transfer.js';
+import * as ep___users_groups_update from './endpoints/users/groups/update.js';
+import * as ep___users_lists_create from './endpoints/users/lists/create.js';
+import * as ep___users_lists_delete from './endpoints/users/lists/delete.js';
+import * as ep___users_lists_list from './endpoints/users/lists/list.js';
+import * as ep___users_lists_pull from './endpoints/users/lists/pull.js';
+import * as ep___users_lists_push from './endpoints/users/lists/push.js';
+import * as ep___users_lists_show from './endpoints/users/lists/show.js';
+import * as ep___users_lists_update from './endpoints/users/lists/update.js';
+import * as ep___users_notes from './endpoints/users/notes.js';
+import * as ep___users_pages from './endpoints/users/pages.js';
+import * as ep___users_reactions from './endpoints/users/reactions.js';
+import * as ep___users_recommendation from './endpoints/users/recommendation.js';
+import * as ep___users_relation from './endpoints/users/relation.js';
+import * as ep___users_reportAbuse from './endpoints/users/report-abuse.js';
+import * as ep___users_searchByUsernameAndHost from './endpoints/users/search-by-username-and-host.js';
+import * as ep___users_search from './endpoints/users/search.js';
+import * as ep___users_show from './endpoints/users/show.js';
+import * as ep___users_stats from './endpoints/users/stats.js';
-export type Param = {
- validator: Context;
- transform?: any;
- default?: any;
- deprecated?: boolean;
- ref?: string;
-};
+const eps = [
+ ['admin/abuse-user-reports', ep___admin_abuseUserReports],
+ ['admin/accounts/create', ep___admin_accounts_create],
+ ['admin/accounts/delete', ep___admin_accounts_delete],
+ ['admin/ad/create', ep___admin_ad_create],
+ ['admin/ad/delete', ep___admin_ad_delete],
+ ['admin/ad/list', ep___admin_ad_list],
+ ['admin/ad/update', ep___admin_ad_update],
+ ['admin/announcements/create', ep___admin_announcements_create],
+ ['admin/announcements/delete', ep___admin_announcements_delete],
+ ['admin/announcements/list', ep___admin_announcements_list],
+ ['admin/announcements/update', ep___admin_announcements_update],
+ ['admin/delete-all-files-of-a-user', ep___admin_deleteAllFilesOfAUser],
+ ['admin/drive/clean-remote-files', ep___admin_drive_cleanRemoteFiles],
+ ['admin/drive/cleanup', ep___admin_drive_cleanup],
+ ['admin/drive/files', ep___admin_drive_files],
+ ['admin/drive/show-file', ep___admin_drive_showFile],
+ ['admin/emoji/add-aliases-bulk', ep___admin_emoji_addAliasesBulk],
+ ['admin/emoji/add', ep___admin_emoji_add],
+ ['admin/emoji/copy', ep___admin_emoji_copy],
+ ['admin/emoji/delete-bulk', ep___admin_emoji_deleteBulk],
+ ['admin/emoji/delete', ep___admin_emoji_delete],
+ ['admin/emoji/import-zip', ep___admin_emoji_importZip],
+ ['admin/emoji/list-remote', ep___admin_emoji_listRemote],
+ ['admin/emoji/list', ep___admin_emoji_list],
+ ['admin/emoji/remove-aliases-bulk', ep___admin_emoji_removeAliasesBulk],
+ ['admin/emoji/set-aliases-bulk', ep___admin_emoji_setAliasesBulk],
+ ['admin/emoji/set-category-bulk', ep___admin_emoji_setCategoryBulk],
+ ['admin/emoji/update', ep___admin_emoji_update],
+ ['admin/federation/delete-all-files', ep___admin_federation_deleteAllFiles],
+ ['admin/federation/refresh-remote-instance-metadata', ep___admin_federation_refreshRemoteInstanceMetadata],
+ ['admin/federation/remove-all-following', ep___admin_federation_removeAllFollowing],
+ ['admin/federation/update-instance', ep___admin_federation_updateInstance],
+ ['admin/get-index-stats', ep___admin_getIndexStats],
+ ['admin/get-table-stats', ep___admin_getTableStats],
+ ['admin/invite', ep___admin_invite],
+ ['admin/moderators/add', ep___admin_moderators_add],
+ ['admin/moderators/remove', ep___admin_moderators_remove],
+ ['admin/promo/create', ep___admin_promo_create],
+ ['admin/queue/clear', ep___admin_queue_clear],
+ ['admin/queue/deliver-delayed', ep___admin_queue_deliverDelayed],
+ ['admin/queue/inbox-delayed', ep___admin_queue_inboxDelayed],
+ ['admin/queue/stats', ep___admin_queue_stats],
+ ['admin/relays/add', ep___admin_relays_add],
+ ['admin/relays/list', ep___admin_relays_list],
+ ['admin/relays/remove', ep___admin_relays_remove],
+ ['admin/reset-password', ep___admin_resetPassword],
+ ['admin/resolve-abuse-user-report', ep___admin_resolveAbuseUserReport],
+ ['admin/send-email', ep___admin_sendEmail],
+ ['admin/server-info', ep___admin_serverInfo],
+ ['admin/show-moderation-logs', ep___admin_showModerationLogs],
+ ['admin/show-user', ep___admin_showUser],
+ ['admin/show-users', ep___admin_showUsers],
+ ['admin/silence-user', ep___admin_silenceUser],
+ ['admin/suspend-user', ep___admin_suspendUser],
+ ['admin/unsilence-user', ep___admin_unsilenceUser],
+ ['admin/unsuspend-user', ep___admin_unsuspendUser],
+ ['admin/update-meta', ep___admin_updateMeta],
+ ['admin/vacuum', ep___admin_vacuum],
+ ['announcements', ep___announcements],
+ ['antennas/create', ep___antennas_create],
+ ['antennas/delete', ep___antennas_delete],
+ ['antennas/list', ep___antennas_list],
+ ['antennas/notes', ep___antennas_notes],
+ ['antennas/show', ep___antennas_show],
+ ['antennas/update', ep___antennas_update],
+ ['ap/get', ep___ap_get],
+ ['ap/show', ep___ap_show],
+ ['app/create', ep___app_create],
+ ['app/show', ep___app_show],
+ ['auth/accept', ep___auth_accept],
+ ['auth/session/generate', ep___auth_session_generate],
+ ['auth/session/show', ep___auth_session_show],
+ ['auth/session/userkey', ep___auth_session_userkey],
+ ['blocking/create', ep___blocking_create],
+ ['blocking/delete', ep___blocking_delete],
+ ['blocking/list', ep___blocking_list],
+ ['channels/create', ep___channels_create],
+ ['channels/featured', ep___channels_featured],
+ ['channels/follow', ep___channels_follow],
+ ['channels/followed', ep___channels_followed],
+ ['channels/owned', ep___channels_owned],
+ ['channels/show', ep___channels_show],
+ ['channels/timeline', ep___channels_timeline],
+ ['channels/unfollow', ep___channels_unfollow],
+ ['channels/update', ep___channels_update],
+ ['charts/active-users', ep___charts_activeUsers],
+ ['charts/ap-request', ep___charts_apRequest],
+ ['charts/drive', ep___charts_drive],
+ ['charts/federation', ep___charts_federation],
+ ['charts/hashtag', ep___charts_hashtag],
+ ['charts/instance', ep___charts_instance],
+ ['charts/notes', ep___charts_notes],
+ ['charts/user/drive', ep___charts_user_drive],
+ ['charts/user/following', ep___charts_user_following],
+ ['charts/user/notes', ep___charts_user_notes],
+ ['charts/user/reactions', ep___charts_user_reactions],
+ ['charts/users', ep___charts_users],
+ ['clips/add-note', ep___clips_addNote],
+ ['clips/create', ep___clips_create],
+ ['clips/delete', ep___clips_delete],
+ ['clips/list', ep___clips_list],
+ ['clips/notes', ep___clips_notes],
+ ['clips/show', ep___clips_show],
+ ['clips/update', ep___clips_update],
+ ['drive', ep___drive],
+ ['drive/files', ep___drive_files],
+ ['drive/files/attached-notes', ep___drive_files_attachedNotes],
+ ['drive/files/check-existence', ep___drive_files_checkExistence],
+ ['drive/files/create', ep___drive_files_create],
+ ['drive/files/delete', ep___drive_files_delete],
+ ['drive/files/find-by-hash', ep___drive_files_findByHash],
+ ['drive/files/find', ep___drive_files_find],
+ ['drive/files/show', ep___drive_files_show],
+ ['drive/files/update', ep___drive_files_update],
+ ['drive/files/upload-from-url', ep___drive_files_uploadFromUrl],
+ ['drive/folders', ep___drive_folders],
+ ['drive/folders/create', ep___drive_folders_create],
+ ['drive/folders/delete', ep___drive_folders_delete],
+ ['drive/folders/find', ep___drive_folders_find],
+ ['drive/folders/show', ep___drive_folders_show],
+ ['drive/folders/update', ep___drive_folders_update],
+ ['drive/stream', ep___drive_stream],
+ ['email-address/available', ep___emailAddress_available],
+ ['endpoint', ep___endpoint],
+ ['endpoints', ep___endpoints],
+ ['export-custom-emojis', ep___exportCustomEmojis],
+ ['federation/followers', ep___federation_followers],
+ ['federation/following', ep___federation_following],
+ ['federation/instances', ep___federation_instances],
+ ['federation/show-instance', ep___federation_showInstance],
+ ['federation/update-remote-user', ep___federation_updateRemoteUser],
+ ['federation/users', ep___federation_users],
+ ['following/create', ep___following_create],
+ ['following/delete', ep___following_delete],
+ ['following/invalidate', ep___following_invalidate],
+ ['following/requests/accept', ep___following_requests_accept],
+ ['following/requests/cancel', ep___following_requests_cancel],
+ ['following/requests/list', ep___following_requests_list],
+ ['following/requests/reject', ep___following_requests_reject],
+ ['gallery/featured', ep___gallery_featured],
+ ['gallery/popular', ep___gallery_popular],
+ ['gallery/posts', ep___gallery_posts],
+ ['gallery/posts/create', ep___gallery_posts_create],
+ ['gallery/posts/delete', ep___gallery_posts_delete],
+ ['gallery/posts/like', ep___gallery_posts_like],
+ ['gallery/posts/show', ep___gallery_posts_show],
+ ['gallery/posts/unlike', ep___gallery_posts_unlike],
+ ['gallery/posts/update', ep___gallery_posts_update],
+ ['get-online-users-count', ep___getOnlineUsersCount],
+ ['hashtags/list', ep___hashtags_list],
+ ['hashtags/search', ep___hashtags_search],
+ ['hashtags/show', ep___hashtags_show],
+ ['hashtags/trend', ep___hashtags_trend],
+ ['hashtags/users', ep___hashtags_users],
+ ['i', ep___i],
+ ['i/2fa/done', ep___i_2fa_done],
+ ['i/2fa/key-done', ep___i_2fa_keyDone],
+ ['i/2fa/password-less', ep___i_2fa_passwordLess],
+ ['i/2fa/register-key', ep___i_2fa_registerKey],
+ ['i/2fa/register', ep___i_2fa_register],
+ ['i/2fa/remove-key', ep___i_2fa_removeKey],
+ ['i/2fa/unregister', ep___i_2fa_unregister],
+ ['i/apps', ep___i_apps],
+ ['i/authorized-apps', ep___i_authorizedApps],
+ ['i/change-password', ep___i_changePassword],
+ ['i/delete-account', ep___i_deleteAccount],
+ ['i/export-blocking', ep___i_exportBlocking],
+ ['i/export-following', ep___i_exportFollowing],
+ ['i/export-mute', ep___i_exportMute],
+ ['i/export-notes', ep___i_exportNotes],
+ ['i/export-user-lists', ep___i_exportUserLists],
+ ['i/favorites', ep___i_favorites],
+ ['i/gallery/likes', ep___i_gallery_likes],
+ ['i/gallery/posts', ep___i_gallery_posts],
+ ['i/get-word-muted-notes-count', ep___i_getWordMutedNotesCount],
+ ['i/import-blocking', ep___i_importBlocking],
+ ['i/import-following', ep___i_importFollowing],
+ ['i/import-muting', ep___i_importMuting],
+ ['i/import-user-lists', ep___i_importUserLists],
+ ['i/notifications', ep___i_notifications],
+ ['i/page-likes', ep___i_pageLikes],
+ ['i/pages', ep___i_pages],
+ ['i/pin', ep___i_pin],
+ ['i/read-all-messaging-messages', ep___i_readAllMessagingMessages],
+ ['i/read-all-unread-notes', ep___i_readAllUnreadNotes],
+ ['i/read-announcement', ep___i_readAnnouncement],
+ ['i/regenerate-token', ep___i_regenerateToken],
+ ['i/registry/get-all', ep___i_registry_getAll],
+ ['i/registry/get-detail', ep___i_registry_getDetail],
+ ['i/registry/get', ep___i_registry_get],
+ ['i/registry/keys-with-type', ep___i_registry_keysWithType],
+ ['i/registry/keys', ep___i_registry_keys],
+ ['i/registry/remove', ep___i_registry_remove],
+ ['i/registry/scopes', ep___i_registry_scopes],
+ ['i/registry/set', ep___i_registry_set],
+ ['i/revoke-token', ep___i_revokeToken],
+ ['i/signin-history', ep___i_signinHistory],
+ ['i/unpin', ep___i_unpin],
+ ['i/update-email', ep___i_updateEmail],
+ ['i/update', ep___i_update],
+ ['i/user-group-invites', ep___i_userGroupInvites],
+ ['messaging/history', ep___messaging_history],
+ ['messaging/messages', ep___messaging_messages],
+ ['messaging/messages/create', ep___messaging_messages_create],
+ ['messaging/messages/delete', ep___messaging_messages_delete],
+ ['messaging/messages/read', ep___messaging_messages_read],
+ ['meta', ep___meta],
+ ['miauth/gen-token', ep___miauth_genToken],
+ ['mute/create', ep___mute_create],
+ ['mute/delete', ep___mute_delete],
+ ['mute/list', ep___mute_list],
+ ['my/apps', ep___my_apps],
+ ['notes', ep___notes],
+ ['notes/children', ep___notes_children],
+ ['notes/clips', ep___notes_clips],
+ ['notes/conversation', ep___notes_conversation],
+ ['notes/create', ep___notes_create],
+ ['notes/delete', ep___notes_delete],
+ ['notes/favorites/create', ep___notes_favorites_create],
+ ['notes/favorites/delete', ep___notes_favorites_delete],
+ ['notes/featured', ep___notes_featured],
+ ['notes/global-timeline', ep___notes_globalTimeline],
+ ['notes/hybrid-timeline', ep___notes_hybridTimeline],
+ ['notes/local-timeline', ep___notes_localTimeline],
+ ['notes/mentions', ep___notes_mentions],
+ ['notes/polls/recommendation', ep___notes_polls_recommendation],
+ ['notes/polls/vote', ep___notes_polls_vote],
+ ['notes/reactions', ep___notes_reactions],
+ ['notes/reactions/create', ep___notes_reactions_create],
+ ['notes/reactions/delete', ep___notes_reactions_delete],
+ ['notes/renotes', ep___notes_renotes],
+ ['notes/replies', ep___notes_replies],
+ ['notes/search-by-tag', ep___notes_searchByTag],
+ ['notes/search', ep___notes_search],
+ ['notes/show', ep___notes_show],
+ ['notes/state', ep___notes_state],
+ ['notes/thread-muting/create', ep___notes_threadMuting_create],
+ ['notes/thread-muting/delete', ep___notes_threadMuting_delete],
+ ['notes/timeline', ep___notes_timeline],
+ ['notes/translate', ep___notes_translate],
+ ['notes/unrenote', ep___notes_unrenote],
+ ['notes/user-list-timeline', ep___notes_userListTimeline],
+ ['notes/watching/create', ep___notes_watching_create],
+ ['notes/watching/delete', ep___notes_watching_delete],
+ ['notifications/create', ep___notifications_create],
+ ['notifications/mark-all-as-read', ep___notifications_markAllAsRead],
+ ['notifications/read', ep___notifications_read],
+ ['page-push', ep___pagePush],
+ ['pages/create', ep___pages_create],
+ ['pages/delete', ep___pages_delete],
+ ['pages/featured', ep___pages_featured],
+ ['pages/like', ep___pages_like],
+ ['pages/show', ep___pages_show],
+ ['pages/unlike', ep___pages_unlike],
+ ['pages/update', ep___pages_update],
+ ['ping', ep___ping],
+ ['pinned-users', ep___pinnedUsers],
+ ['promo/read', ep___promo_read],
+ ['request-reset-password', ep___requestResetPassword],
+ ['reset-db', ep___resetDb],
+ ['reset-password', ep___resetPassword],
+ ['server-info', ep___serverInfo],
+ ['stats', ep___stats],
+ ['sw/register', ep___sw_register],
+ ['sw/unregister', ep___sw_unregister],
+ ['test', ep___test],
+ ['username/available', ep___username_available],
+ ['users', ep___users],
+ ['users/clips', ep___users_clips],
+ ['users/followers', ep___users_followers],
+ ['users/following', ep___users_following],
+ ['users/gallery/posts', ep___users_gallery_posts],
+ ['users/get-frequently-replied-users', ep___users_getFrequentlyRepliedUsers],
+ ['users/groups/create', ep___users_groups_create],
+ ['users/groups/delete', ep___users_groups_delete],
+ ['users/groups/invitations/accept', ep___users_groups_invitations_accept],
+ ['users/groups/invitations/reject', ep___users_groups_invitations_reject],
+ ['users/groups/invite', ep___users_groups_invite],
+ ['users/groups/joined', ep___users_groups_joined],
+ ['users/groups/leave', ep___users_groups_leave],
+ ['users/groups/owned', ep___users_groups_owned],
+ ['users/groups/pull', ep___users_groups_pull],
+ ['users/groups/show', ep___users_groups_show],
+ ['users/groups/transfer', ep___users_groups_transfer],
+ ['users/groups/update', ep___users_groups_update],
+ ['users/lists/create', ep___users_lists_create],
+ ['users/lists/delete', ep___users_lists_delete],
+ ['users/lists/list', ep___users_lists_list],
+ ['users/lists/pull', ep___users_lists_pull],
+ ['users/lists/push', ep___users_lists_push],
+ ['users/lists/show', ep___users_lists_show],
+ ['users/lists/update', ep___users_lists_update],
+ ['users/notes', ep___users_notes],
+ ['users/pages', ep___users_pages],
+ ['users/reactions', ep___users_reactions],
+ ['users/recommendation', ep___users_recommendation],
+ ['users/relation', ep___users_relation],
+ ['users/report-abuse', ep___users_reportAbuse],
+ ['users/search-by-username-and-host', ep___users_searchByUsernameAndHost],
+ ['users/search', ep___users_search],
+ ['users/show', ep___users_show],
+ ['users/stats', ep___users_stats],
+];
export interface IEndpointMeta {
readonly stability?: 'deprecated' | 'experimental' | 'stable';
readonly tags?: ReadonlyArray;
- readonly params?: {
- readonly [key: string]: Param;
- };
-
readonly errors?: {
readonly [key: string]: {
readonly message: string;
@@ -99,25 +686,23 @@ export interface IEndpointMeta {
* パーミッションの実現に利用されます。
*/
readonly kind?: string;
+
+ readonly description?: string;
}
export interface IEndpoint {
name: string;
exec: any;
meta: IEndpointMeta;
+ params: Schema;
}
-const files = glob.sync('**/*.js', {
- cwd: path.resolve(_dirname + '/endpoints/'),
-});
-
-const endpoints: IEndpoint[] = files.map(f => {
- const ep = require(`./endpoints/${f}`);
-
+const endpoints: IEndpoint[] = eps.map(([name, ep]) => {
return {
- name: f.replace('.js', ''),
+ name: name,
exec: ep.default,
meta: ep.meta || {},
+ params: ep.paramDef,
};
});
diff --git a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts
index ed7b146d0..333746f42 100644
--- a/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts
+++ b/packages/backend/src/server/api/endpoints/admin/abuse-user-reports.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { AbuseUserReports } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { AbuseUserReports } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['admin'],
@@ -10,49 +8,6 @@ export const meta = {
requireCredential: 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: {
type: 'array',
optional: false, nullable: false,
@@ -115,8 +70,22 @@ export const meta = {
},
} 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
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
const query = makePaginationQuery(AbuseUserReports.createQueryBuilder('report'), ps.sinceId, ps.untilId);
switch (ps.state) {
@@ -134,7 +103,7 @@ export default define(meta, async (ps) => {
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);
});
diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/create.ts b/packages/backend/src/server/api/endpoints/admin/accounts/create.ts
index 20f123295..2820c7993 100644
--- a/packages/backend/src/server/api/endpoints/admin/accounts/create.ts
+++ b/packages/backend/src/server/api/endpoints/admin/accounts/create.ts
@@ -1,20 +1,10 @@
-import define from '../../../define';
-import { Users } from '@/models/index';
-import { signup } from '../../../common/signup';
+import define from '../../../define.js';
+import { Users } from '@/models/index.js';
+import { signup } from '../../../common/signup.js';
export const meta = {
tags: ['admin'],
- params: {
- username: {
- validator: Users.validateLocalUsername,
- },
-
- password: {
- validator: Users.validatePassword,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -28,8 +18,17 @@ export const meta = {
},
} 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
-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 noUsers = (await Users.count({
host: null,
diff --git a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts
index 1701c1e3a..01754ec8f 100644
--- a/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts
+++ b/packages/backend/src/server/api/endpoints/admin/accounts/delete.ts
@@ -1,26 +1,26 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { Users } from '@/models/index';
-import { doPostSuspend } from '@/services/suspend-user';
-import { publishUserEvent } from '@/services/stream';
-import { createDeleteAccountJob } from '@/queue';
-import { ID } from '@/misc/cafy-id';
+import define from '../../../define.js';
+import { Users } from '@/models/index.js';
+import { doPostSuspend } from '@/services/suspend-user.js';
+import { publishUserEvent } from '@/services/stream.js';
+import { createDeleteAccountJob } from '@/queue/index.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
},
+ required: ['userId'],
} 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 user = await Users.findOne(ps.userId);
if (user == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/ad/create.ts b/packages/backend/src/server/api/endpoints/admin/ad/create.ts
index 00ad2012f..ab2c50b50 100644
--- a/packages/backend/src/server/api/endpoints/admin/ad/create.ts
+++ b/packages/backend/src/server/api/endpoints/admin/ad/create.ts
@@ -1,41 +1,30 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { Ads } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import define from '../../../define.js';
+import { Ads } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- url: {
- validator: $.str.min(1),
- },
- memo: {
- validator: $.str,
- },
- place: {
- validator: $.str,
- },
- priority: {
- validator: $.str,
- },
- ratio: {
- validator: $.num.int().min(0),
- },
- expiresAt: {
- validator: $.num.int(),
- },
- imageUrl: {
- validator: $.str.min(1),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ url: { type: 'string', minLength: 1 },
+ memo: { type: 'string' },
+ place: { type: 'string' },
+ priority: { type: 'string' },
+ ratio: { type: 'integer' },
+ expiresAt: { type: 'integer' },
+ imageUrl: { type: 'string', minLength: 1 },
},
+ required: ['url', 'memo', 'place', 'priority', 'ratio', 'expiresAt', 'imageUrl'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
await Ads.insert({
id: genId(),
createdAt: new Date(),
diff --git a/packages/backend/src/server/api/endpoints/admin/ad/delete.ts b/packages/backend/src/server/api/endpoints/admin/ad/delete.ts
index c0124e248..3663d974c 100644
--- a/packages/backend/src/server/api/endpoints/admin/ad/delete.ts
+++ b/packages/backend/src/server/api/endpoints/admin/ad/delete.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Ads } from '@/models/index';
-import { ApiError } from '../../../error';
+import define from '../../../define.js';
+import { Ads } from '@/models/index.js';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
@@ -10,12 +8,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- id: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchAd: {
message: 'No such ad.',
@@ -25,8 +17,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const ad = await Ads.findOne(ps.id);
if (ad == null) throw new ApiError(meta.errors.noSuchAd);
diff --git a/packages/backend/src/server/api/endpoints/admin/ad/list.ts b/packages/backend/src/server/api/endpoints/admin/ad/list.ts
index 7a83637f3..74f154f27 100644
--- a/packages/backend/src/server/api/endpoints/admin/ad/list.ts
+++ b/packages/backend/src/server/api/endpoints/admin/ad/list.ts
@@ -1,37 +1,30 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { Ads } from '@/models/index';
-import { makePaginationQuery } from '../../../common/make-pagination-query';
+import define from '../../../define.js';
+import { Ads } from '@/models/index.js';
+import { makePaginationQuery } from '../../../common/make-pagination-query.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
+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
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
const query = makePaginationQuery(Ads.createQueryBuilder('ad'), ps.sinceId, ps.untilId)
.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;
});
diff --git a/packages/backend/src/server/api/endpoints/admin/ad/update.ts b/packages/backend/src/server/api/endpoints/admin/ad/update.ts
index c2b09ab9c..89c421db6 100644
--- a/packages/backend/src/server/api/endpoints/admin/ad/update.ts
+++ b/packages/backend/src/server/api/endpoints/admin/ad/update.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Ads } from '@/models/index';
-import { ApiError } from '../../../error';
+import define from '../../../define.js';
+import { Ads } from '@/models/index.js';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
@@ -10,33 +8,6 @@ export const meta = {
requireCredential: 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: {
noSuchAd: {
message: 'No such ad.',
@@ -46,8 +17,23 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const ad = await Ads.findOne(ps.id);
if (ad == null) throw new ApiError(meta.errors.noSuchAd);
diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/create.ts b/packages/backend/src/server/api/endpoints/admin/announcements/create.ts
index 24c4caa37..41570078d 100644
--- a/packages/backend/src/server/api/endpoints/admin/announcements/create.ts
+++ b/packages/backend/src/server/api/endpoints/admin/announcements/create.ts
@@ -1,7 +1,6 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { Announcements } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import define from '../../../define.js';
+import { Announcements } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
tags: ['admin'],
@@ -9,18 +8,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- title: {
- validator: $.str.min(1),
- },
- text: {
- validator: $.str.min(1),
- },
- imageUrl: {
- validator: $.nullable.str.min(1),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -57,8 +44,18 @@ export const meta = {
},
} 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
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
const announcement = await Announcements.insert({
id: genId(),
createdAt: new Date(),
@@ -68,5 +65,5 @@ export default define(meta, async (ps) => {
imageUrl: ps.imageUrl,
}).then(x => Announcements.findOneOrFail(x.identifiers[0]));
- return announcement;
+ return Object.assign({}, announcement, { createdAt: announcement.createdAt.toISOString(), updatedAt: null });
});
diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts b/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts
index 5548f9900..4871dc4e1 100644
--- a/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts
+++ b/packages/backend/src/server/api/endpoints/admin/announcements/delete.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Announcements } from '@/models/index';
-import { ApiError } from '../../../error';
+import define from '../../../define.js';
+import { Announcements } from '@/models/index.js';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
@@ -10,12 +8,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- id: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchAnnouncement: {
message: 'No such announcement.',
@@ -25,8 +17,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const announcement = await Announcements.findOne(ps.id);
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/list.ts b/packages/backend/src/server/api/endpoints/admin/announcements/list.ts
index e5cc53ccd..0ba0a8ee0 100644
--- a/packages/backend/src/server/api/endpoints/admin/announcements/list.ts
+++ b/packages/backend/src/server/api/endpoints/admin/announcements/list.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { Announcements, AnnouncementReads } from '@/models/index';
-import { makePaginationQuery } from '../../../common/make-pagination-query';
+import define from '../../../define.js';
+import { Announcements, AnnouncementReads } from '@/models/index.js';
+import { makePaginationQuery } from '../../../common/make-pagination-query.js';
export const meta = {
tags: ['admin'],
@@ -10,21 +8,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- 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,
@@ -69,11 +52,21 @@ export const meta = {
},
} 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
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
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) {
(announcement as any).reads = await AnnouncementReads.count({
diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/update.ts b/packages/backend/src/server/api/endpoints/admin/announcements/update.ts
index f66293bb1..138337ef5 100644
--- a/packages/backend/src/server/api/endpoints/admin/announcements/update.ts
+++ b/packages/backend/src/server/api/endpoints/admin/announcements/update.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Announcements } from '@/models/index';
-import { ApiError } from '../../../error';
+import define from '../../../define.js';
+import { Announcements } from '@/models/index.js';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
@@ -10,21 +8,6 @@ export const meta = {
requireCredential: 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: {
noSuchAnnouncement: {
message: 'No such announcement.',
@@ -34,8 +17,19 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const announcement = await Announcements.findOne(ps.id);
if (announcement == null) throw new ApiError(meta.errors.noSuchAnnouncement);
diff --git a/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts b/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts
index 249e63a0f..90e65ec4c 100644
--- a/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts
+++ b/packages/backend/src/server/api/endpoints/admin/delete-all-files-of-a-user.ts
@@ -1,24 +1,24 @@
-import $ from 'cafy';
-import define from '../../define';
-import { deleteFile } from '@/services/drive/delete-file';
-import { DriveFiles } from '@/models/index';
-import { ID } from '@/misc/cafy-id';
+import define from '../../define.js';
+import { deleteFile } from '@/services/drive/delete-file.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
},
+ required: ['userId'],
} 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 files = await DriveFiles.find({
userId: ps.userId,
});
diff --git a/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts b/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts
index acabbfef5..bab149532 100644
--- a/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts
+++ b/packages/backend/src/server/api/endpoints/admin/drive/clean-remote-files.ts
@@ -1,5 +1,5 @@
-import define from '../../../define';
-import { createCleanRemoteFilesJob } from '@/queue/index';
+import define from '../../../define.js';
+import { createCleanRemoteFilesJob } from '@/queue/index.js';
export const meta = {
tags: ['admin'],
@@ -8,7 +8,13 @@ export const meta = {
requireModerator: true,
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
createCleanRemoteFilesJob();
});
diff --git a/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts b/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts
index 452e7069a..3e7d43fb0 100644
--- a/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts
+++ b/packages/backend/src/server/api/endpoints/admin/drive/cleanup.ts
@@ -1,7 +1,7 @@
import { IsNull } from 'typeorm';
-import define from '../../../define';
-import { deleteFile } from '@/services/drive/delete-file';
-import { DriveFiles } from '@/models/index';
+import define from '../../../define.js';
+import { deleteFile } from '@/services/drive/delete-file.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
tags: ['admin'],
@@ -10,8 +10,14 @@ export const meta = {
requireModerator: true,
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 files = await DriveFiles.find({
userId: IsNull(),
});
diff --git a/packages/backend/src/server/api/endpoints/admin/drive/files.ts b/packages/backend/src/server/api/endpoints/admin/drive/files.ts
index 264f54986..646d85a1e 100644
--- a/packages/backend/src/server/api/endpoints/admin/drive/files.ts
+++ b/packages/backend/src/server/api/endpoints/admin/drive/files.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { DriveFiles } from '@/models/index';
-import { makePaginationQuery } from '../../../common/make-pagination-query';
-import { ID } from '@/misc/cafy-id';
+import define from '../../../define.js';
+import { DriveFiles } from '@/models/index.js';
+import { makePaginationQuery } from '../../../common/make-pagination-query.js';
export const meta = {
tags: ['admin'],
@@ -10,39 +8,6 @@ export const meta = {
requireCredential: false,
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: {
type: 'array',
optional: false, nullable: false,
@@ -54,8 +19,21 @@ export const meta = {
},
} 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
-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);
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 });
});
diff --git a/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts b/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts
index 5d9a1f270..e82116009 100644
--- a/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts
+++ b/packages/backend/src/server/api/endpoints/admin/drive/show-file.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { DriveFiles } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
tags: ['admin'],
@@ -10,16 +8,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- fileId: {
- validator: $.optional.type(ID),
- },
-
- url: {
- validator: $.optional.str,
- },
- },
-
errors: {
noSuchFile: {
message: 'No such file.',
@@ -161,8 +149,17 @@ export const meta = {
},
} 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
-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({
where: [{
url: ps.url,
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts
index f0fd73c27..77a4adea6 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/add-aliases-bulk.ts
@@ -1,29 +1,30 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Emojis } from '@/models/index';
+import define from '../../../define.js';
+import { Emojis } from '@/models/index.js';
import { getConnection, In } from 'typeorm';
-import { ApiError } from '../../../error';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- ids: {
- validator: $.arr($.type(ID)),
- },
-
- aliases: {
- validator: $.arr($.str),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ ids: { type: 'array', items: {
+ type: 'string', format: 'misskey:id',
+ } },
+ aliases: { type: 'array', items: {
+ type: 'string',
+ } },
},
+ required: ['ids', 'aliases'],
} as const;
// 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({
id: In(ps.ids),
});
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts
index 1dfeae262..c5787d59d 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/add.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/add.ts
@@ -1,13 +1,11 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { Emojis, DriveFiles } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import define from '../../../define.js';
+import { Emojis, DriveFiles } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
import { getConnection } from 'typeorm';
-import { insertModerationLog } from '@/services/insert-moderation-log';
-import { ApiError } from '../../../error';
-import { ID } from '@/misc/cafy-id';
+import { insertModerationLog } from '@/services/insert-moderation-log.js';
+import { ApiError } from '../../../error.js';
import rndstr from 'rndstr';
-import { publishBroadcastStream } from '@/services/stream';
+import { publishBroadcastStream } from '@/services/stream.js';
export const meta = {
tags: ['admin'],
@@ -15,12 +13,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- fileId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchFile: {
message: 'No such file.',
@@ -30,8 +22,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const file = await DriveFiles.findOne(ps.fileId);
if (file == null) throw new ApiError(meta.errors.noSuchFile);
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts
index 17cbf208a..a0eaa6125 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/copy.ts
@@ -1,13 +1,11 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { Emojis } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import define from '../../../define.js';
+import { Emojis } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
import { getConnection } from 'typeorm';
-import { ApiError } from '../../../error';
-import { DriveFile } from '@/models/entities/drive-file';
-import { ID } from '@/misc/cafy-id';
-import { uploadFromUrl } from '@/services/drive/upload-from-url';
-import { publishBroadcastStream } from '@/services/stream';
+import { ApiError } from '../../../error.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { uploadFromUrl } from '@/services/drive/upload-from-url.js';
+import { publishBroadcastStream } from '@/services/stream.js';
export const meta = {
tags: ['admin'],
@@ -15,12 +13,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- emojiId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchEmoji: {
message: 'No such emoji.',
@@ -42,8 +34,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const emoji = await Emojis.findOne(ps.emojiId);
if (emoji == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts
index 797a5de67..38a2d65cf 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/delete-bulk.ts
@@ -1,26 +1,28 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Emojis } from '@/models/index';
+import define from '../../../define.js';
+import { Emojis } from '@/models/index.js';
import { getConnection, In } from 'typeorm';
-import { insertModerationLog } from '@/services/insert-moderation-log';
-import { ApiError } from '../../../error';
+import { insertModerationLog } from '@/services/insert-moderation-log.js';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- ids: {
- validator: $.arr($.type(ID)),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ ids: { type: 'array', items: {
+ type: 'string', format: 'misskey:id',
+ } },
},
+ required: ['ids'],
} 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 emojis = await Emojis.find({
id: In(ps.ids),
});
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts
index 158043902..a0cffb47f 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/delete.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Emojis } from '@/models/index';
+import define from '../../../define.js';
+import { Emojis } from '@/models/index.js';
import { getConnection } from 'typeorm';
-import { insertModerationLog } from '@/services/insert-moderation-log';
-import { ApiError } from '../../../error';
+import { insertModerationLog } from '@/services/insert-moderation-log.js';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
@@ -12,12 +10,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- id: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchEmoji: {
message: 'No such emoji.',
@@ -27,8 +19,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const emoji = await Emojis.findOne(ps.id);
if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji);
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts b/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts
index 8856a38f2..3f03dc2da 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/import-zip.ts
@@ -1,21 +1,22 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { createImportCustomEmojisJob } from '@/queue/index';
+import define from '../../../define.js';
+import { createImportCustomEmojisJob } from '@/queue/index.js';
import ms from 'ms';
-import { ID } from '@/misc/cafy-id';
export const meta = {
secure: true,
requireCredential: true,
requireModerator: true,
- params: {
- fileId: {
- validator: $.type(ID),
- },
+} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
createImportCustomEmojisJob(user, ps.fileId);
});
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts
index 6e502547f..f19c3ddbd 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { Emojis } from '@/models/index';
-import { toPuny } from '@/misc/convert-host';
-import { makePaginationQuery } from '../../../common/make-pagination-query';
-import { ID } from '@/misc/cafy-id';
+import define from '../../../define.js';
+import { Emojis } from '@/models/index.js';
+import { toPuny } from '@/misc/convert-host.js';
+import { makePaginationQuery } from '../../../common/make-pagination-query.js';
export const meta = {
tags: ['admin'],
@@ -11,31 +9,6 @@ export const meta = {
requireCredential: 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: {
type: 'array',
optional: false, nullable: false,
@@ -77,8 +50,20 @@ export const meta = {
},
} 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
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId);
if (ps.host == null) {
@@ -93,7 +78,7 @@ export default define(meta, async (ps) => {
const emojis = await q
.orderBy('emoji.id', 'DESC')
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return Emojis.packMany(emojis);
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts
index 76ef190f9..f488a71a0 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { Emojis } from '@/models/index';
-import { makePaginationQuery } from '../../../common/make-pagination-query';
-import { ID } from '@/misc/cafy-id';
-import { Emoji } from '@/models/entities/emoji';
+import define from '../../../define.js';
+import { Emojis } from '@/models/index.js';
+import { makePaginationQuery } from '../../../common/make-pagination-query.js';
+import { Emoji } from '@/models/entities/emoji.js';
export const meta = {
tags: ['admin'],
@@ -11,26 +9,6 @@ export const meta = {
requireCredential: 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: {
type: 'array',
optional: false, nullable: false,
@@ -72,8 +50,19 @@ export const meta = {
},
} 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
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId)
.andWhere(`emoji.host IS NULL`);
@@ -81,7 +70,7 @@ export default define(meta, async (ps) => {
if (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();
@@ -90,9 +79,9 @@ export default define(meta, async (ps) => {
emoji.aliases.some(a => a.includes(ps.query!)) ||
emoji.category?.includes(ps.query!));
- emojis.splice(ps.limit! + 1);
+ emojis.splice(ps.limit + 1);
} else {
- emojis = await q.take(ps.limit!).getMany();
+ emojis = await q.take(ps.limit).getMany();
}
return Emojis.packMany(emojis);
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts
index c49f84b7f..dbad93d33 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/remove-aliases-bulk.ts
@@ -1,29 +1,30 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Emojis } from '@/models/index';
+import define from '../../../define.js';
+import { Emojis } from '@/models/index.js';
import { getConnection, In } from 'typeorm';
-import { ApiError } from '../../../error';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- ids: {
- validator: $.arr($.type(ID)),
- },
-
- aliases: {
- validator: $.arr($.str),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ ids: { type: 'array', items: {
+ type: 'string', format: 'misskey:id',
+ } },
+ aliases: { type: 'array', items: {
+ type: 'string',
+ } },
},
+ required: ['ids', 'aliases'],
} as const;
// 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({
id: In(ps.ids),
});
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts
index 06197820f..470b9bef0 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/set-aliases-bulk.ts
@@ -1,29 +1,30 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Emojis } from '@/models/index';
+import define from '../../../define.js';
+import { Emojis } from '@/models/index.js';
import { getConnection, In } from 'typeorm';
-import { ApiError } from '../../../error';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- ids: {
- validator: $.arr($.type(ID)),
- },
-
- aliases: {
- validator: $.arr($.str),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ ids: { type: 'array', items: {
+ type: 'string', format: 'misskey:id',
+ } },
+ aliases: { type: 'array', items: {
+ type: 'string',
+ } },
},
+ required: ['ids', 'aliases'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
await Emojis.update({
id: In(ps.ids),
}, {
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts b/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts
index f0645f111..40e4c0199 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/set-category-bulk.ts
@@ -1,29 +1,28 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Emojis } from '@/models/index';
+import define from '../../../define.js';
+import { Emojis } from '@/models/index.js';
import { getConnection, In } from 'typeorm';
-import { ApiError } from '../../../error';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- ids: {
- validator: $.arr($.type(ID)),
- },
-
- category: {
- validator: $.optional.nullable.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ ids: { type: 'array', items: {
+ type: 'string', format: 'misskey:id',
+ } },
+ category: { type: 'string', nullable: true },
},
+ required: ['ids'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
await Emojis.update({
id: In(ps.ids),
}, {
diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts
index 54a2cf951..c6d07e16f 100644
--- a/packages/backend/src/server/api/endpoints/admin/emoji/update.ts
+++ b/packages/backend/src/server/api/endpoints/admin/emoji/update.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { Emojis } from '@/models/index';
+import define from '../../../define.js';
+import { Emojis } from '@/models/index.js';
import { getConnection } from 'typeorm';
-import { ApiError } from '../../../error';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
@@ -11,24 +9,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- id: {
- validator: $.type(ID),
- },
-
- name: {
- validator: $.str,
- },
-
- category: {
- validator: $.optional.nullable.str,
- },
-
- aliases: {
- validator: $.arr($.str),
- },
- },
-
errors: {
noSuchEmoji: {
message: 'No such emoji.',
@@ -38,8 +18,21 @@ export const meta = {
},
} 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
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
const emoji = await Emojis.findOne(ps.id);
if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji);
diff --git a/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts b/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts
index db023c6f0..d4251f2fe 100644
--- a/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts
+++ b/packages/backend/src/server/api/endpoints/admin/federation/delete-all-files.ts
@@ -1,23 +1,24 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { deleteFile } from '@/services/drive/delete-file';
-import { DriveFiles } from '@/models/index';
+import define from '../../../define.js';
+import { deleteFile } from '@/services/drive/delete-file.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- host: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ host: { type: 'string' },
},
+ required: ['host'],
} 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 files = await DriveFiles.find({
userHost: ps.host,
});
diff --git a/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts b/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts
index b68252ef2..86978cc30 100644
--- a/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts
+++ b/packages/backend/src/server/api/endpoints/admin/federation/refresh-remote-instance-metadata.ts
@@ -1,24 +1,25 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { Instances } from '@/models/index';
-import { toPuny } from '@/misc/convert-host';
-import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata';
+import define from '../../../define.js';
+import { Instances } from '@/models/index.js';
+import { toPuny } from '@/misc/convert-host.js';
+import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- host: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ host: { type: 'string' },
},
+ required: ['host'],
} 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 instance = await Instances.findOne({ host: toPuny(ps.host) });
if (instance == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts b/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts
index 4de8ad133..ccd07489c 100644
--- a/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts
+++ b/packages/backend/src/server/api/endpoints/admin/federation/remove-all-following.ts
@@ -1,23 +1,24 @@
-import $ from 'cafy';
-import define from '../../../define';
-import deleteFollowing from '@/services/following/delete';
-import { Followings, Users } from '@/models/index';
+import define from '../../../define.js';
+import deleteFollowing from '@/services/following/delete.js';
+import { Followings, Users } from '@/models/index.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- host: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ host: { type: 'string' },
},
+ required: ['host'],
} 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 followings = await Followings.find({
followerHost: ps.host,
});
diff --git a/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts b/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts
index 6ac2f1f46..198108242 100644
--- a/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts
+++ b/packages/backend/src/server/api/endpoints/admin/federation/update-instance.ts
@@ -1,27 +1,25 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { Instances } from '@/models/index';
-import { toPuny } from '@/misc/convert-host';
+import define from '../../../define.js';
+import { Instances } from '@/models/index.js';
+import { toPuny } from '@/misc/convert-host.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- host: {
- validator: $.str,
- },
-
- isSuspended: {
- validator: $.bool,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ host: { type: 'string' },
+ isSuspended: { type: 'boolean' },
},
+ required: ['host', 'isSuspended'],
} 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 instance = await Instances.findOne({ host: toPuny(ps.host) });
if (instance == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts b/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts
index 9a2bccec7..37878c414 100644
--- a/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts
+++ b/packages/backend/src/server/api/endpoints/admin/get-index-stats.ts
@@ -1,4 +1,4 @@
-import define from '../../define';
+import define from '../../define.js';
import { getConnection } from 'typeorm';
export const meta = {
@@ -6,13 +6,16 @@ export const meta = {
requireModerator: true,
tags: ['admin'],
+} as const;
- params: {
- },
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async () => {
+export default define(meta, paramDef, async () => {
const stats = await
getConnection().query(`SELECT * FROM pg_indexes;`)
.then(recs => {
diff --git a/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts b/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts
index 1c5f25067..7cf2d5ffd 100644
--- a/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts
+++ b/packages/backend/src/server/api/endpoints/admin/get-table-stats.ts
@@ -1,4 +1,4 @@
-import define from '../../define';
+import define from '../../define.js';
import { getConnection } from 'typeorm';
export const meta = {
@@ -7,9 +7,6 @@ export const meta = {
tags: ['admin'],
- params: {
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -22,8 +19,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async () => {
+export default define(meta, paramDef, async () => {
const sizes = await
getConnection().query(`
SELECT relname AS "table", reltuples as "count", pg_total_relation_size(C.oid) AS "size"
diff --git a/packages/backend/src/server/api/endpoints/admin/invite.ts b/packages/backend/src/server/api/endpoints/admin/invite.ts
index 3428709c0..7e950cf87 100644
--- a/packages/backend/src/server/api/endpoints/admin/invite.ts
+++ b/packages/backend/src/server/api/endpoints/admin/invite.ts
@@ -1,7 +1,7 @@
import rndstr from 'rndstr';
-import define from '../../define';
-import { RegistrationTickets } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import define from '../../define.js';
+import { RegistrationTickets } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
tags: ['admin'],
@@ -9,8 +9,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {},
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -26,8 +24,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async () => {
+export default define(meta, paramDef, async () => {
const code = rndstr({
length: 8,
chars: '2-9A-HJ-NP-Z', // [0-9A-Z] w/o [01IO] (32 patterns)
diff --git a/packages/backend/src/server/api/endpoints/admin/moderators/add.ts b/packages/backend/src/server/api/endpoints/admin/moderators/add.ts
index 0308cf276..4206e3a3c 100644
--- a/packages/backend/src/server/api/endpoints/admin/moderators/add.ts
+++ b/packages/backend/src/server/api/endpoints/admin/moderators/add.ts
@@ -1,23 +1,23 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { Users } from '@/models/index';
+import define from '../../../define.js';
+import { Users } from '@/models/index.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireAdmin: true,
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
},
+ required: ['userId'],
} as const;
// 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);
if (user == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts b/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts
index bdb976e9e..143119bfe 100644
--- a/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts
+++ b/packages/backend/src/server/api/endpoints/admin/moderators/remove.ts
@@ -1,23 +1,23 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { Users } from '@/models/index';
+import define from '../../../define.js';
+import { Users } from '@/models/index.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireAdmin: true,
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
},
+ required: ['userId'],
} as const;
// 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);
if (user == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/promo/create.ts b/packages/backend/src/server/api/endpoints/admin/promo/create.ts
index f2735ac9f..2eec5bf0d 100644
--- a/packages/backend/src/server/api/endpoints/admin/promo/create.ts
+++ b/packages/backend/src/server/api/endpoints/admin/promo/create.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getNote } from '../../../common/getters';
-import { PromoNotes } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getNote } from '../../../common/getters.js';
+import { PromoNotes } from '@/models/index.js';
export const meta = {
tags: ['admin'],
@@ -11,16 +9,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- noteId: {
- validator: $.type(ID),
- },
-
- expiresAt: {
- validator: $.num.int(),
- },
- },
-
errors: {
noSuchNote: {
message: 'No such note.',
@@ -36,8 +24,17 @@ export const meta = {
},
} 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
-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;
@@ -51,7 +48,6 @@ export default define(meta, async (ps, user) => {
await PromoNotes.insert({
noteId: note.id,
- createdAt: new Date(),
expiresAt: new Date(ps.expiresAt),
userId: note.userId,
});
diff --git a/packages/backend/src/server/api/endpoints/admin/queue/clear.ts b/packages/backend/src/server/api/endpoints/admin/queue/clear.ts
index 3c8e7a27a..8f015c280 100644
--- a/packages/backend/src/server/api/endpoints/admin/queue/clear.ts
+++ b/packages/backend/src/server/api/endpoints/admin/queue/clear.ts
@@ -1,18 +1,22 @@
-import define from '../../../define';
-import { destroy } from '@/queue/index';
-import { insertModerationLog } from '@/services/insert-moderation-log';
+import define from '../../../define.js';
+import { destroy } from '@/queue/index.js';
+import { insertModerationLog } from '@/services/insert-moderation-log.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {},
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
destroy();
insertModerationLog(me, 'clearQueue');
diff --git a/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts b/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts
index 4760e2c31..70f7d77de 100644
--- a/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts
+++ b/packages/backend/src/server/api/endpoints/admin/queue/deliver-delayed.ts
@@ -1,6 +1,6 @@
-import { deliverQueue } from '@/queue/queues';
-import { URL } from 'url';
-import define from '../../../define';
+import { deliverQueue } from '@/queue/queues.js';
+import { URL } from 'node:url';
+import define from '../../../define.js';
export const meta = {
tags: ['admin'],
@@ -8,9 +8,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -35,8 +32,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
// 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 res = [] as [string, number][];
diff --git a/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts b/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts
index a95aabc50..2235ce8f9 100644
--- a/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts
+++ b/packages/backend/src/server/api/endpoints/admin/queue/inbox-delayed.ts
@@ -1,6 +1,6 @@
-import { URL } from 'url';
-import define from '../../../define';
-import { inboxQueue } from '@/queue/queues';
+import { URL } from 'node:url';
+import define from '../../../define.js';
+import { inboxQueue } from '@/queue/queues.js';
export const meta = {
tags: ['admin'],
@@ -8,9 +8,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -35,8 +32,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
// 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 res = [] as [string, number][];
diff --git a/packages/backend/src/server/api/endpoints/admin/queue/jobs.ts b/packages/backend/src/server/api/endpoints/admin/queue/jobs.ts
deleted file mode 100644
index df0b4a8f1..000000000
--- a/packages/backend/src/server/api/endpoints/admin/queue/jobs.ts
+++ /dev/null
@@ -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,
- };
- });
-});
diff --git a/packages/backend/src/server/api/endpoints/admin/queue/stats.ts b/packages/backend/src/server/api/endpoints/admin/queue/stats.ts
index dab0be5db..988b5a5e3 100644
--- a/packages/backend/src/server/api/endpoints/admin/queue/stats.ts
+++ b/packages/backend/src/server/api/endpoints/admin/queue/stats.ts
@@ -1,5 +1,5 @@
-import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '@/queue/queues';
-import define from '../../../define';
+import { deliverQueue, inboxQueue, dbQueue, objectStorageQueue } from '@/queue/queues.js';
+import define from '../../../define.js';
export const meta = {
tags: ['admin'],
@@ -7,8 +7,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {},
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -33,8 +31,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
// 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 inboxJobCounts = await inboxQueue.getJobCounts();
const dbJobCounts = await dbQueue.getJobCounts();
diff --git a/packages/backend/src/server/api/endpoints/admin/relays/add.ts b/packages/backend/src/server/api/endpoints/admin/relays/add.ts
index 65890a00f..348e9baca 100644
--- a/packages/backend/src/server/api/endpoints/admin/relays/add.ts
+++ b/packages/backend/src/server/api/endpoints/admin/relays/add.ts
@@ -1,8 +1,7 @@
-import { URL } from 'url';
-import $ from 'cafy';
-import define from '../../../define';
-import { addRelay } from '@/services/relay';
-import { ApiError } from '../../../error';
+import { URL } from 'node:url';
+import define from '../../../define.js';
+import { addRelay } from '@/services/relay.js';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['admin'],
@@ -10,12 +9,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- inbox: {
- validator: $.str,
- },
- },
-
errors: {
invalidUrl: {
message: 'Invalid URL',
@@ -52,8 +45,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ inbox: { type: 'string' },
+ },
+ required: ['inbox'],
+} 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) => {
try {
if (new URL(ps.inbox).protocol !== 'https:') throw 'https only';
} catch {
diff --git a/packages/backend/src/server/api/endpoints/admin/relays/list.ts b/packages/backend/src/server/api/endpoints/admin/relays/list.ts
index bdddf1337..89ec651e6 100644
--- a/packages/backend/src/server/api/endpoints/admin/relays/list.ts
+++ b/packages/backend/src/server/api/endpoints/admin/relays/list.ts
@@ -1,5 +1,5 @@
-import define from '../../../define';
-import { listRelay } from '@/services/relay';
+import define from '../../../define.js';
+import { listRelay } from '@/services/relay.js';
export const meta = {
tags: ['admin'],
@@ -7,9 +7,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -42,7 +39,13 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
return await listRelay();
});
diff --git a/packages/backend/src/server/api/endpoints/admin/relays/remove.ts b/packages/backend/src/server/api/endpoints/admin/relays/remove.ts
index 4b04e620c..b59cf72c5 100644
--- a/packages/backend/src/server/api/endpoints/admin/relays/remove.ts
+++ b/packages/backend/src/server/api/endpoints/admin/relays/remove.ts
@@ -1,21 +1,22 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { removeRelay } from '@/services/relay';
+import define from '../../../define.js';
+import { removeRelay } from '@/services/relay.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- inbox: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ inbox: { type: 'string' },
},
+ required: ['inbox'],
} 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) => {
return await removeRelay(ps.inbox);
});
diff --git a/packages/backend/src/server/api/endpoints/admin/reset-password.ts b/packages/backend/src/server/api/endpoints/admin/reset-password.ts
index b6cf1ee2d..1fd5c8d5a 100644
--- a/packages/backend/src/server/api/endpoints/admin/reset-password.ts
+++ b/packages/backend/src/server/api/endpoints/admin/reset-password.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import * as bcrypt from 'bcryptjs';
+import define from '../../define.js';
+import bcrypt from 'bcryptjs';
import rndstr from 'rndstr';
-import { Users, UserProfiles } from '@/models/index';
+import { Users, UserProfiles } from '@/models/index.js';
export const meta = {
tags: ['admin'],
@@ -11,12 +9,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -31,8 +23,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
const user = await Users.findOne(ps.userId as string);
if (user == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts b/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts
index a47b69ec1..a9e565841 100644
--- a/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts
+++ b/packages/backend/src/server/api/endpoints/admin/resolve-abuse-user-report.ts
@@ -1,33 +1,28 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { AbuseUserReports, Users } from '@/models/index';
-import { getInstanceActor } from '@/services/instance-actor';
-import { deliver } from '@/queue/index';
-import { renderActivity } from '@/remote/activitypub/renderer/index';
-import { renderFlag } from '@/remote/activitypub/renderer/flag';
+import define from '../../define.js';
+import { AbuseUserReports, Users } from '@/models/index.js';
+import { getInstanceActor } from '@/services/instance-actor.js';
+import { deliver } from '@/queue/index.js';
+import { renderActivity } from '@/remote/activitypub/renderer/index.js';
+import { renderFlag } from '@/remote/activitypub/renderer/flag.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- reportId: {
- validator: $.type(ID),
- },
-
- forward: {
- validator: $.optional.boolean,
- required: false,
- default: false,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ reportId: { type: 'string', format: 'misskey:id' },
+ forward: { type: 'boolean', default: false },
},
+ required: ['reportId'],
} 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 report = await AbuseUserReports.findOne(ps.reportId);
if (report == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/send-email.ts b/packages/backend/src/server/api/endpoints/admin/send-email.ts
index c2972c35f..bbdd66e4c 100644
--- a/packages/backend/src/server/api/endpoints/admin/send-email.ts
+++ b/packages/backend/src/server/api/endpoints/admin/send-email.ts
@@ -1,27 +1,24 @@
-import $ from 'cafy';
-import define from '../../define';
-import { sendEmail } from '@/services/send-email';
+import define from '../../define.js';
+import { sendEmail } from '@/services/send-email.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- to: {
- validator: $.str,
- },
- subject: {
- validator: $.str,
- },
- text: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ to: { type: 'string' },
+ subject: { type: 'string' },
+ text: { type: 'string' },
},
+ required: ['to', 'subject', 'text'],
} as const;
// 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);
});
diff --git a/packages/backend/src/server/api/endpoints/admin/server-info.ts b/packages/backend/src/server/api/endpoints/admin/server-info.ts
index cd282e364..8bf1c4341 100644
--- a/packages/backend/src/server/api/endpoints/admin/server-info.ts
+++ b/packages/backend/src/server/api/endpoints/admin/server-info.ts
@@ -1,8 +1,8 @@
-import * as os from 'os';
-import * as si from 'systeminformation';
+import * as os from 'node:os';
+import si from 'systeminformation';
import { getConnection } from 'typeorm';
-import define from '../../define';
-import { redisClient } from '../../../../db/redis';
+import define from '../../define.js';
+import { redisClient } from '../../../../db/redis.js';
export const meta = {
requireCredential: true,
@@ -10,9 +10,6 @@ export const meta = {
tags: ['admin', 'meta'],
- params: {
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -90,8 +87,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
// 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 fsStats = await si.fsSize();
const netInterface = await si.networkInterfaceDefault();
diff --git a/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts b/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts
index 84e2b84bb..3545536aa 100644
--- a/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts
+++ b/packages/backend/src/server/api/endpoints/admin/show-moderation-logs.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ModerationLogs } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { ModerationLogs } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['admin'],
@@ -10,21 +8,6 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- 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,
@@ -65,11 +48,21 @@ export const meta = {
},
} 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
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
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);
});
diff --git a/packages/backend/src/server/api/endpoints/admin/show-user.ts b/packages/backend/src/server/api/endpoints/admin/show-user.ts
index 0d0cc9087..a435dcc28 100644
--- a/packages/backend/src/server/api/endpoints/admin/show-user.ts
+++ b/packages/backend/src/server/api/endpoints/admin/show-user.ts
@@ -1,7 +1,5 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Users } from '@/models/index';
+import define from '../../define.js';
+import { Users } from '@/models/index.js';
export const meta = {
tags: ['admin'],
@@ -9,20 +7,22 @@ export const meta = {
requireCredential: true,
requireModerator: true,
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
res: {
type: 'object',
nullable: false, optional: false,
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const user = await Users.findOne(ps.userId as string);
if (user == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/show-users.ts b/packages/backend/src/server/api/endpoints/admin/show-users.ts
index d3dde99b7..1ec86fef2 100644
--- a/packages/backend/src/server/api/endpoints/admin/show-users.ts
+++ b/packages/backend/src/server/api/endpoints/admin/show-users.ts
@@ -1,6 +1,5 @@
-import $ from 'cafy';
-import define from '../../define';
-import { Users } from '@/models/index';
+import define from '../../define.js';
+import { Users } from '@/models/index.js';
export const meta = {
tags: ['admin'],
@@ -8,61 +7,6 @@ export const meta = {
requireCredential: 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: {
type: 'array',
nullable: false, optional: false,
@@ -74,8 +18,22 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const query = Users.createQueryBuilder('user');
switch (ps.state) {
@@ -111,7 +69,7 @@ export default define(meta, async (ps, me) => {
default: query.orderBy('user.id', 'ASC'); break;
}
- query.take(ps.limit!);
+ query.take(ps.limit);
query.skip(ps.offset);
const users = await query.getMany();
diff --git a/packages/backend/src/server/api/endpoints/admin/silence-user.ts b/packages/backend/src/server/api/endpoints/admin/silence-user.ts
index 872bd2a6a..4a74c3fb0 100644
--- a/packages/backend/src/server/api/endpoints/admin/silence-user.ts
+++ b/packages/backend/src/server/api/endpoints/admin/silence-user.ts
@@ -1,24 +1,24 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Users } from '@/models/index';
-import { insertModerationLog } from '@/services/insert-moderation-log';
+import define from '../../define.js';
+import { Users } from '@/models/index.js';
+import { insertModerationLog } from '@/services/insert-moderation-log.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
},
+ required: ['userId'],
} 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 user = await Users.findOne(ps.userId as string);
if (user == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/suspend-user.ts b/packages/backend/src/server/api/endpoints/admin/suspend-user.ts
index 2bb1875fc..adaa7b86c 100644
--- a/packages/backend/src/server/api/endpoints/admin/suspend-user.ts
+++ b/packages/backend/src/server/api/endpoints/admin/suspend-user.ts
@@ -1,28 +1,28 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import deleteFollowing from '@/services/following/delete';
-import { Users, Followings, Notifications } from '@/models/index';
-import { User } from '@/models/entities/user';
-import { insertModerationLog } from '@/services/insert-moderation-log';
-import { doPostSuspend } from '@/services/suspend-user';
-import { publishUserEvent } from '@/services/stream';
+import define from '../../define.js';
+import deleteFollowing from '@/services/following/delete.js';
+import { Users, Followings, Notifications } from '@/models/index.js';
+import { User } from '@/models/entities/user.js';
+import { insertModerationLog } from '@/services/insert-moderation-log.js';
+import { doPostSuspend } from '@/services/suspend-user.js';
+import { publishUserEvent } from '@/services/stream.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
},
+ required: ['userId'],
} 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 user = await Users.findOne(ps.userId as string);
if (user == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts b/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts
index a4c6ff2ad..4e6366aa1 100644
--- a/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts
+++ b/packages/backend/src/server/api/endpoints/admin/unsilence-user.ts
@@ -1,24 +1,24 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Users } from '@/models/index';
-import { insertModerationLog } from '@/services/insert-moderation-log';
+import define from '../../define.js';
+import { Users } from '@/models/index.js';
+import { insertModerationLog } from '@/services/insert-moderation-log.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
},
+ required: ['userId'],
} 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 user = await Users.findOne(ps.userId as string);
if (user == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts b/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts
index 5ab56d51c..3b9e0a94e 100644
--- a/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts
+++ b/packages/backend/src/server/api/endpoints/admin/unsuspend-user.ts
@@ -1,25 +1,25 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Users } from '@/models/index';
-import { insertModerationLog } from '@/services/insert-moderation-log';
-import { doPostUnsuspend } from '@/services/unsuspend-user';
+import define from '../../define.js';
+import { Users } from '@/models/index.js';
+import { insertModerationLog } from '@/services/insert-moderation-log.js';
+import { doPostUnsuspend } from '@/services/unsuspend-user.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
},
+ required: ['userId'],
} 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 user = await Users.findOne(ps.userId as string);
if (user == null) {
diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts
index 1764d230a..66b634c87 100644
--- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts
+++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts
@@ -1,310 +1,107 @@
-import $ from 'cafy';
-import define from '../../define';
+import define from '../../define.js';
import { getConnection } from 'typeorm';
-import { Meta } from '@/models/entities/meta';
-import { insertModerationLog } from '@/services/insert-moderation-log';
-import { DB_MAX_NOTE_TEXT_LENGTH } from '@/misc/hard-limits';
-import { ID } from '@/misc/cafy-id';
+import { Meta } from '@/models/entities/meta.js';
+import { insertModerationLog } from '@/services/insert-moderation-log.js';
+import { DB_MAX_NOTE_TEXT_LENGTH } from '@/misc/hard-limits.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireAdmin: true,
-
- params: {
- disableRegistration: {
- validator: $.optional.nullable.bool,
- },
-
- disableLocalTimeline: {
- validator: $.optional.nullable.bool,
- },
-
- disableGlobalTimeline: {
- validator: $.optional.nullable.bool,
- },
-
- useStarForReactionFallback: {
- validator: $.optional.nullable.bool,
- },
-
- pinnedUsers: {
- validator: $.optional.nullable.arr($.str),
- },
-
- hiddenTags: {
- validator: $.optional.nullable.arr($.str),
- },
-
- blockedHosts: {
- validator: $.optional.nullable.arr($.str),
- },
-
- themeColor: {
- validator: $.optional.nullable.str,
- },
-
- mascotImageUrl: {
- validator: $.optional.nullable.str,
- },
-
- bannerUrl: {
- validator: $.optional.nullable.str,
- },
-
- errorImageUrl: {
- validator: $.optional.nullable.str,
- },
-
- iconUrl: {
- validator: $.optional.nullable.str,
- },
-
- backgroundImageUrl: {
- validator: $.optional.nullable.str,
- },
-
- logoImageUrl: {
- validator: $.optional.nullable.str,
- },
-
- name: {
- validator: $.optional.nullable.str,
- },
-
- description: {
- validator: $.optional.nullable.str,
- },
-
- maxNoteTextLength: {
- validator: $.optional.num.min(0).max(DB_MAX_NOTE_TEXT_LENGTH),
- },
-
- localDriveCapacityMb: {
- validator: $.optional.num.min(0),
- },
-
- remoteDriveCapacityMb: {
- validator: $.optional.num.min(0),
- },
-
- cacheRemoteFiles: {
- validator: $.optional.bool,
- },
-
- proxyRemoteFiles: {
- validator: $.optional.bool,
- },
-
- emailRequiredForSignup: {
- validator: $.optional.bool,
- },
-
- 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;
+
+export const paramDef = {
+ type: 'object',
+ properties: {
+ disableRegistration: { type: 'boolean', nullable: true },
+ disableLocalTimeline: { type: 'boolean', nullable: true },
+ disableGlobalTimeline: { type: 'boolean', nullable: true },
+ useStarForReactionFallback: { type: 'boolean', nullable: true },
+ pinnedUsers: { type: 'array', nullable: true, items: {
+ type: 'string',
+ } },
+ hiddenTags: { type: 'array', nullable: true, items: {
+ type: 'string',
+ } },
+ blockedHosts: { type: 'array', nullable: true, items: {
+ type: 'string',
+ } },
+ themeColor: { type: 'string', nullable: true },
+ mascotImageUrl: { type: 'string', nullable: true },
+ bannerUrl: { type: 'string', nullable: true },
+ errorImageUrl: { type: 'string', nullable: true },
+ iconUrl: { type: 'string', nullable: true },
+ backgroundImageUrl: { type: 'string', nullable: true },
+ logoImageUrl: { type: 'string', nullable: true },
+ name: { type: 'string', nullable: true },
+ description: { type: 'string', nullable: true },
+ defaultLightTheme: { type: 'string', nullable: true },
+ defaultDarkTheme: { type: 'string', nullable: true },
+ localDriveCapacityMb: { type: 'integer' },
+ remoteDriveCapacityMb: { type: 'integer' },
+ cacheRemoteFiles: { type: 'boolean' },
+ emailRequiredForSignup: { type: 'boolean' },
+ enableHcaptcha: { type: 'boolean' },
+ hcaptchaSiteKey: { type: 'string', nullable: true },
+ hcaptchaSecretKey: { type: 'string', nullable: true },
+ enableRecaptcha: { type: 'boolean' },
+ recaptchaSiteKey: { type: 'string', nullable: true },
+ recaptchaSecretKey: { type: 'string', nullable: true },
+ proxyAccountId: { type: 'string', format: 'misskey:id', nullable: true },
+ maintainerName: { type: 'string', nullable: true },
+ maintainerEmail: { type: 'string', nullable: true },
+ pinnedPages: { type: 'array', items: {
+ type: 'string',
+ } },
+ pinnedClipId: { type: 'string', format: 'misskey:id', nullable: true },
+ langs: { type: 'array', items: {
+ type: 'string',
+ } },
+ summalyProxy: { type: 'string', nullable: true },
+ deeplAuthKey: { type: 'string', nullable: true },
+ deeplIsPro: { type: 'boolean' },
+ enableTwitterIntegration: { type: 'boolean' },
+ twitterConsumerKey: { type: 'string', nullable: true },
+ twitterConsumerSecret: { type: 'string', nullable: true },
+ enableGithubIntegration: { type: 'boolean' },
+ githubClientId: { type: 'string', nullable: true },
+ githubClientSecret: { type: 'string', nullable: true },
+ enableDiscordIntegration: { type: 'boolean' },
+ discordClientId: { type: 'string', nullable: true },
+ discordClientSecret: { type: 'string', nullable: true },
+ enableEmail: { type: 'boolean' },
+ email: { type: 'string', nullable: true },
+ smtpSecure: { type: 'boolean' },
+ smtpHost: { type: 'string', nullable: true },
+ smtpPort: { type: 'integer', nullable: true },
+ smtpUser: { type: 'string', nullable: true },
+ smtpPass: { type: 'string', nullable: true },
+ enableServiceWorker: { type: 'boolean' },
+ swPublicKey: { type: 'string', nullable: true },
+ swPrivateKey: { type: 'string', nullable: true },
+ tosUrl: { type: 'string', nullable: true },
+ repositoryUrl: { type: 'string' },
+ feedbackUrl: { type: 'string' },
+ useObjectStorage: { type: 'boolean' },
+ objectStorageBaseUrl: { type: 'string', nullable: true },
+ objectStorageBucket: { type: 'string', nullable: true },
+ objectStoragePrefix: { type: 'string', nullable: true },
+ objectStorageEndpoint: { type: 'string', nullable: true },
+ objectStorageRegion: { type: 'string', nullable: true },
+ objectStoragePort: { type: 'integer', nullable: true },
+ objectStorageAccessKey: { type: 'string', nullable: true },
+ objectStorageSecretKey: { type: 'string', nullable: true },
+ objectStorageUseSSL: { type: 'boolean' },
+ objectStorageUseProxy: { type: 'boolean' },
+ objectStorageSetPublicRead: { type: 'boolean' },
+ objectStorageS3ForcePathStyle: { type: 'boolean' },
},
+ 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 set = {} as Partial;
if (typeof ps.disableRegistration === 'boolean') {
@@ -367,8 +164,12 @@ export default define(meta, async (ps, me) => {
set.description = ps.description;
}
- if (ps.maxNoteTextLength) {
- set.maxNoteTextLength = ps.maxNoteTextLength;
+ if (ps.defaultLightTheme !== undefined) {
+ set.defaultLightTheme = ps.defaultLightTheme;
+ }
+
+ if (ps.defaultDarkTheme !== undefined) {
+ set.defaultDarkTheme = ps.defaultDarkTheme;
}
if (ps.localDriveCapacityMb !== undefined) {
@@ -383,10 +184,6 @@ export default define(meta, async (ps, me) => {
set.cacheRemoteFiles = ps.cacheRemoteFiles;
}
- if (ps.proxyRemoteFiles !== undefined) {
- set.proxyRemoteFiles = ps.proxyRemoteFiles;
- }
-
if (ps.emailRequiredForSignup !== undefined) {
set.emailRequiredForSignup = ps.emailRequiredForSignup;
}
diff --git a/packages/backend/src/server/api/endpoints/admin/vacuum.ts b/packages/backend/src/server/api/endpoints/admin/vacuum.ts
index 4229ef0d2..4c04e019d 100644
--- a/packages/backend/src/server/api/endpoints/admin/vacuum.ts
+++ b/packages/backend/src/server/api/endpoints/admin/vacuum.ts
@@ -1,26 +1,25 @@
-import $ from 'cafy';
-import define from '../../define';
+import define from '../../define.js';
import { getConnection } from 'typeorm';
-import { insertModerationLog } from '@/services/insert-moderation-log';
+import { insertModerationLog } from '@/services/insert-moderation-log.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
+} as const;
- params: {
- full: {
- validator: $.bool,
- },
- analyze: {
- validator: $.bool,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ full: { type: 'boolean' },
+ analyze: { type: 'boolean' },
},
+ required: ['full', 'analyze'],
} 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 params: string[] = [];
if (ps.full) {
diff --git a/packages/backend/src/server/api/endpoints/announcements.ts b/packages/backend/src/server/api/endpoints/announcements.ts
index 22c13743a..bba66e98c 100644
--- a/packages/backend/src/server/api/endpoints/announcements.ts
+++ b/packages/backend/src/server/api/endpoints/announcements.ts
@@ -1,34 +1,12 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../define';
-import { Announcements, AnnouncementReads } from '@/models/index';
-import { makePaginationQuery } from '../common/make-pagination-query';
+import define from '../define.js';
+import { Announcements, AnnouncementReads } from '@/models/index.js';
+import { makePaginationQuery } from '../common/make-pagination-query.js';
export const meta = {
tags: ['meta'],
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: {
type: 'array',
optional: false, nullable: false,
@@ -73,11 +51,22 @@ export const meta = {
},
} 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
-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 announcements = await query.take(ps.limit!).getMany();
+ const announcements = await query.take(ps.limit).getMany();
if (user) {
const reads = (await AnnouncementReads.find({
diff --git a/packages/backend/src/server/api/endpoints/antennas/create.ts b/packages/backend/src/server/api/endpoints/antennas/create.ts
index 2092d177b..92cbba817 100644
--- a/packages/backend/src/server/api/endpoints/antennas/create.ts
+++ b/packages/backend/src/server/api/endpoints/antennas/create.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import define from '../../define';
-import { genId } from '@/misc/gen-id';
-import { Antennas, UserLists, UserGroupJoinings } from '@/models/index';
-import { ID } from '@/misc/cafy-id';
-import { ApiError } from '../../error';
-import { publishInternalEvent } from '@/services/stream';
+import define from '../../define.js';
+import { genId } from '@/misc/gen-id.js';
+import { Antennas, UserLists, UserGroupJoinings } from '@/models/index.js';
+import { ApiError } from '../../error.js';
+import { publishInternalEvent } from '@/services/stream.js';
export const meta = {
tags: ['antennas'],
@@ -13,52 +11,6 @@ export const meta = {
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: {
noSuchUserList: {
message: 'No such user list.',
@@ -80,8 +32,36 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
let userList;
let userGroupJoining;
diff --git a/packages/backend/src/server/api/endpoints/antennas/delete.ts b/packages/backend/src/server/api/endpoints/antennas/delete.ts
index b2793fc70..4e6b8b3d2 100644
--- a/packages/backend/src/server/api/endpoints/antennas/delete.ts
+++ b/packages/backend/src/server/api/endpoints/antennas/delete.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Antennas } from '@/models/index';
-import { publishInternalEvent } from '@/services/stream';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Antennas } from '@/models/index.js';
+import { publishInternalEvent } from '@/services/stream.js';
export const meta = {
tags: ['antennas'],
@@ -12,12 +10,6 @@ export const meta = {
kind: 'write:account',
- params: {
- antennaId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchAntenna: {
message: 'No such antenna.',
@@ -27,8 +19,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const antenna = await Antennas.findOne({
id: ps.antennaId,
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/antennas/list.ts b/packages/backend/src/server/api/endpoints/antennas/list.ts
index bb5891261..accca5de7 100644
--- a/packages/backend/src/server/api/endpoints/antennas/list.ts
+++ b/packages/backend/src/server/api/endpoints/antennas/list.ts
@@ -1,5 +1,5 @@
-import define from '../../define';
-import { Antennas } from '@/models/index';
+import define from '../../define.js';
+import { Antennas } from '@/models/index.js';
export const meta = {
tags: ['antennas', 'account'],
@@ -19,8 +19,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 antennas = await Antennas.find({
userId: me.id,
});
diff --git a/packages/backend/src/server/api/endpoints/antennas/notes.ts b/packages/backend/src/server/api/endpoints/antennas/notes.ts
index eb7de901c..f0cb2ba3c 100644
--- a/packages/backend/src/server/api/endpoints/antennas/notes.ts
+++ b/packages/backend/src/server/api/endpoints/antennas/notes.ts
@@ -1,13 +1,11 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import readNote from '@/services/note/read';
-import { Antennas, Notes, AntennaNotes } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { ApiError } from '../../error';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
+import define from '../../define.js';
+import readNote from '@/services/note/read.js';
+import { Antennas, Notes, AntennaNotes } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { ApiError } from '../../error.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
export const meta = {
tags: ['antennas', 'account', 'notes'],
@@ -16,33 +14,6 @@ export const meta = {
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: {
noSuchAntenna: {
message: 'No such antenna.',
@@ -62,8 +33,21 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const antenna = await Antennas.findOne({
id: ps.antennaId,
userId: user.id,
@@ -81,10 +65,16 @@ export default define(meta, async (ps, user) => {
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere(`note.id IN (${ antennaQuery.getQuery() })`)
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
.leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner')
.setParameters(antennaQuery.getParameters());
generateVisibilityQuery(query, user);
@@ -92,7 +82,7 @@ export default define(meta, async (ps, user) => {
generateBlockedUserQuery(query, user);
const notes = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
if (notes.length > 0) {
diff --git a/packages/backend/src/server/api/endpoints/antennas/show.ts b/packages/backend/src/server/api/endpoints/antennas/show.ts
index a37d37d31..36c4da81b 100644
--- a/packages/backend/src/server/api/endpoints/antennas/show.ts
+++ b/packages/backend/src/server/api/endpoints/antennas/show.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Antennas } from '@/models/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Antennas } from '@/models/index.js';
export const meta = {
tags: ['antennas', 'account'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'read:account',
- params: {
- antennaId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchAntenna: {
message: 'No such antenna.',
@@ -32,8 +24,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
// Fetch the antenna
const antenna = await Antennas.findOne({
id: ps.antennaId,
diff --git a/packages/backend/src/server/api/endpoints/antennas/update.ts b/packages/backend/src/server/api/endpoints/antennas/update.ts
index 900f72550..a99964555 100644
--- a/packages/backend/src/server/api/endpoints/antennas/update.ts
+++ b/packages/backend/src/server/api/endpoints/antennas/update.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Antennas, UserLists, UserGroupJoinings } from '@/models/index';
-import { publishInternalEvent } from '@/services/stream';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Antennas, UserLists, UserGroupJoinings } from '@/models/index.js';
+import { publishInternalEvent } from '@/services/stream.js';
export const meta = {
tags: ['antennas'],
@@ -12,56 +10,6 @@ export const meta = {
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: {
noSuchAntenna: {
message: 'No such antenna.',
@@ -89,8 +37,37 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
// Fetch the antenna
const antenna = await Antennas.findOne({
id: ps.antennaId,
diff --git a/packages/backend/src/server/api/endpoints/ap/get.ts b/packages/backend/src/server/api/endpoints/ap/get.ts
index ff8c677b9..0cbe7ebc6 100644
--- a/packages/backend/src/server/api/endpoints/ap/get.ts
+++ b/packages/backend/src/server/api/endpoints/ap/get.ts
@@ -1,7 +1,6 @@
-import $ from 'cafy';
-import define from '../../define';
-import Resolver from '@/remote/activitypub/resolver';
-import { ApiError } from '../../error';
+import define from '../../define.js';
+import Resolver from '@/remote/activitypub/resolver.js';
+import { ApiError } from '../../error.js';
import ms from 'ms';
export const meta = {
@@ -14,12 +13,6 @@ export const meta = {
max: 30,
},
- params: {
- uri: {
- validator: $.str,
- },
- },
-
errors: {
},
@@ -29,8 +22,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ uri: { type: 'string' },
+ },
+ required: ['uri'],
+} as const;
+
// 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 object = await resolver.resolve(ps.uri);
return object;
diff --git a/packages/backend/src/server/api/endpoints/ap/show.ts b/packages/backend/src/server/api/endpoints/ap/show.ts
index 7d17d8edc..7595c38e8 100644
--- a/packages/backend/src/server/api/endpoints/ap/show.ts
+++ b/packages/backend/src/server/api/endpoints/ap/show.ts
@@ -1,18 +1,17 @@
-import $ from 'cafy';
-import define from '../../define';
-import config from '@/config/index';
-import { createPerson } from '@/remote/activitypub/models/person';
-import { createNote } from '@/remote/activitypub/models/note';
-import Resolver from '@/remote/activitypub/resolver';
-import { ApiError } from '../../error';
-import { extractDbHost } from '@/misc/convert-host';
-import { Users, Notes } from '@/models/index';
-import { Note } from '@/models/entities/note';
-import { User } from '@/models/entities/user';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { isActor, isPost, getApId } from '@/remote/activitypub/type';
+import define from '../../define.js';
+import config from '@/config/index.js';
+import { createPerson } from '@/remote/activitypub/models/person.js';
+import { createNote } from '@/remote/activitypub/models/note.js';
+import Resolver from '@/remote/activitypub/resolver.js';
+import { ApiError } from '../../error.js';
+import { extractDbHost } from '@/misc/convert-host.js';
+import { Users, Notes } from '@/models/index.js';
+import { Note } from '@/models/entities/note.js';
+import { User } from '@/models/entities/user.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { isActor, isPost, getApId } from '@/remote/activitypub/type.js';
import ms from 'ms';
-import { SchemaType } from '@/misc/schema';
+import { SchemaType } from '@/misc/schema.js';
export const meta = {
tags: ['federation'],
@@ -24,12 +23,6 @@ export const meta = {
max: 30,
},
- params: {
- uri: {
- validator: $.str,
- },
- },
-
errors: {
noSuchObject: {
message: 'No such object.',
@@ -75,8 +68,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ uri: { type: 'string' },
+ },
+ required: ['uri'],
+} as const;
+
// 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);
if (object) {
return object;
diff --git a/packages/backend/src/server/api/endpoints/app/create.ts b/packages/backend/src/server/api/endpoints/app/create.ts
index fbe6690f1..e0cf8632f 100644
--- a/packages/backend/src/server/api/endpoints/app/create.ts
+++ b/packages/backend/src/server/api/endpoints/app/create.ts
@@ -1,35 +1,14 @@
-import $ from 'cafy';
-import define from '../../define';
-import { Apps } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { unique } from '@/prelude/array';
-import { secureRndstr } from '@/misc/secure-rndstr';
+import define from '../../define.js';
+import { Apps } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { unique } from '@/prelude/array.js';
+import { secureRndstr } from '@/misc/secure-rndstr.js';
export const meta = {
tags: ['app'],
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: {
type: 'object',
optional: false, nullable: false,
@@ -37,8 +16,21 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
// Generate secret
const secret = secureRndstr(32, true);
diff --git a/packages/backend/src/server/api/endpoints/app/show.ts b/packages/backend/src/server/api/endpoints/app/show.ts
index 9f4777b38..54e714e19 100644
--- a/packages/backend/src/server/api/endpoints/app/show.ts
+++ b/packages/backend/src/server/api/endpoints/app/show.ts
@@ -1,18 +1,10 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Apps } from '@/models/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Apps } from '@/models/index.js';
export const meta = {
tags: ['app'],
- params: {
- appId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchApp: {
message: 'No such app.',
@@ -28,8 +20,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user, token) => {
+export default define(meta, paramDef, async (ps, user, token) => {
const isSecure = user != null && token == null;
// Lookup app
diff --git a/packages/backend/src/server/api/endpoints/auth/accept.ts b/packages/backend/src/server/api/endpoints/auth/accept.ts
index f028135ca..0760eef52 100644
--- a/packages/backend/src/server/api/endpoints/auth/accept.ts
+++ b/packages/backend/src/server/api/endpoints/auth/accept.ts
@@ -1,10 +1,9 @@
-import * as crypto from 'crypto';
-import $ from 'cafy';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { AuthSessions, AccessTokens, Apps } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { secureRndstr } from '@/misc/secure-rndstr';
+import * as crypto from 'node:crypto';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { AuthSessions, AccessTokens, Apps } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { secureRndstr } from '@/misc/secure-rndstr.js';
export const meta = {
tags: ['auth'],
@@ -13,12 +12,6 @@ export const meta = {
secure: true,
- params: {
- token: {
- validator: $.str,
- },
- },
-
errors: {
noSuchSession: {
message: 'No such session.',
@@ -28,8 +21,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ token: { type: 'string' },
+ },
+ required: ['token'],
+} 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) => {
// Fetch token
const session = await AuthSessions
.findOne({ token: ps.token });
diff --git a/packages/backend/src/server/api/endpoints/auth/session/generate.ts b/packages/backend/src/server/api/endpoints/auth/session/generate.ts
index 98987eba5..bd571327d 100644
--- a/packages/backend/src/server/api/endpoints/auth/session/generate.ts
+++ b/packages/backend/src/server/api/endpoints/auth/session/generate.ts
@@ -1,22 +1,15 @@
import { v4 as uuid } from 'uuid';
-import $ from 'cafy';
-import config from '@/config/index';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { Apps, AuthSessions } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import config from '@/config/index.js';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { Apps, AuthSessions } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
tags: ['auth'],
requireCredential: false,
- params: {
- appSecret: {
- validator: $.str,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -42,8 +35,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ appSecret: { type: 'string' },
+ },
+ required: ['appSecret'],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
// Lookup app
const app = await Apps.findOne({
secret: ps.appSecret,
diff --git a/packages/backend/src/server/api/endpoints/auth/session/show.ts b/packages/backend/src/server/api/endpoints/auth/session/show.ts
index ae0d016ce..d40c9363c 100644
--- a/packages/backend/src/server/api/endpoints/auth/session/show.ts
+++ b/packages/backend/src/server/api/endpoints/auth/session/show.ts
@@ -1,19 +1,12 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { AuthSessions } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { AuthSessions } from '@/models/index.js';
export const meta = {
tags: ['auth'],
requireCredential: false,
- params: {
- token: {
- validator: $.str,
- },
- },
-
errors: {
noSuchSession: {
message: 'No such session.',
@@ -44,8 +37,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ token: { type: 'string' },
+ },
+ required: ['token'],
+} 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) => {
// Lookup session
const session = await AuthSessions.findOne({
token: ps.token,
diff --git a/packages/backend/src/server/api/endpoints/auth/session/userkey.ts b/packages/backend/src/server/api/endpoints/auth/session/userkey.ts
index fe0211ebe..b699c6fa2 100644
--- a/packages/backend/src/server/api/endpoints/auth/session/userkey.ts
+++ b/packages/backend/src/server/api/endpoints/auth/session/userkey.ts
@@ -1,23 +1,12 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { Apps, AuthSessions, AccessTokens, Users } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { Apps, AuthSessions, AccessTokens, Users } from '@/models/index.js';
export const meta = {
tags: ['auth'],
requireCredential: false,
- params: {
- appSecret: {
- validator: $.str,
- },
-
- token: {
- validator: $.str,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -56,8 +45,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ appSecret: { type: 'string' },
+ token: { type: 'string' },
+ },
+ required: ['appSecret', 'token'],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
// Lookup app
const app = await Apps.findOne({
secret: ps.appSecret,
diff --git a/packages/backend/src/server/api/endpoints/blocking/create.ts b/packages/backend/src/server/api/endpoints/blocking/create.ts
index 6d555ff56..c5e73c013 100644
--- a/packages/backend/src/server/api/endpoints/blocking/create.ts
+++ b/packages/backend/src/server/api/endpoints/blocking/create.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
import ms from 'ms';
-import create from '@/services/blocking/create';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { getUser } from '../../common/getters';
-import { Blockings, NoteWatchings, Users } from '@/models/index';
+import create from '@/services/blocking/create.js';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { getUser } from '../../common/getters.js';
+import { Blockings, NoteWatchings, Users } from '@/models/index.js';
export const meta = {
tags: ['account'],
@@ -19,12 +17,6 @@ export const meta = {
kind: 'write:blocks',
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -52,8 +44,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const blocker = await Users.findOneOrFail(user.id);
// 自分自身
diff --git a/packages/backend/src/server/api/endpoints/blocking/delete.ts b/packages/backend/src/server/api/endpoints/blocking/delete.ts
index 942cddaed..a45547290 100644
--- a/packages/backend/src/server/api/endpoints/blocking/delete.ts
+++ b/packages/backend/src/server/api/endpoints/blocking/delete.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
import ms from 'ms';
-import deleteBlocking from '@/services/blocking/delete';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { getUser } from '../../common/getters';
-import { Blockings, Users } from '@/models/index';
+import deleteBlocking from '@/services/blocking/delete.js';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { getUser } from '../../common/getters.js';
+import { Blockings, Users } from '@/models/index.js';
export const meta = {
tags: ['account'],
@@ -19,12 +17,6 @@ export const meta = {
kind: 'write:blocks',
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -52,8 +44,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const blocker = await Users.findOneOrFail(user.id);
// Check if the blockee is yourself
diff --git a/packages/backend/src/server/api/endpoints/blocking/list.ts b/packages/backend/src/server/api/endpoints/blocking/list.ts
index 9a4f66214..29095ebe2 100644
--- a/packages/backend/src/server/api/endpoints/blocking/list.ts
+++ b/packages/backend/src/server/api/endpoints/blocking/list.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Blockings } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { Blockings } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['account'],
@@ -11,21 +9,6 @@ export const meta = {
kind: 'read:blocks',
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 30,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -37,13 +20,23 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 30 },
+ sinceId: { type: 'string', format: 'misskey:id' },
+ untilId: { type: 'string', format: 'misskey:id' },
+ },
+ 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(Blockings.createQueryBuilder('blocking'), ps.sinceId, ps.untilId)
.andWhere(`blocking.blockerId = :meId`, { meId: me.id });
const blockings = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Blockings.packMany(blockings, me);
diff --git a/packages/backend/src/server/api/endpoints/channels/create.ts b/packages/backend/src/server/api/endpoints/channels/create.ts
index 68cdf1143..16456b9c0 100644
--- a/packages/backend/src/server/api/endpoints/channels/create.ts
+++ b/packages/backend/src/server/api/endpoints/channels/create.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Channels, DriveFiles } from '@/models/index';
-import { Channel } from '@/models/entities/channel';
-import { genId } from '@/misc/gen-id';
-import { ID } from '@/misc/cafy-id';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Channels, DriveFiles } from '@/models/index.js';
+import { Channel } from '@/models/entities/channel.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
tags: ['channels'],
@@ -13,20 +11,6 @@ export const meta = {
kind: 'write:channels',
- params: {
- name: {
- validator: $.str.range(1, 128),
- },
-
- description: {
- validator: $.nullable.optional.str.range(1, 2048),
- },
-
- bannerId: {
- validator: $.nullable.optional.type(ID),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -42,8 +26,18 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ name: { type: 'string', minLength: 1, maxLength: 128 },
+ description: { type: 'string', nullable: true, minLength: 1, maxLength: 2048 },
+ bannerId: { type: 'string', format: 'misskey:id', nullable: true },
+ },
+ required: ['name'],
+} 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 banner = null;
if (ps.bannerId != null) {
banner = await DriveFiles.findOne({
diff --git a/packages/backend/src/server/api/endpoints/channels/featured.ts b/packages/backend/src/server/api/endpoints/channels/featured.ts
index ceadde907..73980c0fa 100644
--- a/packages/backend/src/server/api/endpoints/channels/featured.ts
+++ b/packages/backend/src/server/api/endpoints/channels/featured.ts
@@ -1,5 +1,5 @@
-import define from '../../define';
-import { Channels } from '@/models/index';
+import define from '../../define.js';
+import { Channels } from '@/models/index.js';
export const meta = {
tags: ['channels'],
@@ -17,8 +17,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 = Channels.createQueryBuilder('channel')
.where('channel.lastNotedAt IS NOT NULL')
.orderBy('channel.lastNotedAt', 'DESC');
diff --git a/packages/backend/src/server/api/endpoints/channels/follow.ts b/packages/backend/src/server/api/endpoints/channels/follow.ts
index bf580eea6..4372c283c 100644
--- a/packages/backend/src/server/api/endpoints/channels/follow.ts
+++ b/packages/backend/src/server/api/endpoints/channels/follow.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Channels, ChannelFollowings } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { publishUserEvent } from '@/services/stream';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Channels, ChannelFollowings } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { publishUserEvent } from '@/services/stream.js';
export const meta = {
tags: ['channels'],
@@ -13,12 +11,6 @@ export const meta = {
kind: 'write:channels',
- params: {
- channelId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchChannel: {
message: 'No such channel.',
@@ -28,8 +20,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ channelId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['channelId'],
+} 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 channel = await Channels.findOne({
id: ps.channelId,
});
diff --git a/packages/backend/src/server/api/endpoints/channels/followed.ts b/packages/backend/src/server/api/endpoints/channels/followed.ts
index 9e4c942af..e4aa4d161 100644
--- a/packages/backend/src/server/api/endpoints/channels/followed.ts
+++ b/packages/backend/src/server/api/endpoints/channels/followed.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Channels, ChannelFollowings } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { Channels, ChannelFollowings } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['channels', 'account'],
@@ -11,21 +9,6 @@ export const meta = {
kind: 'read:channels',
- params: {
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 5,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -37,13 +20,23 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ sinceId: { type: 'string', format: 'misskey:id' },
+ untilId: { type: 'string', format: 'misskey:id' },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 5 },
+ },
+ 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(ChannelFollowings.createQueryBuilder(), ps.sinceId, ps.untilId)
.andWhere({ followerId: me.id });
const followings = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Promise.all(followings.map(x => Channels.pack(x.followeeId, me)));
diff --git a/packages/backend/src/server/api/endpoints/channels/owned.ts b/packages/backend/src/server/api/endpoints/channels/owned.ts
index 5473636a8..ed7e41cac 100644
--- a/packages/backend/src/server/api/endpoints/channels/owned.ts
+++ b/packages/backend/src/server/api/endpoints/channels/owned.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Channels } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { Channels } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['channels', 'account'],
@@ -11,21 +9,6 @@ export const meta = {
kind: 'read:channels',
- params: {
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 5,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -37,13 +20,23 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ sinceId: { type: 'string', format: 'misskey:id' },
+ untilId: { type: 'string', format: 'misskey:id' },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 5 },
+ },
+ 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(Channels.createQueryBuilder(), ps.sinceId, ps.untilId)
.andWhere({ userId: me.id });
const channels = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Promise.all(channels.map(x => Channels.pack(x, me)));
diff --git a/packages/backend/src/server/api/endpoints/channels/show.ts b/packages/backend/src/server/api/endpoints/channels/show.ts
index 598a87ec4..ea4e01307 100644
--- a/packages/backend/src/server/api/endpoints/channels/show.ts
+++ b/packages/backend/src/server/api/endpoints/channels/show.ts
@@ -1,20 +1,12 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Channels } from '@/models/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Channels } from '@/models/index.js';
export const meta = {
tags: ['channels'],
requireCredential: false,
- params: {
- channelId: {
- validator: $.type(ID),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -30,8 +22,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ channelId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['channelId'],
+} 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 channel = await Channels.findOne({
id: ps.channelId,
});
diff --git a/packages/backend/src/server/api/endpoints/channels/timeline.ts b/packages/backend/src/server/api/endpoints/channels/timeline.ts
index 2639095f8..57a9fa44b 100644
--- a/packages/backend/src/server/api/endpoints/channels/timeline.ts
+++ b/packages/backend/src/server/api/endpoints/channels/timeline.ts
@@ -1,43 +1,14 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Notes, Channels } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { activeUsersChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Notes, Channels } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { activeUsersChart } from '@/services/chart/index.js';
export const meta = {
tags: ['notes', 'channels'],
requireCredential: false,
- params: {
- channelId: {
- 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,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -57,8 +28,21 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ channelId: { 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: ['channelId'],
+} 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 channel = await Channels.findOne({
id: ps.channelId,
});
@@ -71,14 +55,20 @@ export default define(meta, async (ps, user) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('note.channelId = :channelId', { channelId: channel.id })
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
.leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner')
.leftJoinAndSelect('note.channel', 'channel');
//#endregion
- const timeline = await query.take(ps.limit!).getMany();
+ const timeline = await query.take(ps.limit).getMany();
if (user) activeUsersChart.read(user);
diff --git a/packages/backend/src/server/api/endpoints/channels/unfollow.ts b/packages/backend/src/server/api/endpoints/channels/unfollow.ts
index ada0cb29f..32beb24d6 100644
--- a/packages/backend/src/server/api/endpoints/channels/unfollow.ts
+++ b/packages/backend/src/server/api/endpoints/channels/unfollow.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Channels, ChannelFollowings } from '@/models/index';
-import { publishUserEvent } from '@/services/stream';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Channels, ChannelFollowings } from '@/models/index.js';
+import { publishUserEvent } from '@/services/stream.js';
export const meta = {
tags: ['channels'],
@@ -12,12 +10,6 @@ export const meta = {
kind: 'write:channels',
- params: {
- channelId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchChannel: {
message: 'No such channel.',
@@ -27,8 +19,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ channelId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['channelId'],
+} 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 channel = await Channels.findOne({
id: ps.channelId,
});
diff --git a/packages/backend/src/server/api/endpoints/channels/update.ts b/packages/backend/src/server/api/endpoints/channels/update.ts
index 1f7108a1c..2f2b4aeeb 100644
--- a/packages/backend/src/server/api/endpoints/channels/update.ts
+++ b/packages/backend/src/server/api/endpoints/channels/update.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Channels, DriveFiles } from '@/models/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Channels, DriveFiles } from '@/models/index.js';
export const meta = {
tags: ['channels'],
@@ -11,24 +9,6 @@ export const meta = {
kind: 'write:channels',
- params: {
- channelId: {
- validator: $.type(ID),
- },
-
- name: {
- validator: $.optional.str.range(1, 128),
- },
-
- description: {
- validator: $.nullable.optional.str.range(1, 2048),
- },
-
- bannerId: {
- validator: $.nullable.optional.type(ID),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -56,8 +36,19 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ channelId: { type: 'string', format: 'misskey:id' },
+ name: { type: 'string', minLength: 1, maxLength: 128 },
+ description: { type: 'string', nullable: true, minLength: 1, maxLength: 2048 },
+ bannerId: { type: 'string', format: 'misskey:id', nullable: true },
+ },
+ required: ['channelId'],
+} 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 channel = await Channels.findOne({
id: ps.channelId,
});
diff --git a/packages/backend/src/server/api/endpoints/charts/active-users.ts b/packages/backend/src/server/api/endpoints/charts/active-users.ts
index a51cd0035..97f7885db 100644
--- a/packages/backend/src/server/api/endpoints/charts/active-users.ts
+++ b/packages/backend/src/server/api/endpoints/charts/active-users.ts
@@ -1,31 +1,24 @@
-import $ from 'cafy';
-import define from '../../define';
-import { convertLog } from '@/services/chart/core';
-import { activeUsersChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { activeUsersChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts', 'users'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(activeUsersChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
},
-
- // TODO: response definition
+ required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await activeUsersChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
+export default define(meta, paramDef, async (ps) => {
+ return await activeUsersChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/packages/backend/src/server/api/endpoints/charts/ap-request.ts b/packages/backend/src/server/api/endpoints/charts/ap-request.ts
index 38bbddb27..4477bfc98 100644
--- a/packages/backend/src/server/api/endpoints/charts/ap-request.ts
+++ b/packages/backend/src/server/api/endpoints/charts/ap-request.ts
@@ -1,31 +1,24 @@
-import $ from 'cafy';
-import define from '../../define';
-import { convertLog } from '@/services/chart/core';
-import { apRequestChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { apRequestChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(apRequestChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
},
-
- // TODO: response definition
+ required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await apRequestChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
+export default define(meta, paramDef, async (ps) => {
+ return await apRequestChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/packages/backend/src/server/api/endpoints/charts/drive.ts b/packages/backend/src/server/api/endpoints/charts/drive.ts
index 4bbb9861f..fd6033392 100644
--- a/packages/backend/src/server/api/endpoints/charts/drive.ts
+++ b/packages/backend/src/server/api/endpoints/charts/drive.ts
@@ -1,31 +1,24 @@
-import $ from 'cafy';
-import define from '../../define';
-import { convertLog } from '@/services/chart/core';
-import { driveChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { driveChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts', 'drive'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(driveChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
},
-
- // TODO: response definition
+ required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await driveChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
+export default define(meta, paramDef, async (ps) => {
+ return await driveChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/packages/backend/src/server/api/endpoints/charts/federation.ts b/packages/backend/src/server/api/endpoints/charts/federation.ts
index 237678ffe..f842f574e 100644
--- a/packages/backend/src/server/api/endpoints/charts/federation.ts
+++ b/packages/backend/src/server/api/endpoints/charts/federation.ts
@@ -1,31 +1,24 @@
-import $ from 'cafy';
-import define from '../../define';
-import { convertLog } from '@/services/chart/core';
-import { federationChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { federationChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(federationChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
},
-
- // TODO: response definition
+ required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await federationChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
+export default define(meta, paramDef, async (ps) => {
+ return await federationChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/packages/backend/src/server/api/endpoints/charts/hashtag.ts b/packages/backend/src/server/api/endpoints/charts/hashtag.ts
index 6c12cb063..01407defd 100644
--- a/packages/backend/src/server/api/endpoints/charts/hashtag.ts
+++ b/packages/backend/src/server/api/endpoints/charts/hashtag.ts
@@ -1,35 +1,25 @@
-import $ from 'cafy';
-import define from '../../define';
-import { convertLog } from '@/services/chart/core';
-import { hashtagChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { hashtagChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts', 'hashtags'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(hashtagChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
-
- tag: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
+ tag: { type: 'string' },
},
-
- // TODO: response definition
+ required: ['span', 'tag'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await hashtagChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.tag);
+export default define(meta, paramDef, async (ps) => {
+ return await hashtagChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.tag);
});
diff --git a/packages/backend/src/server/api/endpoints/charts/instance.ts b/packages/backend/src/server/api/endpoints/charts/instance.ts
index 32a10d5a2..2d12951c6 100644
--- a/packages/backend/src/server/api/endpoints/charts/instance.ts
+++ b/packages/backend/src/server/api/endpoints/charts/instance.ts
@@ -1,35 +1,25 @@
-import $ from 'cafy';
-import define from '../../define';
-import { convertLog } from '@/services/chart/core';
-import { instanceChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { instanceChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(instanceChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
-
- host: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
+ host: { type: 'string' },
},
-
- // TODO: response definition
+ required: ['span', 'host'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await instanceChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.host);
+export default define(meta, paramDef, async (ps) => {
+ return await instanceChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.host);
});
diff --git a/packages/backend/src/server/api/endpoints/charts/notes.ts b/packages/backend/src/server/api/endpoints/charts/notes.ts
index 09255f1d2..b6089f67e 100644
--- a/packages/backend/src/server/api/endpoints/charts/notes.ts
+++ b/packages/backend/src/server/api/endpoints/charts/notes.ts
@@ -1,31 +1,24 @@
-import $ from 'cafy';
-import define from '../../define';
-import { convertLog } from '@/services/chart/core';
-import { notesChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { notesChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts', 'notes'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(notesChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
},
-
- // TODO: response definition
+ required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await notesChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
+export default define(meta, paramDef, async (ps) => {
+ return await notesChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/packages/backend/src/server/api/endpoints/charts/user/drive.ts b/packages/backend/src/server/api/endpoints/charts/user/drive.ts
index 89379858d..e5db7131a 100644
--- a/packages/backend/src/server/api/endpoints/charts/user/drive.ts
+++ b/packages/backend/src/server/api/endpoints/charts/user/drive.ts
@@ -1,36 +1,25 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { convertLog } from '@/services/chart/core';
-import { perUserDriveChart } from '@/services/chart/index';
+import define from '../../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { perUserDriveChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts', 'drive', 'users'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(perUserDriveChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
-
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
+ userId: { type: 'string', format: 'misskey:id' },
},
-
- // TODO: response definition
+ required: ['span', 'userId'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await perUserDriveChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
+export default define(meta, paramDef, async (ps) => {
+ return await perUserDriveChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/packages/backend/src/server/api/endpoints/charts/user/following.ts b/packages/backend/src/server/api/endpoints/charts/user/following.ts
index 26c3f5c12..9b72de745 100644
--- a/packages/backend/src/server/api/endpoints/charts/user/following.ts
+++ b/packages/backend/src/server/api/endpoints/charts/user/following.ts
@@ -1,36 +1,25 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { convertLog } from '@/services/chart/core';
-import { perUserFollowingChart } from '@/services/chart/index';
+import define from '../../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { perUserFollowingChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts', 'users', 'following'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(perUserFollowingChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
-
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
+ userId: { type: 'string', format: 'misskey:id' },
},
-
- // TODO: response definition
+ required: ['span', 'userId'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await perUserFollowingChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
+export default define(meta, paramDef, async (ps) => {
+ return await perUserFollowingChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/packages/backend/src/server/api/endpoints/charts/user/notes.ts b/packages/backend/src/server/api/endpoints/charts/user/notes.ts
index ecf85becf..7cc6cbf31 100644
--- a/packages/backend/src/server/api/endpoints/charts/user/notes.ts
+++ b/packages/backend/src/server/api/endpoints/charts/user/notes.ts
@@ -1,36 +1,25 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { convertLog } from '@/services/chart/core';
-import { perUserNotesChart } from '@/services/chart/index';
+import define from '../../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { perUserNotesChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts', 'users', 'notes'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(perUserNotesChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
-
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
+ userId: { type: 'string', format: 'misskey:id' },
},
-
- // TODO: response definition
+ required: ['span', 'userId'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await perUserNotesChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
+export default define(meta, paramDef, async (ps) => {
+ return await perUserNotesChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/packages/backend/src/server/api/endpoints/charts/user/reactions.ts b/packages/backend/src/server/api/endpoints/charts/user/reactions.ts
index 6e08d0751..5c58a7f15 100644
--- a/packages/backend/src/server/api/endpoints/charts/user/reactions.ts
+++ b/packages/backend/src/server/api/endpoints/charts/user/reactions.ts
@@ -1,36 +1,25 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ID } from '@/misc/cafy-id';
-import { convertLog } from '@/services/chart/core';
-import { perUserReactionsChart } from '@/services/chart/index';
+import define from '../../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { perUserReactionsChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts', 'users', 'reactions'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(perUserReactionsChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
-
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
+ userId: { type: 'string', format: 'misskey:id' },
},
-
- // TODO: response definition
+ required: ['span', 'userId'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await perUserReactionsChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
+export default define(meta, paramDef, async (ps) => {
+ return await perUserReactionsChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/packages/backend/src/server/api/endpoints/charts/users.ts b/packages/backend/src/server/api/endpoints/charts/users.ts
index 15a9ec038..49c762b2e 100644
--- a/packages/backend/src/server/api/endpoints/charts/users.ts
+++ b/packages/backend/src/server/api/endpoints/charts/users.ts
@@ -1,31 +1,24 @@
-import $ from 'cafy';
-import define from '../../define';
-import { convertLog } from '@/services/chart/core';
-import { usersChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { getJsonSchema } from '@/services/chart/core.js';
+import { usersChart } from '@/services/chart/index.js';
export const meta = {
tags: ['charts', 'users'],
- params: {
- span: {
- validator: $.str.or(['day', 'hour']),
- },
+ res: getJsonSchema(usersChart.schema),
+} as const;
- limit: {
- validator: $.optional.num.range(1, 500),
- default: 30,
- },
-
- offset: {
- validator: $.optional.nullable.num,
- default: null,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ span: { type: 'string', enum: ['day', 'hour'] },
+ limit: { type: 'integer', minimum: 1, maximum: 500, default: 30 },
+ offset: { type: 'integer', nullable: true, default: null },
},
-
- // TODO: response definition
+ required: ['span'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
- return await usersChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
+export default define(meta, paramDef, async (ps) => {
+ return await usersChart.getChart(ps.span, ps.limit, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/packages/backend/src/server/api/endpoints/clips/add-note.ts b/packages/backend/src/server/api/endpoints/clips/add-note.ts
index 4a740b6cf..c630302b9 100644
--- a/packages/backend/src/server/api/endpoints/clips/add-note.ts
+++ b/packages/backend/src/server/api/endpoints/clips/add-note.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ClipNotes, Clips } from '@/models/index';
-import { ApiError } from '../../error';
-import { genId } from '@/misc/gen-id';
-import { getNote } from '../../common/getters';
+import define from '../../define.js';
+import { ClipNotes, Clips } from '@/models/index.js';
+import { ApiError } from '../../error.js';
+import { genId } from '@/misc/gen-id.js';
+import { getNote } from '../../common/getters.js';
export const meta = {
tags: ['account', 'notes', 'clips'],
@@ -13,16 +11,6 @@ export const meta = {
kind: 'write:account',
- params: {
- clipId: {
- validator: $.type(ID),
- },
-
- noteId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchClip: {
message: 'No such clip.',
@@ -44,8 +32,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ clipId: { type: 'string', format: 'misskey:id' },
+ noteId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['clipId', '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 clip = await Clips.findOne({
id: ps.clipId,
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/clips/create.ts b/packages/backend/src/server/api/endpoints/clips/create.ts
index 852e66c9e..531847d15 100644
--- a/packages/backend/src/server/api/endpoints/clips/create.ts
+++ b/packages/backend/src/server/api/endpoints/clips/create.ts
@@ -1,7 +1,6 @@
-import $ from 'cafy';
-import define from '../../define';
-import { genId } from '@/misc/gen-id';
-import { Clips } from '@/models/index';
+import define from '../../define.js';
+import { genId } from '@/misc/gen-id.js';
+import { Clips } from '@/models/index.js';
export const meta = {
tags: ['clips'],
@@ -10,20 +9,6 @@ export const meta = {
kind: 'write:account',
- params: {
- name: {
- validator: $.str.range(1, 100),
- },
-
- isPublic: {
- validator: $.optional.bool,
- },
-
- description: {
- validator: $.optional.nullable.str.range(1, 2048),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -31,8 +16,18 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ name: { type: 'string', minLength: 1, maxLength: 100 },
+ isPublic: { type: 'boolean' },
+ description: { type: 'string', nullable: true, minLength: 1, maxLength: 2048 },
+ },
+ required: ['name'],
+} 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 clip = await Clips.insert({
id: genId(),
createdAt: new Date(),
diff --git a/packages/backend/src/server/api/endpoints/clips/delete.ts b/packages/backend/src/server/api/endpoints/clips/delete.ts
index 85c64a115..675db1d57 100644
--- a/packages/backend/src/server/api/endpoints/clips/delete.ts
+++ b/packages/backend/src/server/api/endpoints/clips/delete.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Clips } from '@/models/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Clips } from '@/models/index.js';
export const meta = {
tags: ['clips'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'write:account',
- params: {
- clipId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchClip: {
message: 'No such clip.',
@@ -26,8 +18,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ clipId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['clipId'],
+} 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 clip = await Clips.findOne({
id: ps.clipId,
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/clips/list.ts b/packages/backend/src/server/api/endpoints/clips/list.ts
index d88897d16..1c955d64f 100644
--- a/packages/backend/src/server/api/endpoints/clips/list.ts
+++ b/packages/backend/src/server/api/endpoints/clips/list.ts
@@ -1,5 +1,5 @@
-import define from '../../define';
-import { Clips } from '@/models/index';
+import define from '../../define.js';
+import { Clips } from '@/models/index.js';
export const meta = {
tags: ['clips', 'account'],
@@ -19,8 +19,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 clips = await Clips.find({
userId: me.id,
});
diff --git a/packages/backend/src/server/api/endpoints/clips/notes.ts b/packages/backend/src/server/api/endpoints/clips/notes.ts
index eeb20631c..2627884ee 100644
--- a/packages/backend/src/server/api/endpoints/clips/notes.ts
+++ b/packages/backend/src/server/api/endpoints/clips/notes.ts
@@ -1,12 +1,10 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ClipNotes, Clips, Notes } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { ApiError } from '../../error';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
+import define from '../../define.js';
+import { ClipNotes, Clips, Notes } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { ApiError } from '../../error.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
export const meta = {
tags: ['account', 'notes', 'clips'],
@@ -15,25 +13,6 @@ export const meta = {
kind: 'read:account',
- params: {
- clipId: {
- validator: $.type(ID),
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
- },
-
errors: {
noSuchClip: {
message: 'No such clip.',
@@ -53,8 +32,19 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ clipId: { 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: ['clipId'],
+} 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 clip = await Clips.findOne({
id: ps.clipId,
});
@@ -74,10 +64,16 @@ export default define(meta, async (ps, user) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(`note.id IN (${ clipQuery.getQuery() })`)
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
.leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner')
.setParameters(clipQuery.getParameters());
if (user) {
@@ -87,7 +83,7 @@ export default define(meta, async (ps, user) => {
}
const notes = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Notes.packMany(notes, user);
diff --git a/packages/backend/src/server/api/endpoints/clips/show.ts b/packages/backend/src/server/api/endpoints/clips/show.ts
index 0a4567201..0a3b25c94 100644
--- a/packages/backend/src/server/api/endpoints/clips/show.ts
+++ b/packages/backend/src/server/api/endpoints/clips/show.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Clips } from '@/models/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Clips } from '@/models/index.js';
export const meta = {
tags: ['clips', 'account'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'read:account',
- params: {
- clipId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchClip: {
message: 'No such clip.',
@@ -32,8 +24,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ clipId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['clipId'],
+} 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) => {
// Fetch the clip
const clip = await Clips.findOne({
id: ps.clipId,
diff --git a/packages/backend/src/server/api/endpoints/clips/update.ts b/packages/backend/src/server/api/endpoints/clips/update.ts
index 795483d5b..0ac5ccd04 100644
--- a/packages/backend/src/server/api/endpoints/clips/update.ts
+++ b/packages/backend/src/server/api/endpoints/clips/update.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Clips } from '@/models/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Clips } from '@/models/index.js';
export const meta = {
tags: ['clips'],
@@ -11,24 +9,6 @@ export const meta = {
kind: 'write:account',
- params: {
- clipId: {
- validator: $.type(ID),
- },
-
- name: {
- validator: $.str.range(1, 100),
- },
-
- isPublic: {
- validator: $.optional.bool,
- },
-
- description: {
- validator: $.optional.nullable.str.range(1, 2048),
- },
- },
-
errors: {
noSuchClip: {
message: 'No such clip.',
@@ -44,8 +24,19 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ clipId: { type: 'string', format: 'misskey:id' },
+ name: { type: 'string', minLength: 1, maxLength: 100 },
+ isPublic: { type: 'boolean' },
+ description: { type: 'string', nullable: true, minLength: 1, maxLength: 2048 },
+ },
+ required: ['clipId', 'name'],
+} 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) => {
// Fetch the clip
const clip = await Clips.findOne({
id: ps.clipId,
diff --git a/packages/backend/src/server/api/endpoints/drive.ts b/packages/backend/src/server/api/endpoints/drive.ts
index d9ab9883c..c599d96ca 100644
--- a/packages/backend/src/server/api/endpoints/drive.ts
+++ b/packages/backend/src/server/api/endpoints/drive.ts
@@ -1,6 +1,6 @@
-import define from '../define';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { DriveFiles } from '@/models/index';
+import define from '../define.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
tags: ['drive', 'account'],
@@ -25,8 +25,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 instance = await fetchMeta(true);
// Calculate drive usage
diff --git a/packages/backend/src/server/api/endpoints/drive/files.ts b/packages/backend/src/server/api/endpoints/drive/files.ts
index a5c0a626a..40e6c16c9 100644
--- a/packages/backend/src/server/api/endpoints/drive/files.ts
+++ b/packages/backend/src/server/api/endpoints/drive/files.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { DriveFiles } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { DriveFiles } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['drive'],
@@ -11,30 +9,6 @@ export const meta = {
kind: 'read:drive',
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
-
- folderId: {
- validator: $.optional.nullable.type(ID),
- default: null,
- },
-
- type: {
- validator: $.optional.nullable.str.match(/^[a-zA-Z\/\-*]+$/),
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -46,8 +20,20 @@ export const meta = {
},
} 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' },
+ folderId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
+ type: { type: 'string', nullable: true, pattern: /^[a-zA-Z\/\-*]+$/.toString().slice(1, -1) },
+ },
+ 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 = makePaginationQuery(DriveFiles.createQueryBuilder('file'), ps.sinceId, ps.untilId)
.andWhere('file.userId = :userId', { userId: user.id });
@@ -65,7 +51,7 @@ export default define(meta, async (ps, user) => {
}
}
- const files = await query.take(ps.limit!).getMany();
+ const files = await query.take(ps.limit).getMany();
return await DriveFiles.packMany(files, { detail: false, self: true });
});
diff --git a/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts b/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts
index 835dde805..3c68beee1 100644
--- a/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts
+++ b/packages/backend/src/server/api/endpoints/drive/files/attached-notes.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { DriveFiles, Notes } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { DriveFiles, Notes } from '@/models/index.js';
export const meta = {
tags: ['drive', 'notes'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'read:drive',
- params: {
- fileId: {
- validator: $.type(ID),
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -36,8 +28,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
// Fetch file
const file = await DriveFiles.findOne({
id: ps.fileId,
diff --git a/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts b/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts
index a45d357ee..7e5cb2498 100644
--- a/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts
+++ b/packages/backend/src/server/api/endpoints/drive/files/check-existence.ts
@@ -1,6 +1,5 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { DriveFiles } from '@/models/index';
+import define from '../../../define.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
tags: ['drive'],
@@ -9,20 +8,22 @@ export const meta = {
kind: 'read:drive',
- params: {
- md5: {
- validator: $.str,
- },
- },
-
res: {
type: 'boolean',
optional: false, nullable: false,
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ md5: { type: 'string' },
+ },
+ required: ['md5'],
+} 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 file = await DriveFiles.findOne({
md5: ps.md5,
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/drive/files/create.ts b/packages/backend/src/server/api/endpoints/drive/files/create.ts
index ac7863ec7..b6a2cf720 100644
--- a/packages/backend/src/server/api/endpoints/drive/files/create.ts
+++ b/packages/backend/src/server/api/endpoints/drive/files/create.ts
@@ -1,12 +1,10 @@
import ms from 'ms';
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { addFile } from '@/services/drive/add-file';
-import define from '../../../define';
-import { apiLogger } from '../../../logger';
-import { ApiError } from '../../../error';
-import { DriveFiles } from '@/models/index';
-import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/misc/hard-limits';
+import { addFile } from '@/services/drive/add-file.js';
+import define from '../../../define.js';
+import { apiLogger } from '../../../logger.js';
+import { ApiError } from '../../../error.js';
+import { DriveFiles } from '@/models/index.js';
+import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/misc/hard-limits.js';
export const meta = {
tags: ['drive'],
@@ -22,33 +20,6 @@ export const meta = {
kind: 'write:drive',
- params: {
- folderId: {
- validator: $.optional.nullable.type(ID),
- default: null,
- },
-
- name: {
- validator: $.optional.nullable.str,
- default: null,
- },
-
- comment: {
- validator: $.optional.nullable.str.max(DB_MAX_IMAGE_COMMENT_LENGTH),
- default: null,
- },
-
- isSensitive: {
- validator: $.optional.bool,
- default: false,
- },
-
- force: {
- validator: $.optional.bool,
- default: false,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -64,8 +35,21 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ folderId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
+ name: { type: 'string', nullable: true, default: null },
+ comment: { type: 'string', nullable: true, maxLength: DB_MAX_IMAGE_COMMENT_LENGTH, default: null },
+ isSensitive: { type: 'boolean', default: false },
+ force: { type: 'boolean', default: false },
+ },
+ required: [],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps, user, _, file, cleanup) => {
+// @ts-ignore
+export default define(meta, paramDef, async (ps, user, _, file, cleanup) => {
// Get 'name' parameter
let name = ps.name || file.originalname;
if (name !== undefined && name !== null) {
diff --git a/packages/backend/src/server/api/endpoints/drive/files/delete.ts b/packages/backend/src/server/api/endpoints/drive/files/delete.ts
index 308beb58a..5f565a63f 100644
--- a/packages/backend/src/server/api/endpoints/drive/files/delete.ts
+++ b/packages/backend/src/server/api/endpoints/drive/files/delete.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { deleteFile } from '@/services/drive/delete-file';
-import { publishDriveStream } from '@/services/stream';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { DriveFiles } from '@/models/index';
+import { deleteFile } from '@/services/drive/delete-file.js';
+import { publishDriveStream } from '@/services/stream.js';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
tags: ['drive'],
@@ -13,12 +11,6 @@ export const meta = {
kind: 'write:drive',
- params: {
- fileId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchFile: {
message: 'No such file.',
@@ -34,8 +26,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const file = await DriveFiles.findOne(ps.fileId);
if (file == null) {
diff --git a/packages/backend/src/server/api/endpoints/drive/files/find-by-hash.ts b/packages/backend/src/server/api/endpoints/drive/files/find-by-hash.ts
index dc74dcb7e..e45ec633d 100644
--- a/packages/backend/src/server/api/endpoints/drive/files/find-by-hash.ts
+++ b/packages/backend/src/server/api/endpoints/drive/files/find-by-hash.ts
@@ -1,6 +1,5 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { DriveFiles } from '@/models/index';
+import define from '../../../define.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
tags: ['drive'],
@@ -9,12 +8,6 @@ export const meta = {
kind: 'read:drive',
- params: {
- md5: {
- validator: $.str,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -26,8 +19,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ md5: { type: 'string' },
+ },
+ required: ['md5'],
+} 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 files = await DriveFiles.find({
md5: ps.md5,
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/drive/files/find.ts b/packages/backend/src/server/api/endpoints/drive/files/find.ts
index 2244df13c..974fc9fba 100644
--- a/packages/backend/src/server/api/endpoints/drive/files/find.ts
+++ b/packages/backend/src/server/api/endpoints/drive/files/find.ts
@@ -1,7 +1,5 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { DriveFiles } from '@/models/index';
+import define from '../../../define.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
requireCredential: true,
@@ -10,17 +8,6 @@ export const meta = {
kind: 'read:drive',
- params: {
- name: {
- validator: $.str,
- },
-
- folderId: {
- validator: $.optional.nullable.type(ID),
- default: null,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -32,8 +19,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ name: { type: 'string' },
+ folderId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
+ },
+ required: ['name'],
+} 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 files = await DriveFiles.find({
name: ps.name,
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/drive/files/show.ts b/packages/backend/src/server/api/endpoints/drive/files/show.ts
index 18b17c465..181365c7e 100644
--- a/packages/backend/src/server/api/endpoints/drive/files/show.ts
+++ b/packages/backend/src/server/api/endpoints/drive/files/show.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { DriveFile } from '@/models/entities/drive-file';
-import { DriveFiles } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
tags: ['drive'],
@@ -12,16 +10,6 @@ export const meta = {
kind: 'read:drive',
- params: {
- fileId: {
- validator: $.optional.type(ID),
- },
-
- url: {
- validator: $.optional.str,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -49,8 +37,17 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
let file: DriveFile | undefined;
if (ps.fileId) {
diff --git a/packages/backend/src/server/api/endpoints/drive/files/update.ts b/packages/backend/src/server/api/endpoints/drive/files/update.ts
index b7ca80e83..ab8e4aeeb 100644
--- a/packages/backend/src/server/api/endpoints/drive/files/update.ts
+++ b/packages/backend/src/server/api/endpoints/drive/files/update.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { publishDriveStream } from '@/services/stream';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { DriveFiles, DriveFolders } from '@/models/index';
-import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/misc/hard-limits';
+import { publishDriveStream } from '@/services/stream.js';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { DriveFiles, DriveFolders } from '@/models/index.js';
+import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/misc/hard-limits.js';
export const meta = {
tags: ['drive'],
@@ -13,33 +11,13 @@ export const meta = {
kind: 'write:drive',
- params: {
- fileId: {
- validator: $.type(ID),
- },
-
- folderId: {
- validator: $.optional.nullable.type(ID),
- default: undefined as any,
- },
-
- name: {
- validator: $.optional.str.pipe(DriveFiles.validateFileName),
- default: undefined as any,
- },
-
- isSensitive: {
- validator: $.optional.bool,
- default: undefined as any,
- },
-
- comment: {
- validator: $.optional.nullable.str.max(DB_MAX_IMAGE_COMMENT_LENGTH),
- default: undefined as any,
- },
- },
-
errors: {
+ invalidFileName: {
+ message: 'Invalid file name.',
+ code: 'INVALID_FILE_NAME',
+ id: '395e7156-f9f0-475e-af89-53c3c23080c2',
+ },
+
noSuchFile: {
message: 'No such file.',
code: 'NO_SUCH_FILE',
@@ -66,8 +44,20 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ fileId: { type: 'string', format: 'misskey:id' },
+ folderId: { type: 'string', format: 'misskey:id', nullable: true },
+ name: { type: 'string' },
+ isSensitive: { type: 'boolean' },
+ comment: { type: 'string', nullable: true, maxLength: 512 },
+ },
+ required: ['fileId'],
+} 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 file = await DriveFiles.findOne(ps.fileId);
if (file == null) {
@@ -79,6 +69,9 @@ export default define(meta, async (ps, user) => {
}
if (ps.name) file.name = ps.name;
+ if (!DriveFiles.validateFileName(file.name)) {
+ throw new ApiError(meta.errors.invalidFileName);
+ }
if (ps.comment !== undefined) file.comment = ps.comment;
diff --git a/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts b/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts
index 40da1a4fb..3bfecac80 100644
--- a/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts
+++ b/packages/backend/src/server/api/endpoints/drive/files/upload-from-url.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
import ms from 'ms';
-import { uploadFromUrl } from '@/services/drive/upload-from-url';
-import define from '../../../define';
-import { DriveFiles } from '@/models/index';
-import { publishMainStream } from '@/services/stream';
-import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/misc/hard-limits';
+import { uploadFromUrl } from '@/services/drive/upload-from-url.js';
+import define from '../../../define.js';
+import { DriveFiles } from '@/models/index.js';
+import { publishMainStream } from '@/services/stream.js';
+import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/misc/hard-limits.js';
export const meta = {
tags: ['drive'],
@@ -18,42 +16,23 @@ export const meta = {
requireCredential: true,
kind: 'write:drive',
+} as const;
- params: {
- url: {
- // TODO: Validate this url
- validator: $.str,
- },
-
- folderId: {
- validator: $.optional.nullable.type(ID),
- default: null,
- },
-
- isSensitive: {
- validator: $.optional.bool,
- default: false,
- },
-
- comment: {
- validator: $.optional.nullable.str.max(DB_MAX_IMAGE_COMMENT_LENGTH),
- default: null,
- },
-
- marker: {
- validator: $.optional.nullable.str,
- default: null,
- },
-
- force: {
- validator: $.optional.bool,
- default: false,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ url: { type: 'string' },
+ folderId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
+ isSensitive: { type: 'boolean', default: false },
+ comment: { type: 'string', nullable: true, maxLength: 512, default: null },
+ marker: { type: 'string', nullable: true, default: null },
+ force: { type: 'boolean', default: false },
},
+ required: ['url'],
} 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) => {
uploadFromUrl({ url: ps.url, user, folderId: ps.folderId, sensitive: ps.isSensitive, force: ps.force, comment: ps.comment }).then(file => {
DriveFiles.pack(file, { self: true }).then(packedFile => {
publishMainStream(user.id, 'urlUploadFinished', {
diff --git a/packages/backend/src/server/api/endpoints/drive/folders.ts b/packages/backend/src/server/api/endpoints/drive/folders.ts
index 8f8d1d2c0..d4d530ba9 100644
--- a/packages/backend/src/server/api/endpoints/drive/folders.ts
+++ b/packages/backend/src/server/api/endpoints/drive/folders.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { DriveFolders } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { DriveFolders } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['drive'],
@@ -11,26 +9,6 @@ export const meta = {
kind: 'read:drive',
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
-
- folderId: {
- validator: $.optional.nullable.type(ID),
- default: null,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -42,8 +20,19 @@ export const meta = {
},
} 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' },
+ folderId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
+ },
+ 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 = makePaginationQuery(DriveFolders.createQueryBuilder('folder'), ps.sinceId, ps.untilId)
.andWhere('folder.userId = :userId', { userId: user.id });
@@ -53,7 +42,7 @@ export default define(meta, async (ps, user) => {
query.andWhere('folder.parentId IS NULL');
}
- const folders = await query.take(ps.limit!).getMany();
+ const folders = await query.take(ps.limit).getMany();
return await Promise.all(folders.map(folder => DriveFolders.pack(folder)));
});
diff --git a/packages/backend/src/server/api/endpoints/drive/folders/create.ts b/packages/backend/src/server/api/endpoints/drive/folders/create.ts
index 38ed17e0e..4ae10f062 100644
--- a/packages/backend/src/server/api/endpoints/drive/folders/create.ts
+++ b/packages/backend/src/server/api/endpoints/drive/folders/create.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { publishDriveStream } from '@/services/stream';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { DriveFolders } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import { publishDriveStream } from '@/services/stream.js';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { DriveFolders } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
tags: ['drive'],
@@ -13,17 +11,6 @@ export const meta = {
kind: 'write:drive',
- params: {
- name: {
- validator: $.optional.str.pipe(DriveFolders.validateFolderName),
- default: 'Untitled',
- },
-
- parentId: {
- validator: $.optional.nullable.type(ID),
- },
- },
-
errors: {
noSuchFolder: {
message: 'No such folder.',
@@ -39,8 +26,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ name: { type: 'string', default: "Untitled", maxLength: 200 },
+ parentId: { type: 'string', format: 'misskey:id', nullable: true },
+ },
+ 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) => {
// If the parent folder is specified
let parent = null;
if (ps.parentId) {
diff --git a/packages/backend/src/server/api/endpoints/drive/folders/delete.ts b/packages/backend/src/server/api/endpoints/drive/folders/delete.ts
index 13716fcce..4994615cc 100644
--- a/packages/backend/src/server/api/endpoints/drive/folders/delete.ts
+++ b/packages/backend/src/server/api/endpoints/drive/folders/delete.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { publishDriveStream } from '@/services/stream';
-import { ApiError } from '../../../error';
-import { DriveFolders, DriveFiles } from '@/models/index';
+import define from '../../../define.js';
+import { publishDriveStream } from '@/services/stream.js';
+import { ApiError } from '../../../error.js';
+import { DriveFolders, DriveFiles } from '@/models/index.js';
export const meta = {
tags: ['drive'],
@@ -12,12 +10,6 @@ export const meta = {
kind: 'write:drive',
- params: {
- folderId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchFolder: {
message: 'No such folder.',
@@ -33,8 +25,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ folderId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['folderId'],
+} 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 folder
const folder = await DriveFolders.findOne({
id: ps.folderId,
diff --git a/packages/backend/src/server/api/endpoints/drive/folders/find.ts b/packages/backend/src/server/api/endpoints/drive/folders/find.ts
index 911f51d78..9bf0e3d61 100644
--- a/packages/backend/src/server/api/endpoints/drive/folders/find.ts
+++ b/packages/backend/src/server/api/endpoints/drive/folders/find.ts
@@ -1,7 +1,5 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { DriveFolders } from '@/models/index';
+import define from '../../../define.js';
+import { DriveFolders } from '@/models/index.js';
export const meta = {
tags: ['drive'],
@@ -10,17 +8,6 @@ export const meta = {
kind: 'read:drive',
- params: {
- name: {
- validator: $.str,
- },
-
- parentId: {
- validator: $.optional.nullable.type(ID),
- default: null,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -32,8 +19,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ name: { type: 'string' },
+ parentId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
+ },
+ required: ['name'],
+} 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 folders = await DriveFolders.find({
name: ps.name,
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/drive/folders/show.ts b/packages/backend/src/server/api/endpoints/drive/folders/show.ts
index 58a6dd3c0..f09816d57 100644
--- a/packages/backend/src/server/api/endpoints/drive/folders/show.ts
+++ b/packages/backend/src/server/api/endpoints/drive/folders/show.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { DriveFolders } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { DriveFolders } from '@/models/index.js';
export const meta = {
tags: ['drive'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'read:drive',
- params: {
- folderId: {
- validator: $.type(ID),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -32,8 +24,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ folderId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['folderId'],
+} 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 folder
const folder = await DriveFolders.findOne({
id: ps.folderId,
diff --git a/packages/backend/src/server/api/endpoints/drive/folders/update.ts b/packages/backend/src/server/api/endpoints/drive/folders/update.ts
index 5b0cccd1c..c020b243e 100644
--- a/packages/backend/src/server/api/endpoints/drive/folders/update.ts
+++ b/packages/backend/src/server/api/endpoints/drive/folders/update.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { publishDriveStream } from '@/services/stream';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { DriveFolders } from '@/models/index';
+import { publishDriveStream } from '@/services/stream.js';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { DriveFolders } from '@/models/index.js';
export const meta = {
tags: ['drive'],
@@ -12,20 +10,6 @@ export const meta = {
kind: 'write:drive',
- params: {
- folderId: {
- validator: $.type(ID),
- },
-
- name: {
- validator: $.optional.str.pipe(DriveFolders.validateFolderName),
- },
-
- parentId: {
- validator: $.optional.nullable.type(ID),
- },
- },
-
errors: {
noSuchFolder: {
message: 'No such folder.',
@@ -53,8 +37,18 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ folderId: { type: 'string', format: 'misskey:id' },
+ name: { type: 'string', maxLength: 200 },
+ parentId: { type: 'string', format: 'misskey:id', nullable: true },
+ },
+ required: ['folderId'],
+} 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) => {
// Fetch folder
const folder = await DriveFolders.findOne({
id: ps.folderId,
diff --git a/packages/backend/src/server/api/endpoints/drive/stream.ts b/packages/backend/src/server/api/endpoints/drive/stream.ts
index 9ba780494..99e8d024f 100644
--- a/packages/backend/src/server/api/endpoints/drive/stream.ts
+++ b/packages/backend/src/server/api/endpoints/drive/stream.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { DriveFiles } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { DriveFiles } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['drive'],
@@ -11,25 +9,6 @@ export const meta = {
kind: 'read:drive',
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
-
- type: {
- validator: $.optional.str.match(/^[a-zA-Z\/\-*]+$/),
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -41,8 +20,19 @@ export const meta = {
},
} 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', pattern: /^[a-zA-Z\/\-*]+$/.toString().slice(1, -1) },
+ },
+ 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 = makePaginationQuery(DriveFiles.createQueryBuilder('file'), ps.sinceId, ps.untilId)
.andWhere('file.userId = :userId', { userId: user.id });
@@ -54,7 +44,7 @@ export default define(meta, async (ps, user) => {
}
}
- const files = await query.take(ps.limit!).getMany();
+ const files = await query.take(ps.limit).getMany();
return await DriveFiles.packMany(files, { detail: false, self: true });
});
diff --git a/packages/backend/src/server/api/endpoints/email-address/available.ts b/packages/backend/src/server/api/endpoints/email-address/available.ts
index 19f9b7ccd..07064ce9f 100644
--- a/packages/backend/src/server/api/endpoints/email-address/available.ts
+++ b/packages/backend/src/server/api/endpoints/email-address/available.ts
@@ -1,18 +1,11 @@
-import $ from 'cafy';
-import define from '../../define';
-import { validateEmailForAccount } from '@/services/validate-email-for-account';
+import define from '../../define.js';
+import { validateEmailForAccount } from '@/services/validate-email-for-account.js';
export const meta = {
tags: ['users'],
requireCredential: false,
- params: {
- emailAddress: {
- validator: $.str,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -29,7 +22,15 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ emailAddress: { type: 'string' },
+ },
+ required: ['emailAddress'],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
return await validateEmailForAccount(ps.emailAddress);
});
diff --git a/packages/backend/src/server/api/endpoints/endpoint.ts b/packages/backend/src/server/api/endpoints/endpoint.ts
index 42fd46883..9db140183 100644
--- a/packages/backend/src/server/api/endpoints/endpoint.ts
+++ b/packages/backend/src/server/api/endpoints/endpoint.ts
@@ -1,21 +1,22 @@
-import $ from 'cafy';
-import define from '../define';
-import endpoints from '../endpoints';
+import define from '../define.js';
+import endpoints from '../endpoints.js';
export const meta = {
requireCredential: false,
tags: ['meta'],
+} as const;
- params: {
- endpoint: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ endpoint: { type: 'string' },
},
+ required: ['endpoint'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
const ep = endpoints.find(x => x.name === ps.endpoint);
if (ep == null) return null;
return {
diff --git a/packages/backend/src/server/api/endpoints/endpoints.ts b/packages/backend/src/server/api/endpoints/endpoints.ts
index ebb78de33..b20da96eb 100644
--- a/packages/backend/src/server/api/endpoints/endpoints.ts
+++ b/packages/backend/src/server/api/endpoints/endpoints.ts
@@ -1,14 +1,11 @@
-import define from '../define';
-import endpoints from '../endpoints';
+import define from '../define.js';
+import endpoints from '../endpoints.js';
export const meta = {
requireCredential: false,
tags: ['meta'],
- params: {
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -25,7 +22,13 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async () => {
+export default define(meta, paramDef, async () => {
return endpoints.map(x => x.name);
});
diff --git a/packages/backend/src/server/api/endpoints/export-custom-emojis.ts b/packages/backend/src/server/api/endpoints/export-custom-emojis.ts
index 24c9f56aa..bc8d2e2ac 100644
--- a/packages/backend/src/server/api/endpoints/export-custom-emojis.ts
+++ b/packages/backend/src/server/api/endpoints/export-custom-emojis.ts
@@ -1,6 +1,5 @@
-import $ from 'cafy';
-import define from '../define';
-import { createExportCustomEmojisJob } from '@/queue/index';
+import define from '../define.js';
+import { createExportCustomEmojisJob } from '@/queue/index.js';
import ms from 'ms';
export const meta = {
@@ -12,7 +11,13 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
createExportCustomEmojisJob(user);
});
diff --git a/packages/backend/src/server/api/endpoints/federation/followers.ts b/packages/backend/src/server/api/endpoints/federation/followers.ts
index c0a85f166..7b1197d1e 100644
--- a/packages/backend/src/server/api/endpoints/federation/followers.ts
+++ b/packages/backend/src/server/api/endpoints/federation/followers.ts
@@ -1,33 +1,12 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Followings } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { Followings } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['federation'],
requireCredential: false,
- params: {
- host: {
- validator: $.str,
- },
-
- 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,
@@ -39,13 +18,24 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ host: { type: 'string' },
+ sinceId: { type: 'string', format: 'misskey:id' },
+ untilId: { type: 'string', format: 'misskey:id' },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ },
+ required: ['host'],
+} 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(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId)
.andWhere(`following.followeeHost = :host`, { host: ps.host });
const followings = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Followings.packMany(followings, me, { populateFollowee: true });
diff --git a/packages/backend/src/server/api/endpoints/federation/following.ts b/packages/backend/src/server/api/endpoints/federation/following.ts
index 147f0aedb..ed1f142d8 100644
--- a/packages/backend/src/server/api/endpoints/federation/following.ts
+++ b/packages/backend/src/server/api/endpoints/federation/following.ts
@@ -1,33 +1,12 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Followings } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { Followings } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['federation'],
requireCredential: false,
- params: {
- host: {
- validator: $.str,
- },
-
- 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,
@@ -39,13 +18,24 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ host: { type: 'string' },
+ sinceId: { type: 'string', format: 'misskey:id' },
+ untilId: { type: 'string', format: 'misskey:id' },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ },
+ required: ['host'],
+} 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(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId)
.andWhere(`following.followerHost = :host`, { host: ps.host });
const followings = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Followings.packMany(followings, me, { populateFollowee: true });
diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts
index 11df7ed6b..e27297176 100644
--- a/packages/backend/src/server/api/endpoints/federation/instances.ts
+++ b/packages/backend/src/server/api/endpoints/federation/instances.ts
@@ -1,58 +1,13 @@
-import $ from 'cafy';
-import config from '@/config/index';
-import define from '../../define';
-import { Instances } from '@/models/index';
-import { fetchMeta } from '@/misc/fetch-meta';
+import config from '@/config/index.js';
+import define from '../../define.js';
+import { Instances } from '@/models/index.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
export const meta = {
tags: ['federation'],
requireCredential: false,
- params: {
- host: {
- validator: $.optional.nullable.str,
- },
-
- blocked: {
- validator: $.optional.nullable.bool,
- },
-
- notResponding: {
- validator: $.optional.nullable.bool,
- },
-
- suspended: {
- validator: $.optional.nullable.bool,
- },
-
- federating: {
- validator: $.optional.nullable.bool,
- },
-
- subscribing: {
- validator: $.optional.nullable.bool,
- },
-
- publishing: {
- validator: $.optional.nullable.bool,
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 30,
- },
-
- offset: {
- validator: $.optional.num.min(0),
- default: 0,
- },
-
- sort: {
- validator: $.optional.str,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -64,8 +19,25 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ host: { type: 'string', nullable: true },
+ blocked: { type: 'boolean', nullable: true },
+ notResponding: { type: 'boolean', nullable: true },
+ suspended: { type: 'boolean', nullable: true },
+ federating: { type: 'boolean', nullable: true },
+ subscribing: { type: 'boolean', nullable: true },
+ publishing: { type: 'boolean', nullable: true },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 30 },
+ offset: { type: 'integer', default: 0 },
+ sort: { type: 'string' },
+ },
+ 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 = Instances.createQueryBuilder('instance');
switch (ps.sort) {
@@ -83,10 +55,6 @@ export default define(meta, async (ps, me) => {
case '-caughtAt': query.orderBy('instance.caughtAt', 'ASC'); break;
case '+lastCommunicatedAt': query.orderBy('instance.lastCommunicatedAt', 'DESC'); break;
case '-lastCommunicatedAt': query.orderBy('instance.lastCommunicatedAt', 'ASC'); break;
- case '+driveUsage': query.orderBy('instance.driveUsage', 'DESC'); break;
- case '-driveUsage': query.orderBy('instance.driveUsage', 'ASC'); break;
- case '+driveFiles': query.orderBy('instance.driveFiles', 'DESC'); break;
- case '-driveFiles': query.orderBy('instance.driveFiles', 'ASC'); break;
default: query.orderBy('instance.id', 'DESC'); break;
}
@@ -144,7 +112,7 @@ export default define(meta, async (ps, me) => {
query.andWhere('instance.host like :host', { host: '%' + ps.host.toLowerCase() + '%' });
}
- const instances = await query.take(ps.limit!).skip(ps.offset).getMany();
+ const instances = await query.take(ps.limit).skip(ps.offset).getMany();
- return instances;
+ return await Instances.packMany(instances);
});
diff --git a/packages/backend/src/server/api/endpoints/federation/show-instance.ts b/packages/backend/src/server/api/endpoints/federation/show-instance.ts
index 6f13b28ca..5bfe43fc9 100644
--- a/packages/backend/src/server/api/endpoints/federation/show-instance.ts
+++ b/packages/backend/src/server/api/endpoints/federation/show-instance.ts
@@ -1,30 +1,34 @@
-import $ from 'cafy';
-import define from '../../define';
-import { Instances } from '@/models/index';
-import { toPuny } from '@/misc/convert-host';
+import define from '../../define.js';
+import { Instances } from '@/models/index.js';
+import { toPuny } from '@/misc/convert-host.js';
export const meta = {
tags: ['federation'],
requireCredential: false,
- params: {
- host: {
- validator: $.str,
- },
- },
-
res: {
- type: 'object',
- optional: true, nullable: false,
- ref: 'FederationInstance',
+ oneOf: [{
+ type: 'object',
+ ref: 'FederationInstance',
+ }, {
+ type: 'null',
+ }],
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ host: { type: 'string' },
+ },
+ required: ['host'],
+} 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 instance = await Instances
.findOne({ host: toPuny(ps.host) });
- return instance;
+ return instance ? await Instances.pack(instance) : null;
});
diff --git a/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts b/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts
index 092f805bc..409cc7695 100644
--- a/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts
+++ b/packages/backend/src/server/api/endpoints/federation/update-remote-user.ts
@@ -1,23 +1,23 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { getRemoteUser } from '../../common/getters';
-import { updatePerson } from '@/remote/activitypub/models/person';
+import define from '../../define.js';
+import { getRemoteUser } from '../../common/getters.js';
+import { updatePerson } from '@/remote/activitypub/models/person.js';
export const meta = {
tags: ['federation'],
requireCredential: true,
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
},
+ required: ['userId'],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
const user = await getRemoteUser(ps.userId);
await updatePerson(user.uri!);
});
diff --git a/packages/backend/src/server/api/endpoints/federation/users.ts b/packages/backend/src/server/api/endpoints/federation/users.ts
index 9a8f74993..65ad9f88d 100644
--- a/packages/backend/src/server/api/endpoints/federation/users.ts
+++ b/packages/backend/src/server/api/endpoints/federation/users.ts
@@ -1,33 +1,12 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Users } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { Users } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['federation'],
requireCredential: false,
- params: {
- host: {
- validator: $.str,
- },
-
- 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,
@@ -39,13 +18,24 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ host: { type: 'string' },
+ sinceId: { type: 'string', format: 'misskey:id' },
+ untilId: { type: 'string', format: 'misskey:id' },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ },
+ required: ['host'],
+} 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(Users.createQueryBuilder('user'), ps.sinceId, ps.untilId)
.andWhere(`user.host = :host`, { host: ps.host });
const users = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Users.packMany(users, me, { detail: true });
diff --git a/packages/backend/src/server/api/endpoints/following/create.ts b/packages/backend/src/server/api/endpoints/following/create.ts
index b840ab769..8758a64a3 100644
--- a/packages/backend/src/server/api/endpoints/following/create.ts
+++ b/packages/backend/src/server/api/endpoints/following/create.ts
@@ -1,12 +1,10 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
import ms from 'ms';
-import create from '@/services/following/create';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { getUser } from '../../common/getters';
-import { Followings, Users } from '@/models/index';
-import { IdentifiableError } from '@/misc/identifiable-error';
+import create from '@/services/following/create.js';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { getUser } from '../../common/getters.js';
+import { Followings, Users } from '@/models/index.js';
+import { IdentifiableError } from '@/misc/identifiable-error.js';
export const meta = {
tags: ['following', 'users'],
@@ -20,12 +18,6 @@ export const meta = {
kind: 'write:following',
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -65,8 +57,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const follower = user;
// 自分自身
diff --git a/packages/backend/src/server/api/endpoints/following/delete.ts b/packages/backend/src/server/api/endpoints/following/delete.ts
index 4cd0c4945..47efc59b8 100644
--- a/packages/backend/src/server/api/endpoints/following/delete.ts
+++ b/packages/backend/src/server/api/endpoints/following/delete.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
import ms from 'ms';
-import deleteFollowing from '@/services/following/delete';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { getUser } from '../../common/getters';
-import { Followings, Users } from '@/models/index';
+import deleteFollowing from '@/services/following/delete.js';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { getUser } from '../../common/getters.js';
+import { Followings, Users } from '@/models/index.js';
export const meta = {
tags: ['following', 'users'],
@@ -19,12 +17,6 @@ export const meta = {
kind: 'write:following',
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -52,8 +44,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const follower = user;
// Check if the followee is yourself
diff --git a/packages/backend/src/server/api/endpoints/following/invalidate.ts b/packages/backend/src/server/api/endpoints/following/invalidate.ts
index 92e887e00..24d8256ca 100644
--- a/packages/backend/src/server/api/endpoints/following/invalidate.ts
+++ b/packages/backend/src/server/api/endpoints/following/invalidate.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import * as ms from 'ms';
-import deleteFollowing from '@/services/following/delete';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { getUser } from '../../common/getters';
-import { Followings, Users } from '@/models/index';
+import ms from 'ms';
+import deleteFollowing from '@/services/following/delete.js';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { getUser } from '../../common/getters.js';
+import { Followings, Users } from '@/models/index.js';
export const meta = {
tags: ['following', 'users'],
@@ -19,12 +17,6 @@ export const meta = {
kind: 'write:following',
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -52,8 +44,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const followee = user;
// Check if the follower is yourself
diff --git a/packages/backend/src/server/api/endpoints/following/requests/accept.ts b/packages/backend/src/server/api/endpoints/following/requests/accept.ts
index 7e7c056f5..e5df55375 100644
--- a/packages/backend/src/server/api/endpoints/following/requests/accept.ts
+++ b/packages/backend/src/server/api/endpoints/following/requests/accept.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import acceptFollowRequest from '@/services/following/requests/accept';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getUser } from '../../../common/getters';
+import acceptFollowRequest from '@/services/following/requests/accept.js';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getUser } from '../../../common/getters.js';
export const meta = {
tags: ['following', 'account'],
@@ -12,12 +10,6 @@ export const meta = {
kind: 'write:following',
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -32,8 +24,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
// Fetch follower
const follower = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
diff --git a/packages/backend/src/server/api/endpoints/following/requests/cancel.ts b/packages/backend/src/server/api/endpoints/following/requests/cancel.ts
index c9abbf36d..80d37fb07 100644
--- a/packages/backend/src/server/api/endpoints/following/requests/cancel.ts
+++ b/packages/backend/src/server/api/endpoints/following/requests/cancel.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import cancelFollowRequest from '@/services/following/requests/cancel';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getUser } from '../../../common/getters';
-import { Users } from '@/models/index';
-import { IdentifiableError } from '@/misc/identifiable-error';
+import cancelFollowRequest from '@/services/following/requests/cancel.js';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getUser } from '../../../common/getters.js';
+import { Users } from '@/models/index.js';
+import { IdentifiableError } from '@/misc/identifiable-error.js';
export const meta = {
tags: ['following', 'account'],
@@ -14,12 +12,6 @@ export const meta = {
kind: 'write:following',
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -41,8 +33,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
// Fetch followee
const followee = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
diff --git a/packages/backend/src/server/api/endpoints/following/requests/list.ts b/packages/backend/src/server/api/endpoints/following/requests/list.ts
index ec0c76502..3b60b89b3 100644
--- a/packages/backend/src/server/api/endpoints/following/requests/list.ts
+++ b/packages/backend/src/server/api/endpoints/following/requests/list.ts
@@ -1,5 +1,5 @@
-import define from '../../../define';
-import { FollowRequests } from '@/models/index';
+import define from '../../../define.js';
+import { FollowRequests } from '@/models/index.js';
export const meta = {
tags: ['following', 'account'],
@@ -35,8 +35,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 reqs = await FollowRequests.find({
followeeId: user.id,
});
diff --git a/packages/backend/src/server/api/endpoints/following/requests/reject.ts b/packages/backend/src/server/api/endpoints/following/requests/reject.ts
index a5ce1e7c7..cebe60428 100644
--- a/packages/backend/src/server/api/endpoints/following/requests/reject.ts
+++ b/packages/backend/src/server/api/endpoints/following/requests/reject.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { rejectFollowRequest } from '@/services/following/reject';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getUser } from '../../../common/getters';
+import { rejectFollowRequest } from '@/services/following/reject.js';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getUser } from '../../../common/getters.js';
export const meta = {
tags: ['following', 'account'],
@@ -12,12 +10,6 @@ export const meta = {
kind: 'write:following',
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -27,8 +19,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
// Fetch follower
const follower = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
diff --git a/packages/backend/src/server/api/endpoints/gallery/featured.ts b/packages/backend/src/server/api/endpoints/gallery/featured.ts
index ff7c16889..e6acd3691 100644
--- a/packages/backend/src/server/api/endpoints/gallery/featured.ts
+++ b/packages/backend/src/server/api/endpoints/gallery/featured.ts
@@ -1,5 +1,5 @@
-import define from '../../define';
-import { GalleryPosts } from '@/models/index';
+import define from '../../define.js';
+import { GalleryPosts } from '@/models/index.js';
export const meta = {
tags: ['gallery'],
@@ -17,8 +17,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 = GalleryPosts.createQueryBuilder('post')
.andWhere('post.createdAt > :date', { date: new Date(Date.now() - (1000 * 60 * 60 * 24 * 3)) })
.andWhere('post.likedCount > 0')
diff --git a/packages/backend/src/server/api/endpoints/gallery/popular.ts b/packages/backend/src/server/api/endpoints/gallery/popular.ts
index 2c3368a19..c4c8982fc 100644
--- a/packages/backend/src/server/api/endpoints/gallery/popular.ts
+++ b/packages/backend/src/server/api/endpoints/gallery/popular.ts
@@ -1,5 +1,5 @@
-import define from '../../define';
-import { GalleryPosts } from '@/models/index';
+import define from '../../define.js';
+import { GalleryPosts } from '@/models/index.js';
export const meta = {
tags: ['gallery'],
@@ -17,8 +17,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 = GalleryPosts.createQueryBuilder('post')
.andWhere('post.likedCount > 0')
.orderBy('post.likedCount', 'DESC');
diff --git a/packages/backend/src/server/api/endpoints/gallery/posts.ts b/packages/backend/src/server/api/endpoints/gallery/posts.ts
index 9d2601c7e..428ba9cc7 100644
--- a/packages/backend/src/server/api/endpoints/gallery/posts.ts
+++ b/packages/backend/src/server/api/endpoints/gallery/posts.ts
@@ -1,27 +1,10 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { GalleryPosts } from '@/models/index';
+import define from '../../define.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { GalleryPosts } from '@/models/index.js';
export const meta = {
tags: ['gallery'],
- params: {
- 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,
@@ -33,12 +16,22 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const query = makePaginationQuery(GalleryPosts.createQueryBuilder('post'), ps.sinceId, ps.untilId)
.innerJoinAndSelect('post.user', 'user');
- const posts = await query.take(ps.limit!).getMany();
+ const posts = await query.take(ps.limit).getMany();
return await GalleryPosts.packMany(posts, me);
});
diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts
index e9d5df1ab..eb6c0f3eb 100644
--- a/packages/backend/src/server/api/endpoints/gallery/posts/create.ts
+++ b/packages/backend/src/server/api/endpoints/gallery/posts/create.ts
@@ -1,12 +1,10 @@
-import $ from 'cafy';
import ms from 'ms';
-import define from '../../../define';
-import { ID } from '../../../../../misc/cafy-id';
-import { DriveFiles, GalleryPosts } from '@/models/index';
-import { genId } from '../../../../../misc/gen-id';
-import { GalleryPost } from '@/models/entities/gallery-post';
-import { ApiError } from '../../../error';
-import { DriveFile } from '@/models/entities/drive-file';
+import define from '../../../define.js';
+import { DriveFiles, GalleryPosts } from '@/models/index.js';
+import { genId } from '../../../../../misc/gen-id.js';
+import { GalleryPost } from '@/models/entities/gallery-post.js';
+import { ApiError } from '../../../error.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
export const meta = {
tags: ['gallery'],
@@ -20,25 +18,6 @@ export const meta = {
max: 300,
},
- params: {
- title: {
- validator: $.str.min(1),
- },
-
- description: {
- validator: $.optional.nullable.str,
- },
-
- fileIds: {
- validator: $.arr($.type(ID)).unique().range(1, 32),
- },
-
- isSensitive: {
- validator: $.optional.bool,
- default: false,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -50,8 +29,21 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ title: { type: 'string', minLength: 1 },
+ description: { type: 'string', nullable: true },
+ fileIds: { type: 'array', uniqueItems: true, minItems: 1, maxItems: 32, items: {
+ type: 'string', format: 'misskey:id',
+ } },
+ isSensitive: { type: 'boolean', default: false },
+ },
+ required: ['title', 'fileIds'],
+} 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 files = (await Promise.all(ps.fileIds.map(fileId =>
DriveFiles.findOne({
id: fileId,
diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts b/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts
index 2a13b9ed5..f8bf785ee 100644
--- a/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts
+++ b/packages/backend/src/server/api/endpoints/gallery/posts/delete.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { GalleryPosts } from '@/models/index';
-import { ID } from '@/misc/cafy-id';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { GalleryPosts } from '@/models/index.js';
export const meta = {
tags: ['gallery'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'write:gallery',
- params: {
- postId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchPost: {
message: 'No such post.',
@@ -26,8 +18,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ postId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['postId'],
+} 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 post = await GalleryPosts.findOne({
id: ps.postId,
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/like.ts b/packages/backend/src/server/api/endpoints/gallery/posts/like.ts
index 0fb408fa5..d154bfc3c 100644
--- a/packages/backend/src/server/api/endpoints/gallery/posts/like.ts
+++ b/packages/backend/src/server/api/endpoints/gallery/posts/like.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { GalleryPosts, GalleryLikes } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { GalleryPosts, GalleryLikes } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
tags: ['gallery'],
@@ -12,12 +10,6 @@ export const meta = {
kind: 'write:gallery-likes',
- params: {
- postId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchPost: {
message: 'No such post.',
@@ -39,8 +31,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ postId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['postId'],
+} 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 post = await GalleryPosts.findOne(ps.postId);
if (post == null) {
throw new ApiError(meta.errors.noSuchPost);
diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/show.ts b/packages/backend/src/server/api/endpoints/gallery/posts/show.ts
index 4325d2ad3..5b4594070 100644
--- a/packages/backend/src/server/api/endpoints/gallery/posts/show.ts
+++ b/packages/backend/src/server/api/endpoints/gallery/posts/show.ts
@@ -1,20 +1,12 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { GalleryPosts } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { GalleryPosts } from '@/models/index.js';
export const meta = {
tags: ['gallery'],
requireCredential: false,
- params: {
- postId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchPost: {
message: 'No such post.',
@@ -30,8 +22,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ postId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['postId'],
+} 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 post = await GalleryPosts.findOne({
id: ps.postId,
});
diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts b/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts
index 9cca09bdd..b00008a86 100644
--- a/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts
+++ b/packages/backend/src/server/api/endpoints/gallery/posts/unlike.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { GalleryPosts, GalleryLikes } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { GalleryPosts, GalleryLikes } from '@/models/index.js';
export const meta = {
tags: ['gallery'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'write:gallery-likes',
- params: {
- postId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchPost: {
message: 'No such post.',
@@ -32,8 +24,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ postId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['postId'],
+} 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 post = await GalleryPosts.findOne(ps.postId);
if (post == null) {
throw new ApiError(meta.errors.noSuchPost);
diff --git a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts
index c35e1bbf5..123794d08 100644
--- a/packages/backend/src/server/api/endpoints/gallery/posts/update.ts
+++ b/packages/backend/src/server/api/endpoints/gallery/posts/update.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
import ms from 'ms';
-import define from '../../../define';
-import { ID } from '../../../../../misc/cafy-id';
-import { DriveFiles, GalleryPosts } from '@/models/index';
-import { GalleryPost } from '@/models/entities/gallery-post';
-import { ApiError } from '../../../error';
-import { DriveFile } from '@/models/entities/drive-file';
+import define from '../../../define.js';
+import { DriveFiles, GalleryPosts } from '@/models/index.js';
+import { GalleryPost } from '@/models/entities/gallery-post.js';
+import { ApiError } from '../../../error.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
export const meta = {
tags: ['gallery'],
@@ -19,29 +17,6 @@ export const meta = {
max: 300,
},
- params: {
- postId: {
- validator: $.type(ID),
- },
-
- title: {
- validator: $.str.min(1),
- },
-
- description: {
- validator: $.optional.nullable.str,
- },
-
- fileIds: {
- validator: $.arr($.type(ID)).unique().range(1, 32),
- },
-
- isSensitive: {
- validator: $.optional.bool,
- default: false,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -53,8 +28,22 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ postId: { type: 'string', format: 'misskey:id' },
+ title: { type: 'string', minLength: 1 },
+ description: { type: 'string', nullable: true },
+ fileIds: { type: 'array', uniqueItems: true, minItems: 1, maxItems: 32, items: {
+ type: 'string', format: 'misskey:id',
+ } },
+ isSensitive: { type: 'boolean', default: false },
+ },
+ required: ['postId', 'title', 'fileIds'],
+} 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 files = (await Promise.all(ps.fileIds.map(fileId =>
DriveFiles.findOne({
id: fileId,
diff --git a/packages/backend/src/server/api/endpoints/get-online-users-count.ts b/packages/backend/src/server/api/endpoints/get-online-users-count.ts
index 5b13d5a3b..80a2334cf 100644
--- a/packages/backend/src/server/api/endpoints/get-online-users-count.ts
+++ b/packages/backend/src/server/api/endpoints/get-online-users-count.ts
@@ -1,19 +1,22 @@
-import { USER_ONLINE_THRESHOLD } from '@/const';
-import { Users } from '@/models/index';
+import { USER_ONLINE_THRESHOLD } from '@/const.js';
+import { Users } from '@/models/index.js';
import { MoreThan } from 'typeorm';
-import define from '../define';
+import define from '../define.js';
export const meta = {
tags: ['meta'],
requireCredential: false,
+} as const;
- params: {
- },
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
} as const;
// eslint-disable-next-line import/no-default-export
-export default define(meta, async () => {
+export default define(meta, paramDef, async () => {
const count = await Users.count({
lastActiveDate: MoreThan(new Date(Date.now() - USER_ONLINE_THRESHOLD)),
});
diff --git a/packages/backend/src/server/api/endpoints/hashtags/list.ts b/packages/backend/src/server/api/endpoints/hashtags/list.ts
index 9fa9b3edc..50e36386c 100644
--- a/packages/backend/src/server/api/endpoints/hashtags/list.ts
+++ b/packages/backend/src/server/api/endpoints/hashtags/list.ts
@@ -1,51 +1,11 @@
-import $ from 'cafy';
-import define from '../../define';
-import { Hashtags } from '@/models/index';
+import define from '../../define.js';
+import { Hashtags } from '@/models/index.js';
export const meta = {
tags: ['hashtags'],
requireCredential: false,
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- attachedToUserOnly: {
- validator: $.optional.bool,
- default: false,
- },
-
- attachedToLocalUserOnly: {
- validator: $.optional.bool,
- default: false,
- },
-
- attachedToRemoteUserOnly: {
- validator: $.optional.bool,
- default: false,
- },
-
- sort: {
- validator: $.str.or([
- '+mentionedUsers',
- '-mentionedUsers',
- '+mentionedLocalUsers',
- '-mentionedLocalUsers',
- '+mentionedRemoteUsers',
- '-mentionedRemoteUsers',
- '+attachedUsers',
- '-attachedUsers',
- '+attachedLocalUsers',
- '-attachedLocalUsers',
- '+attachedRemoteUsers',
- '-attachedRemoteUsers',
- ]),
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -57,8 +17,20 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ attachedToUserOnly: { type: 'boolean', default: false },
+ attachedToLocalUserOnly: { type: 'boolean', default: false },
+ attachedToRemoteUserOnly: { type: 'boolean', default: false },
+ sort: { type: 'string', enum: ['+mentionedUsers', '-mentionedUsers', '+mentionedLocalUsers', '-mentionedLocalUsers', '+mentionedRemoteUsers', '-mentionedRemoteUsers', '+attachedUsers', '-attachedUsers', '+attachedLocalUsers', '-attachedLocalUsers', '+attachedRemoteUsers', '-attachedRemoteUsers'] },
+ },
+ required: ['sort'],
+} 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 = Hashtags.createQueryBuilder('tag');
if (ps.attachedToUserOnly) query.andWhere('tag.attachedUsersCount != 0');
@@ -90,7 +62,7 @@ export default define(meta, async (ps, me) => {
'tag.attachedRemoteUsersCount',
]);
- const tags = await query.take(ps.limit!).getMany();
+ const tags = await query.take(ps.limit).getMany();
return Hashtags.packMany(tags);
});
diff --git a/packages/backend/src/server/api/endpoints/hashtags/search.ts b/packages/backend/src/server/api/endpoints/hashtags/search.ts
index 0d646c64f..c28984477 100644
--- a/packages/backend/src/server/api/endpoints/hashtags/search.ts
+++ b/packages/backend/src/server/api/endpoints/hashtags/search.ts
@@ -1,28 +1,11 @@
-import $ from 'cafy';
-import define from '../../define';
-import { Hashtags } from '@/models/index';
+import define from '../../define.js';
+import { Hashtags } from '@/models/index.js';
export const meta = {
tags: ['hashtags'],
requireCredential: false,
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- query: {
- validator: $.str,
- },
-
- offset: {
- validator: $.optional.num.min(0),
- default: 0,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -33,13 +16,23 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ query: { type: 'string' },
+ offset: { type: 'integer', default: 0 },
+ },
+ required: ['query'],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
const hashtags = await Hashtags.createQueryBuilder('tag')
.where('tag.name like :q', { q: ps.query.toLowerCase() + '%' })
.orderBy('tag.count', 'DESC')
.groupBy('tag.id')
- .take(ps.limit!)
+ .take(ps.limit)
.skip(ps.offset)
.getMany();
diff --git a/packages/backend/src/server/api/endpoints/hashtags/show.ts b/packages/backend/src/server/api/endpoints/hashtags/show.ts
index 242cef99d..6e6afa4f1 100644
--- a/packages/backend/src/server/api/endpoints/hashtags/show.ts
+++ b/packages/backend/src/server/api/endpoints/hashtags/show.ts
@@ -1,20 +1,13 @@
-import $ from 'cafy';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Hashtags } from '@/models/index';
-import { normalizeForSearch } from '@/misc/normalize-for-search';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Hashtags } from '@/models/index.js';
+import { normalizeForSearch } from '@/misc/normalize-for-search.js';
export const meta = {
tags: ['hashtags'],
requireCredential: false,
- params: {
- tag: {
- validator: $.str,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -30,8 +23,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ tag: { type: 'string' },
+ },
+ required: ['tag'],
+} 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 hashtag = await Hashtags.findOne({ name: normalizeForSearch(ps.tag) });
if (hashtag == null) {
throw new ApiError(meta.errors.noSuchHashtag);
diff --git a/packages/backend/src/server/api/endpoints/hashtags/trend.ts b/packages/backend/src/server/api/endpoints/hashtags/trend.ts
index be964ad63..9cdbc8941 100644
--- a/packages/backend/src/server/api/endpoints/hashtags/trend.ts
+++ b/packages/backend/src/server/api/endpoints/hashtags/trend.ts
@@ -1,10 +1,10 @@
import { Brackets } from 'typeorm';
-import define from '../../define';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { Notes } from '@/models/index';
-import { Note } from '@/models/entities/note';
-import { safeForSql } from '@/misc/safe-for-sql';
-import { normalizeForSearch } from '@/misc/normalize-for-search';
+import define from '../../define.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { Notes } from '@/models/index.js';
+import { Note } from '@/models/entities/note.js';
+import { safeForSql } from '@/misc/safe-for-sql.js';
+import { normalizeForSearch } from '@/misc/normalize-for-search.js';
/*
トレンドに載るためには「『直近a分間のユニーク投稿数が今からa分前~今からb分前の間のユニーク投稿数のn倍以上』のハッシュタグの上位5位以内に入る」ことが必要
@@ -53,8 +53,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async () => {
+export default define(meta, paramDef, async () => {
const instance = await fetchMeta(true);
const hiddenTags = instance.hiddenTags.map(t => normalizeForSearch(t));
diff --git a/packages/backend/src/server/api/endpoints/hashtags/users.ts b/packages/backend/src/server/api/endpoints/hashtags/users.ts
index 2158dc434..a5df21a7e 100644
--- a/packages/backend/src/server/api/endpoints/hashtags/users.ts
+++ b/packages/backend/src/server/api/endpoints/hashtags/users.ts
@@ -1,52 +1,12 @@
-import $ from 'cafy';
-import define from '../../define';
-import { Users } from '@/models/index';
-import { normalizeForSearch } from '@/misc/normalize-for-search';
+import define from '../../define.js';
+import { Users } from '@/models/index.js';
+import { normalizeForSearch } from '@/misc/normalize-for-search.js';
export const meta = {
requireCredential: false,
tags: ['hashtags', 'users'],
- params: {
- tag: {
- validator: $.str,
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sort: {
- validator: $.str.or([
- '+follower',
- '-follower',
- '+createdAt',
- '-createdAt',
- '+updatedAt',
- '-updatedAt',
- ]),
- },
-
- state: {
- validator: $.optional.str.or([
- 'all',
- 'alive',
- ]),
- default: 'all',
- },
-
- origin: {
- validator: $.optional.str.or([
- 'combined',
- 'local',
- 'remote',
- ]),
- default: 'local',
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -58,8 +18,20 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ tag: { type: 'string' },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt'] },
+ state: { type: 'string', enum: ['all', 'alive'], default: "all" },
+ origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "local" },
+ },
+ required: ['tag', 'sort'],
+} 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 = Users.createQueryBuilder('user')
.where(':tag = ANY(user.tags)', { tag: normalizeForSearch(ps.tag) });
@@ -84,7 +56,7 @@ export default define(meta, async (ps, me) => {
case '-updatedAt': query.orderBy('user.updatedAt', 'ASC'); break;
}
- const users = await query.take(ps.limit!).getMany();
+ const users = await query.take(ps.limit).getMany();
return await Users.packMany(users, me, { detail: true });
});
diff --git a/packages/backend/src/server/api/endpoints/i.ts b/packages/backend/src/server/api/endpoints/i.ts
index d69c118cf..5b1ad2b09 100644
--- a/packages/backend/src/server/api/endpoints/i.ts
+++ b/packages/backend/src/server/api/endpoints/i.ts
@@ -1,13 +1,11 @@
-import define from '../define';
-import { Users } from '@/models/index';
+import define from '../define.js';
+import { Users } from '@/models/index.js';
export const meta = {
tags: ['account'],
requireCredential: true,
- params: {},
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -15,8 +13,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
// 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 = token == null;
// ここで渡ってきている user はキャッシュされていて古い可能性もあるので id だけ渡す
diff --git a/packages/backend/src/server/api/endpoints/i/2fa/done.ts b/packages/backend/src/server/api/endpoints/i/2fa/done.ts
index 485390869..70478430d 100644
--- a/packages/backend/src/server/api/endpoints/i/2fa/done.ts
+++ b/packages/backend/src/server/api/endpoints/i/2fa/done.ts
@@ -1,22 +1,23 @@
-import $ from 'cafy';
import * as speakeasy from 'speakeasy';
-import define from '../../../define';
-import { UserProfiles } from '@/models/index';
+import define from '../../../define.js';
+import { UserProfiles } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- token: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ token: { type: 'string' },
},
+ required: ['token'],
} 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 token = ps.token.replace(/\s/g, '');
const profile = await UserProfiles.findOneOrFail(user.id);
diff --git a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts
index 26e9a6088..f33237c8b 100644
--- a/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts
+++ b/packages/backend/src/server/api/endpoints/i/2fa/key-done.ts
@@ -1,48 +1,40 @@
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import { promisify } from 'util';
+import bcrypt from 'bcryptjs';
+import { promisify } from 'node:util';
import * as cbor from 'cbor';
-import define from '../../../define';
+import define from '../../../define.js';
import {
UserProfiles,
UserSecurityKeys,
AttestationChallenges,
Users,
-} from '@/models/index';
-import config from '@/config/index';
-import { procedures, hash } from '../../../2fa';
-import { publishMainStream } from '@/services/stream';
+} from '@/models/index.js';
+import config from '@/config/index.js';
+import { procedures, hash } from '../../../2fa.js';
+import { publishMainStream } from '@/services/stream.js';
const cborDecodeFirst = promisify(cbor.decodeFirst) as any;
+const rpIdHashReal = hash(Buffer.from(config.hostname, 'utf-8'));
export const meta = {
requireCredential: true,
secure: true,
-
- params: {
- clientDataJSON: {
- validator: $.str,
- },
- attestationObject: {
- validator: $.str,
- },
- password: {
- validator: $.str,
- },
- challengeId: {
- validator: $.str,
- },
- name: {
- validator: $.str,
- },
- },
} as const;
-const rpIdHashReal = hash(Buffer.from(config.hostname, 'utf-8'));
+export const paramDef = {
+ type: 'object',
+ properties: {
+ clientDataJSON: { type: 'string' },
+ attestationObject: { type: 'string' },
+ password: { type: 'string' },
+ challengeId: { type: 'string' },
+ name: { type: 'string' },
+ },
+ required: ['clientDataJSON', 'attestationObject', 'password', 'challengeId', 'name'],
+} 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 profile = await UserProfiles.findOneOrFail(user.id);
// Compare password
diff --git a/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts b/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts
index 854848a43..4bfa24f97 100644
--- a/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts
+++ b/packages/backend/src/server/api/endpoints/i/2fa/password-less.ts
@@ -1,21 +1,22 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { UserProfiles } from '@/models/index';
+import define from '../../../define.js';
+import { UserProfiles } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- value: {
- validator: $.boolean,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ value: { type: 'boolean' },
},
+ required: ['value'],
} 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) => {
await UserProfiles.update(user.id, {
usePasswordLessLogin: ps.value,
});
diff --git a/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts b/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts
index 057e54c69..0c4c99271 100644
--- a/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts
+++ b/packages/backend/src/server/api/endpoints/i/2fa/register-key.ts
@@ -1,11 +1,10 @@
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import define from '../../../define';
-import { UserProfiles, AttestationChallenges } from '@/models/index';
-import { promisify } from 'util';
-import * as crypto from 'crypto';
-import { genId } from '@/misc/gen-id';
-import { hash } from '../../../2fa';
+import bcrypt from 'bcryptjs';
+import define from '../../../define.js';
+import { UserProfiles, AttestationChallenges } from '@/models/index.js';
+import { promisify } from 'node:util';
+import * as crypto from 'node:crypto';
+import { genId } from '@/misc/gen-id.js';
+import { hash } from '../../../2fa.js';
const randomBytes = promisify(crypto.randomBytes);
@@ -13,16 +12,18 @@ export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- password: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ password: { type: 'string' },
},
+ required: ['password'],
} 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 profile = await UserProfiles.findOneOrFail(user.id);
// Compare password
diff --git a/packages/backend/src/server/api/endpoints/i/2fa/register.ts b/packages/backend/src/server/api/endpoints/i/2fa/register.ts
index c5cfb9dfa..7951e393b 100644
--- a/packages/backend/src/server/api/endpoints/i/2fa/register.ts
+++ b/packages/backend/src/server/api/endpoints/i/2fa/register.ts
@@ -1,25 +1,26 @@
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
+import bcrypt from 'bcryptjs';
import * as speakeasy from 'speakeasy';
import * as QRCode from 'qrcode';
-import config from '@/config/index';
-import define from '../../../define';
-import { UserProfiles } from '@/models/index';
+import config from '@/config/index.js';
+import define from '../../../define.js';
+import { UserProfiles } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- password: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ password: { type: 'string' },
},
+ required: ['password'],
} 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 profile = await UserProfiles.findOneOrFail(user.id);
// Compare password
diff --git a/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts b/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts
index 03e1d0434..2b69b1f8c 100644
--- a/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts
+++ b/packages/backend/src/server/api/endpoints/i/2fa/remove-key.ts
@@ -1,26 +1,25 @@
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import define from '../../../define';
-import { UserProfiles, UserSecurityKeys, Users } from '@/models/index';
-import { publishMainStream } from '@/services/stream';
+import bcrypt from 'bcryptjs';
+import define from '../../../define.js';
+import { UserProfiles, UserSecurityKeys, Users } from '@/models/index.js';
+import { publishMainStream } from '@/services/stream.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- password: {
- validator: $.str,
- },
- credentialId: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ password: { type: 'string' },
+ credentialId: { type: 'string' },
},
+ required: ['password', 'credentialId'],
} 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 profile = await UserProfiles.findOneOrFail(user.id);
// Compare password
diff --git a/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts b/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts
index a19ad6810..c5633f68b 100644
--- a/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts
+++ b/packages/backend/src/server/api/endpoints/i/2fa/unregister.ts
@@ -1,22 +1,23 @@
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import define from '../../../define';
-import { UserProfiles } from '@/models/index';
+import bcrypt from 'bcryptjs';
+import define from '../../../define.js';
+import { UserProfiles } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- password: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ password: { type: 'string' },
},
+ required: ['password'],
} 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 profile = await UserProfiles.findOneOrFail(user.id);
// Compare password
diff --git a/packages/backend/src/server/api/endpoints/i/apps.ts b/packages/backend/src/server/api/endpoints/i/apps.ts
index 63999b098..eca955884 100644
--- a/packages/backend/src/server/api/endpoints/i/apps.ts
+++ b/packages/backend/src/server/api/endpoints/i/apps.ts
@@ -1,26 +1,22 @@
-import $ from 'cafy';
-import define from '../../define';
-import { AccessTokens } from '@/models/index';
+import define from '../../define.js';
+import { AccessTokens } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- sort: {
- validator: $.optional.str.or([
- '+createdAt',
- '-createdAt',
- '+lastUsedAt',
- '-lastUsedAt',
- ]),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ sort: { type: 'string', enum: ['+createdAt', '-createdAt', '+lastUsedAt', '-lastUsedAt'] },
},
+ 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 = AccessTokens.createQueryBuilder('token')
.where('token.userId = :userId', { userId: user.id });
diff --git a/packages/backend/src/server/api/endpoints/i/authorized-apps.ts b/packages/backend/src/server/api/endpoints/i/authorized-apps.ts
index 52122b851..3301808e7 100644
--- a/packages/backend/src/server/api/endpoints/i/authorized-apps.ts
+++ b/packages/backend/src/server/api/endpoints/i/authorized-apps.ts
@@ -1,38 +1,30 @@
-import $ from 'cafy';
-import define from '../../define';
-import { AccessTokens, Apps } from '@/models/index';
+import define from '../../define.js';
+import { AccessTokens, Apps } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- offset: {
- validator: $.optional.num.min(0),
- default: 0,
- },
-
- sort: {
- validator: $.optional.str.or('desc|asc'),
- default: 'desc',
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ offset: { type: 'integer', default: 0 },
+ sort: { type: 'string', enum: ['desc', 'asc'], default: "desc" },
},
+ 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) => {
// Get tokens
const tokens = await AccessTokens.find({
where: {
userId: user.id,
},
- take: ps.limit!,
+ take: ps.limit,
skip: ps.offset,
order: {
id: ps.sort == 'asc' ? 1 : -1,
diff --git a/packages/backend/src/server/api/endpoints/i/change-password.ts b/packages/backend/src/server/api/endpoints/i/change-password.ts
index 7b6c13773..16509d2dc 100644
--- a/packages/backend/src/server/api/endpoints/i/change-password.ts
+++ b/packages/backend/src/server/api/endpoints/i/change-password.ts
@@ -1,26 +1,24 @@
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import define from '../../define';
-import { UserProfiles } from '@/models/index';
+import bcrypt from 'bcryptjs';
+import define from '../../define.js';
+import { UserProfiles } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- currentPassword: {
- validator: $.str,
- },
-
- newPassword: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ currentPassword: { type: 'string' },
+ newPassword: { type: 'string', minLength: 1 },
},
+ required: ['currentPassword', 'newPassword'],
} 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 profile = await UserProfiles.findOneOrFail(user.id);
// Compare password
diff --git a/packages/backend/src/server/api/endpoints/i/delete-account.ts b/packages/backend/src/server/api/endpoints/i/delete-account.ts
index e1eee949f..8cb6b6a63 100644
--- a/packages/backend/src/server/api/endpoints/i/delete-account.ts
+++ b/packages/backend/src/server/api/endpoints/i/delete-account.ts
@@ -1,25 +1,26 @@
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import define from '../../define';
-import { UserProfiles, Users } from '@/models/index';
-import { doPostSuspend } from '@/services/suspend-user';
-import { publishUserEvent } from '@/services/stream';
-import { createDeleteAccountJob } from '@/queue';
+import bcrypt from 'bcryptjs';
+import define from '../../define.js';
+import { UserProfiles, Users } from '@/models/index.js';
+import { doPostSuspend } from '@/services/suspend-user.js';
+import { publishUserEvent } from '@/services/stream.js';
+import { createDeleteAccountJob } from '@/queue/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- password: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ password: { type: 'string' },
},
+ required: ['password'],
} 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 profile = await UserProfiles.findOneOrFail(user.id);
const userDetailed = await Users.findOneOrFail(user.id);
if (userDetailed.isDeleted) {
diff --git a/packages/backend/src/server/api/endpoints/i/export-blocking.ts b/packages/backend/src/server/api/endpoints/i/export-blocking.ts
index 44d8a1cb3..aed4c2e0a 100644
--- a/packages/backend/src/server/api/endpoints/i/export-blocking.ts
+++ b/packages/backend/src/server/api/endpoints/i/export-blocking.ts
@@ -1,5 +1,5 @@
-import define from '../../define';
-import { createExportBlockingJob } from '@/queue/index';
+import define from '../../define.js';
+import { createExportBlockingJob } from '@/queue/index.js';
import ms from 'ms';
export const meta = {
@@ -11,7 +11,13 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
createExportBlockingJob(user);
});
diff --git a/packages/backend/src/server/api/endpoints/i/export-following.ts b/packages/backend/src/server/api/endpoints/i/export-following.ts
index 5d1617d57..058d77b3c 100644
--- a/packages/backend/src/server/api/endpoints/i/export-following.ts
+++ b/packages/backend/src/server/api/endpoints/i/export-following.ts
@@ -1,6 +1,5 @@
-import $ from 'cafy';
-import define from '../../define';
-import { createExportFollowingJob } from '@/queue/index';
+import define from '../../define.js';
+import { createExportFollowingJob } from '@/queue/index.js';
import ms from 'ms';
export const meta = {
@@ -10,19 +9,18 @@ export const meta = {
duration: ms('1hour'),
max: 1,
},
- params: {
- excludeMuting: {
- validator: $.optional.bool,
- default: false,
- },
- excludeInactive: {
- validator: $.optional.bool,
- default: false,
- },
+} as const;
+
+export const paramDef = {
+ type: 'object',
+ properties: {
+ excludeMuting: { type: 'boolean', default: false },
+ excludeInactive: { type: 'boolean', default: false },
},
+ 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) => {
createExportFollowingJob(user, ps.excludeMuting, ps.excludeInactive);
});
diff --git a/packages/backend/src/server/api/endpoints/i/export-mute.ts b/packages/backend/src/server/api/endpoints/i/export-mute.ts
index 27ce8f0b2..c0216fac0 100644
--- a/packages/backend/src/server/api/endpoints/i/export-mute.ts
+++ b/packages/backend/src/server/api/endpoints/i/export-mute.ts
@@ -1,5 +1,5 @@
-import define from '../../define';
-import { createExportMuteJob } from '@/queue/index';
+import define from '../../define.js';
+import { createExportMuteJob } from '@/queue/index.js';
import ms from 'ms';
export const meta = {
@@ -11,7 +11,13 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
createExportMuteJob(user);
});
diff --git a/packages/backend/src/server/api/endpoints/i/export-notes.ts b/packages/backend/src/server/api/endpoints/i/export-notes.ts
index 25b1849e8..4b85a4555 100644
--- a/packages/backend/src/server/api/endpoints/i/export-notes.ts
+++ b/packages/backend/src/server/api/endpoints/i/export-notes.ts
@@ -1,5 +1,5 @@
-import define from '../../define';
-import { createExportNotesJob } from '@/queue/index';
+import define from '../../define.js';
+import { createExportNotesJob } from '@/queue/index.js';
import ms from 'ms';
export const meta = {
@@ -11,7 +11,13 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
createExportNotesJob(user);
});
diff --git a/packages/backend/src/server/api/endpoints/i/export-user-lists.ts b/packages/backend/src/server/api/endpoints/i/export-user-lists.ts
index d28b699c5..fa5c1f5e5 100644
--- a/packages/backend/src/server/api/endpoints/i/export-user-lists.ts
+++ b/packages/backend/src/server/api/endpoints/i/export-user-lists.ts
@@ -1,5 +1,5 @@
-import define from '../../define';
-import { createExportUserListsJob } from '@/queue/index';
+import define from '../../define.js';
+import { createExportUserListsJob } from '@/queue/index.js';
import ms from 'ms';
export const meta = {
@@ -11,7 +11,13 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
createExportUserListsJob(user);
});
diff --git a/packages/backend/src/server/api/endpoints/i/favorites.ts b/packages/backend/src/server/api/endpoints/i/favorites.ts
index 92c767876..3c420e4d0 100644
--- a/packages/backend/src/server/api/endpoints/i/favorites.ts
+++ b/packages/backend/src/server/api/endpoints/i/favorites.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { NoteFavorites } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { NoteFavorites } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['account', 'notes', 'favorites'],
@@ -11,21 +9,6 @@ export const meta = {
kind: 'read:favorites',
- params: {
- 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,
@@ -37,14 +20,24 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(NoteFavorites.createQueryBuilder('favorite'), ps.sinceId, ps.untilId)
.andWhere(`favorite.userId = :meId`, { meId: user.id })
.leftJoinAndSelect('favorite.note', 'note');
const favorites = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await NoteFavorites.packMany(favorites, user);
diff --git a/packages/backend/src/server/api/endpoints/i/gallery/likes.ts b/packages/backend/src/server/api/endpoints/i/gallery/likes.ts
index f1c576359..a38383f30 100644
--- a/packages/backend/src/server/api/endpoints/i/gallery/likes.ts
+++ b/packages/backend/src/server/api/endpoints/i/gallery/likes.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { GalleryLikes } from '@/models/index';
-import { makePaginationQuery } from '../../../common/make-pagination-query';
+import define from '../../../define.js';
+import { GalleryLikes } from '@/models/index.js';
+import { makePaginationQuery } from '../../../common/make-pagination-query.js';
export const meta = {
tags: ['account', 'gallery'],
@@ -11,47 +9,46 @@ export const meta = {
kind: 'read:gallery-likes',
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
- },
-
res: {
- type: 'object',
+ type: 'array',
optional: false, nullable: false,
- properties: {
- id: {
- type: 'string',
- optional: false, nullable: false,
- format: 'id',
+ items: {
+ type: 'object',
+ optional: false, nullable: false,
+ properties: {
+ id: {
+ type: 'string',
+ optional: false, nullable: false,
+ format: 'id',
+ },
+ post: {
+ type: 'object',
+ optional: false, nullable: false,
+ ref: 'GalleryPost',
+ },
},
- page: {
- type: 'object',
- optional: false, nullable: false,
- ref: 'GalleryPost',
- },
- },
+ }
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(GalleryLikes.createQueryBuilder('like'), ps.sinceId, ps.untilId)
.andWhere(`like.userId = :meId`, { meId: user.id })
.leftJoinAndSelect('like.post', 'post');
const likes = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await GalleryLikes.packMany(likes, user);
diff --git a/packages/backend/src/server/api/endpoints/i/gallery/posts.ts b/packages/backend/src/server/api/endpoints/i/gallery/posts.ts
index d46d42f63..b4edb5f73 100644
--- a/packages/backend/src/server/api/endpoints/i/gallery/posts.ts
+++ b/packages/backend/src/server/api/endpoints/i/gallery/posts.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { GalleryPosts } from '@/models/index';
-import { makePaginationQuery } from '../../../common/make-pagination-query';
+import define from '../../../define.js';
+import { GalleryPosts } from '@/models/index.js';
+import { makePaginationQuery } from '../../../common/make-pagination-query.js';
export const meta = {
tags: ['account', 'gallery'],
@@ -11,21 +9,6 @@ export const meta = {
kind: 'read:gallery',
- params: {
- 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,
@@ -37,13 +20,23 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(GalleryPosts.createQueryBuilder('post'), ps.sinceId, ps.untilId)
.andWhere(`post.userId = :meId`, { meId: user.id });
const posts = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await GalleryPosts.packMany(posts, user);
diff --git a/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts b/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts
index 4e1a4d3db..bc3e0aff4 100644
--- a/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts
+++ b/packages/backend/src/server/api/endpoints/i/get-word-muted-notes-count.ts
@@ -1,5 +1,5 @@
-import define from '../../define';
-import { MutedNotes } from '@/models/index';
+import define from '../../define.js';
+import { MutedNotes } from '@/models/index.js';
export const meta = {
tags: ['account'],
@@ -8,9 +8,6 @@ export const meta = {
kind: 'read:account',
- params: {
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -23,8 +20,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
return {
count: await MutedNotes.count({
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/i/import-blocking.ts b/packages/backend/src/server/api/endpoints/i/import-blocking.ts
index acc579742..c70704f9a 100644
--- a/packages/backend/src/server/api/endpoints/i/import-blocking.ts
+++ b/packages/backend/src/server/api/endpoints/i/import-blocking.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { createImportBlockingJob } from '@/queue/index';
+import define from '../../define.js';
+import { createImportBlockingJob } from '@/queue/index.js';
import ms from 'ms';
-import { ApiError } from '../../error';
-import { DriveFiles } from '@/models/index';
+import { ApiError } from '../../error.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
secure: true,
@@ -15,12 +13,6 @@ export const meta = {
max: 1,
},
- params: {
- fileId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchFile: {
message: 'No such file.',
@@ -48,8 +40,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const file = await DriveFiles.findOne(ps.fileId);
if (file == null) throw new ApiError(meta.errors.noSuchFile);
diff --git a/packages/backend/src/server/api/endpoints/i/import-following.ts b/packages/backend/src/server/api/endpoints/i/import-following.ts
index 35006746f..7e9175cbf 100644
--- a/packages/backend/src/server/api/endpoints/i/import-following.ts
+++ b/packages/backend/src/server/api/endpoints/i/import-following.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { createImportFollowingJob } from '@/queue/index';
+import define from '../../define.js';
+import { createImportFollowingJob } from '@/queue/index.js';
import ms from 'ms';
-import { ApiError } from '../../error';
-import { DriveFiles } from '@/models/index';
+import { ApiError } from '../../error.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
secure: true,
@@ -14,12 +12,6 @@ export const meta = {
max: 1,
},
- params: {
- fileId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchFile: {
message: 'No such file.',
@@ -47,8 +39,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const file = await DriveFiles.findOne(ps.fileId);
if (file == null) throw new ApiError(meta.errors.noSuchFile);
diff --git a/packages/backend/src/server/api/endpoints/i/import-muting.ts b/packages/backend/src/server/api/endpoints/i/import-muting.ts
index 7bbb2e008..abbf07212 100644
--- a/packages/backend/src/server/api/endpoints/i/import-muting.ts
+++ b/packages/backend/src/server/api/endpoints/i/import-muting.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { createImportMutingJob } from '@/queue/index';
+import define from '../../define.js';
+import { createImportMutingJob } from '@/queue/index.js';
import ms from 'ms';
-import { ApiError } from '../../error';
-import { DriveFiles } from '@/models/index';
+import { ApiError } from '../../error.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
secure: true,
@@ -15,12 +13,6 @@ export const meta = {
max: 1,
},
- params: {
- fileId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchFile: {
message: 'No such file.',
@@ -48,8 +40,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const file = await DriveFiles.findOne(ps.fileId);
if (file == null) throw new ApiError(meta.errors.noSuchFile);
diff --git a/packages/backend/src/server/api/endpoints/i/import-user-lists.ts b/packages/backend/src/server/api/endpoints/i/import-user-lists.ts
index 759d41b6c..be162817f 100644
--- a/packages/backend/src/server/api/endpoints/i/import-user-lists.ts
+++ b/packages/backend/src/server/api/endpoints/i/import-user-lists.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { createImportUserListsJob } from '@/queue/index';
+import define from '../../define.js';
+import { createImportUserListsJob } from '@/queue/index.js';
import ms from 'ms';
-import { ApiError } from '../../error';
-import { DriveFiles } from '@/models/index';
+import { ApiError } from '../../error.js';
+import { DriveFiles } from '@/models/index.js';
export const meta = {
secure: true,
@@ -14,12 +12,6 @@ export const meta = {
max: 1,
},
- params: {
- fileId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchFile: {
message: 'No such file.',
@@ -47,8 +39,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const file = await DriveFiles.findOne(ps.fileId);
if (file == null) throw new ApiError(meta.errors.noSuchFile);
diff --git a/packages/backend/src/server/api/endpoints/i/notifications.ts b/packages/backend/src/server/api/endpoints/i/notifications.ts
index 59efd32bb..7d9bd44d1 100644
--- a/packages/backend/src/server/api/endpoints/i/notifications.ts
+++ b/packages/backend/src/server/api/endpoints/i/notifications.ts
@@ -1,12 +1,10 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { readNotification } from '../../common/read-notification';
-import define from '../../define';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { generateMutedInstanceNotificationQuery } from '../../common/generate-muted-instance-query';
-import { Notifications, Followings, Mutings, Users } from '@/models/index';
-import { notificationTypes } from '@/types';
-import read from '@/services/note/read';
+import { readNotification } from '../../common/read-notification.js';
+import define from '../../define.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { generateMutedInstanceNotificationQuery } from '../../common/generate-muted-instance-query.js';
+import { Notifications, Followings, Mutings, Users } from '@/models/index.js';
+import { notificationTypes } from '@/types.js';
+import read from '@/services/note/read.js';
import { Brackets } from 'typeorm';
export const meta = {
@@ -16,44 +14,6 @@ export const meta = {
kind: 'read:notifications',
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
-
- following: {
- validator: $.optional.bool,
- default: false,
- },
-
- unreadOnly: {
- validator: $.optional.bool,
- default: false,
- },
-
- markAsRead: {
- validator: $.optional.bool,
- default: true,
- },
-
- includeTypes: {
- validator: $.optional.arr($.str.or(notificationTypes as unknown as string[])),
- },
-
- excludeTypes: {
- validator: $.optional.arr($.str.or(notificationTypes as unknown as string[])),
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -65,8 +25,27 @@ export const meta = {
},
} 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' },
+ following: { type: 'boolean', default: false },
+ unreadOnly: { type: 'boolean', default: false },
+ markAsRead: { type: 'boolean', default: true },
+ includeTypes: { type: 'array', items: {
+ type: 'string', enum: notificationTypes,
+ } },
+ excludeTypes: { type: 'array', items: {
+ type: 'string', enum: notificationTypes,
+ } },
+ },
+ 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) => {
// includeTypes が空の場合はクエリしない
if (ps.includeTypes && ps.includeTypes.length === 0) {
return [];
@@ -92,10 +71,16 @@ export default define(meta, async (ps, user) => {
.leftJoinAndSelect('notification.notifier', 'notifier')
.leftJoinAndSelect('notification.note', 'note')
.leftJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
query.andWhere(new Brackets(qb => { qb
.where(`notification.notifierId NOT IN (${ mutingQuery.getQuery() })`)
@@ -125,7 +110,7 @@ export default define(meta, async (ps, user) => {
query.andWhere(`notification.isRead = false`);
}
- const notifications = await query.take(ps.limit!).getMany();
+ const notifications = await query.take(ps.limit).getMany();
// Mark all as read
if (notifications.length > 0 && ps.markAsRead) {
diff --git a/packages/backend/src/server/api/endpoints/i/page-likes.ts b/packages/backend/src/server/api/endpoints/i/page-likes.ts
index 59239c744..71e326e2f 100644
--- a/packages/backend/src/server/api/endpoints/i/page-likes.ts
+++ b/packages/backend/src/server/api/endpoints/i/page-likes.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { PageLikes } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { PageLikes } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['account', 'pages'],
@@ -11,48 +9,46 @@ export const meta = {
kind: 'read:page-likes',
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
- },
-
res: {
- type: 'object',
+ type: 'array',
optional: false, nullable: false,
- properties: {
- id: {
- type: 'string',
- optional: false, nullable: false,
- format: 'id',
+ items: {
+ type: 'object',
+ properties: {
+ id: {
+ type: 'string',
+ optional: false, nullable: false,
+ format: 'id',
+ },
+ page: {
+ type: 'object',
+ optional: false, nullable: false,
+ ref: 'Page',
+ },
},
- page: {
- type: 'object',
- optional: false, nullable: false,
- ref: 'Page',
- },
- },
+ }
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(PageLikes.createQueryBuilder('like'), ps.sinceId, ps.untilId)
.andWhere(`like.userId = :meId`, { meId: user.id })
.leftJoinAndSelect('like.page', 'page');
const likes = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
- return await PageLikes.packMany(likes, user);
+ return PageLikes.packMany(likes, user);
});
diff --git a/packages/backend/src/server/api/endpoints/i/pages.ts b/packages/backend/src/server/api/endpoints/i/pages.ts
index bef775d06..f28aed3fd 100644
--- a/packages/backend/src/server/api/endpoints/i/pages.ts
+++ b/packages/backend/src/server/api/endpoints/i/pages.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Pages } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { Pages } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['account', 'pages'],
@@ -11,21 +9,6 @@ export const meta = {
kind: 'read:pages',
- params: {
- 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,
@@ -37,13 +20,23 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(Pages.createQueryBuilder('page'), ps.sinceId, ps.untilId)
.andWhere(`page.userId = :meId`, { meId: user.id });
const pages = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Pages.packMany(pages);
diff --git a/packages/backend/src/server/api/endpoints/i/pin.ts b/packages/backend/src/server/api/endpoints/i/pin.ts
index a940d1b99..67b7026be 100644
--- a/packages/backend/src/server/api/endpoints/i/pin.ts
+++ b/packages/backend/src/server/api/endpoints/i/pin.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { addPinned } from '@/services/i/pin';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Users } from '@/models/index';
+import { addPinned } from '@/services/i/pin.js';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Users } from '@/models/index.js';
export const meta = {
tags: ['account', 'notes'],
@@ -12,12 +10,6 @@ export const meta = {
kind: 'write:account',
- params: {
- noteId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchNote: {
message: 'No such note.',
@@ -45,8 +37,16 @@ export const meta = {
},
} as const;
+export 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) => {
await addPinned(user, ps.noteId).catch(e => {
if (e.id === '70c4e51f-5bea-449c-a030-53bee3cce202') throw new ApiError(meta.errors.noSuchNote);
if (e.id === '15a018eb-58e5-4da1-93be-330fcc5e4e1a') throw new ApiError(meta.errors.pinLimitExceeded);
diff --git a/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts b/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts
index 4e4fb3840..2e291a34a 100644
--- a/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts
+++ b/packages/backend/src/server/api/endpoints/i/read-all-messaging-messages.ts
@@ -1,6 +1,6 @@
-import { publishMainStream } from '@/services/stream';
-import define from '../../define';
-import { MessagingMessages, UserGroupJoinings } from '@/models/index';
+import { publishMainStream } from '@/services/stream.js';
+import define from '../../define.js';
+import { MessagingMessages, UserGroupJoinings } from '@/models/index.js';
export const meta = {
tags: ['account', 'messaging'],
@@ -8,13 +8,16 @@ export const meta = {
requireCredential: true,
kind: 'write:account',
+} as const;
- params: {
- },
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
// Update documents
await MessagingMessages.update({
recipientId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts b/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts
index 99f17ddfc..49f3deb33 100644
--- a/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts
+++ b/packages/backend/src/server/api/endpoints/i/read-all-unread-notes.ts
@@ -1,6 +1,6 @@
-import { publishMainStream } from '@/services/stream';
-import define from '../../define';
-import { NoteUnreads } from '@/models/index';
+import { publishMainStream } from '@/services/stream.js';
+import define from '../../define.js';
+import { NoteUnreads } from '@/models/index.js';
export const meta = {
tags: ['account'],
@@ -8,13 +8,16 @@ export const meta = {
requireCredential: true,
kind: 'write:account',
+} as const;
- params: {
- },
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
// Remove documents
await NoteUnreads.delete({
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/i/read-announcement.ts b/packages/backend/src/server/api/endpoints/i/read-announcement.ts
index e9bb66264..647fa77fa 100644
--- a/packages/backend/src/server/api/endpoints/i/read-announcement.ts
+++ b/packages/backend/src/server/api/endpoints/i/read-announcement.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { genId } from '@/misc/gen-id';
-import { AnnouncementReads, Announcements, Users } from '@/models/index';
-import { publishMainStream } from '@/services/stream';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { genId } from '@/misc/gen-id.js';
+import { AnnouncementReads, Announcements, Users } from '@/models/index.js';
+import { publishMainStream } from '@/services/stream.js';
export const meta = {
tags: ['account'],
@@ -13,12 +11,6 @@ export const meta = {
kind: 'write:account',
- params: {
- announcementId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchAnnouncement: {
message: 'No such announcement.',
@@ -28,8 +20,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ announcementId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['announcementId'],
+} 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) => {
// Check if announcement exists
const announcement = await Announcements.findOne(ps.announcementId);
diff --git a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts
index a20719363..771c98b21 100644
--- a/packages/backend/src/server/api/endpoints/i/regenerate-token.ts
+++ b/packages/backend/src/server/api/endpoints/i/regenerate-token.ts
@@ -1,24 +1,25 @@
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import { publishMainStream, publishUserEvent } from '@/services/stream';
-import generateUserToken from '../../common/generate-native-user-token';
-import define from '../../define';
-import { Users, UserProfiles } from '@/models/index';
+import bcrypt from 'bcryptjs';
+import { publishMainStream, publishUserEvent } from '@/services/stream.js';
+import generateUserToken from '../../common/generate-native-user-token.js';
+import define from '../../define.js';
+import { Users, UserProfiles } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- password: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ password: { type: 'string' },
},
+ required: ['password'],
} 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 profile = await UserProfiles.findOneOrFail(user.id);
// Compare password
diff --git a/packages/backend/src/server/api/endpoints/i/registry/get-all.ts b/packages/backend/src/server/api/endpoints/i/registry/get-all.ts
index 2941b441e..d0b16dbc4 100644
--- a/packages/backend/src/server/api/endpoints/i/registry/get-all.ts
+++ b/packages/backend/src/server/api/endpoints/i/registry/get-all.ts
@@ -1,22 +1,24 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { RegistryItems } from '@/models/index';
+import define from '../../../define.js';
+import { RegistryItems } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- scope: {
- validator: $.optional.arr($.str.match(/^[a-zA-Z0-9_]+$/)),
- default: [],
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ scope: { type: 'array', default: [], items: {
+ type: 'string', pattern: /^[a-zA-Z0-9_]+$/.toString().slice(1, -1),
+ } },
},
+ 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 = RegistryItems.createQueryBuilder('item')
.where('item.domain IS NULL')
.andWhere('item.userId = :userId', { userId: user.id })
diff --git a/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts b/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts
index 51371353c..cc5d5a8c6 100644
--- a/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts
+++ b/packages/backend/src/server/api/endpoints/i/registry/get-detail.ts
@@ -1,24 +1,12 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { RegistryItems } from '@/models/index';
-import { ApiError } from '../../../error';
+import define from '../../../define.js';
+import { RegistryItems } from '@/models/index.js';
+import { ApiError } from '../../../error.js';
export const meta = {
requireCredential: true,
secure: true,
- params: {
- key: {
- validator: $.str,
- },
-
- scope: {
- validator: $.optional.arr($.str.match(/^[a-zA-Z0-9_]+$/)),
- default: [],
- },
- },
-
errors: {
noSuchKey: {
message: 'No such key.',
@@ -28,8 +16,19 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ key: { type: 'string' },
+ scope: { type: 'array', default: [], items: {
+ type: 'string', pattern: /^[a-zA-Z0-9_]+$/.toString().slice(1, -1),
+ } },
+ },
+ required: ['key'],
+} 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 = RegistryItems.createQueryBuilder('item')
.where('item.domain IS NULL')
.andWhere('item.userId = :userId', { userId: user.id })
diff --git a/packages/backend/src/server/api/endpoints/i/registry/get.ts b/packages/backend/src/server/api/endpoints/i/registry/get.ts
index ac617defb..a79319744 100644
--- a/packages/backend/src/server/api/endpoints/i/registry/get.ts
+++ b/packages/backend/src/server/api/endpoints/i/registry/get.ts
@@ -1,24 +1,12 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { RegistryItems } from '@/models/index';
-import { ApiError } from '../../../error';
+import define from '../../../define.js';
+import { RegistryItems } from '@/models/index.js';
+import { ApiError } from '../../../error.js';
export const meta = {
requireCredential: true,
secure: true,
- params: {
- key: {
- validator: $.str,
- },
-
- scope: {
- validator: $.optional.arr($.str.match(/^[a-zA-Z0-9_]+$/)),
- default: [],
- },
- },
-
errors: {
noSuchKey: {
message: 'No such key.',
@@ -28,8 +16,19 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ key: { type: 'string' },
+ scope: { type: 'array', default: [], items: {
+ type: 'string', pattern: /^[a-zA-Z0-9_]+$/.toString().slice(1, -1),
+ } },
+ },
+ required: ['key'],
+} 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 = RegistryItems.createQueryBuilder('item')
.where('item.domain IS NULL')
.andWhere('item.userId = :userId', { userId: user.id })
diff --git a/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts b/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts
index 044592218..ac209c06a 100644
--- a/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts
+++ b/packages/backend/src/server/api/endpoints/i/registry/keys-with-type.ts
@@ -1,22 +1,24 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { RegistryItems } from '@/models/index';
+import define from '../../../define.js';
+import { RegistryItems } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- scope: {
- validator: $.optional.arr($.str.match(/^[a-zA-Z0-9_]+$/)),
- default: [],
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ scope: { type: 'array', default: [], items: {
+ type: 'string', pattern: /^[a-zA-Z0-9_]+$/.toString().slice(1, -1),
+ } },
},
+ 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 = RegistryItems.createQueryBuilder('item')
.where('item.domain IS NULL')
.andWhere('item.userId = :userId', { userId: user.id })
diff --git a/packages/backend/src/server/api/endpoints/i/registry/keys.ts b/packages/backend/src/server/api/endpoints/i/registry/keys.ts
index a3c9d0e5e..5ea1a9d34 100644
--- a/packages/backend/src/server/api/endpoints/i/registry/keys.ts
+++ b/packages/backend/src/server/api/endpoints/i/registry/keys.ts
@@ -1,22 +1,24 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { RegistryItems } from '@/models/index';
+import define from '../../../define.js';
+import { RegistryItems } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- scope: {
- validator: $.optional.arr($.str.match(/^[a-zA-Z0-9_]+$/)),
- default: [],
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ scope: { type: 'array', default: [], items: {
+ type: 'string', pattern: /^[a-zA-Z0-9_]+$/.toString().slice(1, -1),
+ } },
},
+ 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 = RegistryItems.createQueryBuilder('item')
.select('item.key')
.where('item.domain IS NULL')
diff --git a/packages/backend/src/server/api/endpoints/i/registry/remove.ts b/packages/backend/src/server/api/endpoints/i/registry/remove.ts
index 08185f224..92473654c 100644
--- a/packages/backend/src/server/api/endpoints/i/registry/remove.ts
+++ b/packages/backend/src/server/api/endpoints/i/registry/remove.ts
@@ -1,24 +1,12 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { RegistryItems } from '@/models/index';
-import { ApiError } from '../../../error';
+import define from '../../../define.js';
+import { RegistryItems } from '@/models/index.js';
+import { ApiError } from '../../../error.js';
export const meta = {
requireCredential: true,
secure: true,
- params: {
- key: {
- validator: $.str,
- },
-
- scope: {
- validator: $.optional.arr($.str.match(/^[a-zA-Z0-9_]+$/)),
- default: [],
- },
- },
-
errors: {
noSuchKey: {
message: 'No such key.',
@@ -28,8 +16,19 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ key: { type: 'string' },
+ scope: { type: 'array', default: [], items: {
+ type: 'string', pattern: /^[a-zA-Z0-9_]+$/.toString().slice(1, -1),
+ } },
+ },
+ required: ['key'],
+} 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 = RegistryItems.createQueryBuilder('item')
.where('item.domain IS NULL')
.andWhere('item.userId = :userId', { userId: user.id })
diff --git a/packages/backend/src/server/api/endpoints/i/registry/scopes.ts b/packages/backend/src/server/api/endpoints/i/registry/scopes.ts
index 9de68ac6e..de4b313e2 100644
--- a/packages/backend/src/server/api/endpoints/i/registry/scopes.ts
+++ b/packages/backend/src/server/api/endpoints/i/registry/scopes.ts
@@ -1,17 +1,20 @@
-import define from '../../../define';
-import { RegistryItems } from '@/models/index';
+import define from '../../../define.js';
+import { RegistryItems } from '@/models/index.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- },
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 = RegistryItems.createQueryBuilder('item')
.select('item.scope')
.where('item.domain IS NULL')
diff --git a/packages/backend/src/server/api/endpoints/i/registry/set.ts b/packages/backend/src/server/api/endpoints/i/registry/set.ts
index 27884046b..d380b428a 100644
--- a/packages/backend/src/server/api/endpoints/i/registry/set.ts
+++ b/packages/backend/src/server/api/endpoints/i/registry/set.ts
@@ -1,32 +1,28 @@
-import $ from 'cafy';
-import { publishMainStream } from '@/services/stream';
-import define from '../../../define';
-import { RegistryItems } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import { publishMainStream } from '@/services/stream.js';
+import define from '../../../define.js';
+import { RegistryItems } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- key: {
- validator: $.str.min(1),
- },
-
- value: {
- validator: $.nullable.any,
- },
-
- scope: {
- validator: $.optional.arr($.str.match(/^[a-zA-Z0-9_]+$/)),
- default: [],
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ key: { type: 'string', minLength: 1 },
+ value: {},
+ scope: { type: 'array', default: [], items: {
+ type: 'string', pattern: /^[a-zA-Z0-9_]+$/.toString().slice(1, -1),
+ } },
},
+ required: ['key', 'value'],
} 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 = RegistryItems.createQueryBuilder('item')
.where('item.domain IS NULL')
.andWhere('item.userId = :userId', { userId: user.id })
diff --git a/packages/backend/src/server/api/endpoints/i/revoke-token.ts b/packages/backend/src/server/api/endpoints/i/revoke-token.ts
index 51721c5b5..b957fd079 100644
--- a/packages/backend/src/server/api/endpoints/i/revoke-token.ts
+++ b/packages/backend/src/server/api/endpoints/i/revoke-token.ts
@@ -1,23 +1,23 @@
-import $ from 'cafy';
-import define from '../../define';
-import { AccessTokens } from '@/models/index';
-import { ID } from '@/misc/cafy-id';
-import { publishUserEvent } from '@/services/stream';
+import define from '../../define.js';
+import { AccessTokens } from '@/models/index.js';
+import { publishUserEvent } from '@/services/stream.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- tokenId: {
- validator: $.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ tokenId: { type: 'string', format: 'misskey:id' },
},
+ required: ['tokenId'],
} 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 token = await AccessTokens.findOne(ps.tokenId);
if (token) {
diff --git a/packages/backend/src/server/api/endpoints/i/signin-history.ts b/packages/backend/src/server/api/endpoints/i/signin-history.ts
index 796e2ec30..ca3741166 100644
--- a/packages/backend/src/server/api/endpoints/i/signin-history.ts
+++ b/packages/backend/src/server/api/endpoints/i/signin-history.ts
@@ -1,36 +1,29 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Signins } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { Signins } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
requireCredential: true,
secure: true,
+} as const;
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
+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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(Signins.createQueryBuilder('signin'), ps.sinceId, ps.untilId)
.andWhere(`signin.userId = :meId`, { meId: user.id });
- const history = await query.take(ps.limit!).getMany();
+ const history = await query.take(ps.limit).getMany();
return await Promise.all(history.map(record => Signins.pack(record)));
});
diff --git a/packages/backend/src/server/api/endpoints/i/unpin.ts b/packages/backend/src/server/api/endpoints/i/unpin.ts
index 9c82b7496..9912689da 100644
--- a/packages/backend/src/server/api/endpoints/i/unpin.ts
+++ b/packages/backend/src/server/api/endpoints/i/unpin.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { removePinned } from '@/services/i/pin';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Users } from '@/models/index';
+import { removePinned } from '@/services/i/pin.js';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Users } from '@/models/index.js';
export const meta = {
tags: ['account', 'notes'],
@@ -12,12 +10,6 @@ export const meta = {
kind: 'write:account',
- params: {
- noteId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchNote: {
message: 'No such note.',
@@ -33,8 +25,16 @@ export const meta = {
},
} as const;
+export 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) => {
await removePinned(user, ps.noteId).catch(e => {
if (e.id === 'b302d4cf-c050-400a-bbb3-be208681f40c') throw new ApiError(meta.errors.noSuchNote);
throw e;
diff --git a/packages/backend/src/server/api/endpoints/i/update-email.ts b/packages/backend/src/server/api/endpoints/i/update-email.ts
index b4479aa50..389ff1b81 100644
--- a/packages/backend/src/server/api/endpoints/i/update-email.ts
+++ b/packages/backend/src/server/api/endpoints/i/update-email.ts
@@ -1,14 +1,13 @@
-import $ from 'cafy';
-import { publishMainStream } from '@/services/stream';
-import define from '../../define';
+import { publishMainStream } from '@/services/stream.js';
+import define from '../../define.js';
import rndstr from 'rndstr';
-import config from '@/config/index';
+import config from '@/config/index.js';
import ms from 'ms';
-import * as bcrypt from 'bcryptjs';
-import { Users, UserProfiles } from '@/models/index';
-import { sendEmail } from '@/services/send-email';
-import { ApiError } from '../../error';
-import { validateEmailForAccount } from '@/services/validate-email-for-account';
+import bcrypt from 'bcryptjs';
+import { Users, UserProfiles } from '@/models/index.js';
+import { sendEmail } from '@/services/send-email.js';
+import { ApiError } from '../../error.js';
+import { validateEmailForAccount } from '@/services/validate-email-for-account.js';
export const meta = {
requireCredential: true,
@@ -20,16 +19,6 @@ export const meta = {
max: 3,
},
- params: {
- password: {
- validator: $.str,
- },
-
- email: {
- validator: $.optional.nullable.str,
- },
- },
-
errors: {
incorrectPassword: {
message: 'Incorrect password.',
@@ -45,8 +34,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ password: { type: 'string' },
+ email: { type: 'string', nullable: true },
+ },
+ required: ['password'],
+} 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 profile = await UserProfiles.findOneOrFail(user.id);
// Compare password
diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts
index aec7bbd2e..85d0a6254 100644
--- a/packages/backend/src/server/api/endpoints/i/update.ts
+++ b/packages/backend/src/server/api/endpoints/i/update.ts
@@ -1,21 +1,19 @@
-const RE2 = require('re2');
-import $ from 'cafy';
+import RE2 from 're2';
import * as mfm from 'mfm-js';
-import { ID } from '@/misc/cafy-id';
-import { publishMainStream, publishUserEvent } from '@/services/stream';
-import acceptAllFollowRequests from '@/services/following/requests/accept-all';
-import { publishToFollowers } from '@/services/i/update';
-import define from '../../define';
-import { extractCustomEmojisFromMfm } from '@/misc/extract-custom-emojis-from-mfm';
-import { extractHashtags } from '@/misc/extract-hashtags';
-import * as langmap from 'langmap';
-import { updateUsertags } from '@/services/update-hashtag';
-import { ApiError } from '../../error';
-import { Users, DriveFiles, UserProfiles, Pages } from '@/models/index';
-import { User } from '@/models/entities/user';
-import { UserProfile } from '@/models/entities/user-profile';
-import { notificationTypes } from '@/types';
-import { normalizeForSearch } from '@/misc/normalize-for-search';
+import { publishMainStream, publishUserEvent } from '@/services/stream.js';
+import acceptAllFollowRequests from '@/services/following/requests/accept-all.js';
+import { publishToFollowers } from '@/services/i/update.js';
+import define from '../../define.js';
+import { extractCustomEmojisFromMfm } from '@/misc/extract-custom-emojis-from-mfm.js';
+import { extractHashtags } from '@/misc/extract-hashtags.js';
+import { updateUsertags } from '@/services/update-hashtag.js';
+import { ApiError } from '../../error.js';
+import { Users, DriveFiles, UserProfiles, Pages } from '@/models/index.js';
+import { User } from '@/models/entities/user.js';
+import { UserProfile } from '@/models/entities/user-profile.js';
+import { notificationTypes } from '@/types.js';
+import { normalizeForSearch } from '@/misc/normalize-for-search.js';
+import { langmap } from '@/misc/langmap.js';
export const meta = {
tags: ['account'],
@@ -24,116 +22,6 @@ export const meta = {
kind: 'write:account',
- params: {
- name: {
- validator: $.optional.nullable.use(Users.validateName),
- },
-
- description: {
- validator: $.optional.nullable.use(Users.validateDescription),
- },
-
- lang: {
- validator: $.optional.nullable.str.or(Object.keys(langmap)),
- },
-
- location: {
- validator: $.optional.nullable.use(Users.validateLocation),
- },
-
- birthday: {
- validator: $.optional.nullable.use(Users.validateBirthday),
- },
-
- avatarId: {
- validator: $.optional.nullable.type(ID),
- },
-
- bannerId: {
- validator: $.optional.nullable.type(ID),
- },
-
- fields: {
- validator: $.optional.arr($.object()).range(1, 4),
- },
-
- isLocked: {
- validator: $.optional.bool,
- },
-
- isExplorable: {
- validator: $.optional.bool,
- },
-
- hideOnlineStatus: {
- validator: $.optional.bool,
- },
-
- publicReactions: {
- validator: $.optional.bool,
- },
-
- ffVisibility: {
- validator: $.optional.str,
- },
-
- carefulBot: {
- validator: $.optional.bool,
- },
-
- autoAcceptFollowed: {
- validator: $.optional.bool,
- },
-
- noCrawle: {
- validator: $.optional.bool,
- },
-
- isBot: {
- validator: $.optional.bool,
- },
-
- isCat: {
- validator: $.optional.bool,
- },
-
- showTimelineReplies: {
- validator: $.optional.bool,
- },
-
- injectFeaturedNote: {
- validator: $.optional.bool,
- },
-
- receiveAnnouncementEmail: {
- validator: $.optional.bool,
- },
-
- alwaysMarkNsfw: {
- validator: $.optional.bool,
- },
-
- pinnedPageId: {
- validator: $.optional.nullable.type(ID),
- },
-
- mutedWords: {
- validator: $.optional.arr($.either($.arr($.str.min(1)).min(1), $.str)),
- },
-
- mutedInstances: {
- validator: $.optional.arr($.str),
- },
-
- mutingNotificationTypes: {
- validator: $.optional.arr($.str.or(notificationTypes as unknown as string[])),
- },
-
- emailNotificationTypes: {
- validator: $.optional.arr($.str),
- },
- },
-
errors: {
noSuchAvatar: {
message: 'No such avatar file.',
@@ -179,8 +67,60 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ name: { ...Users.nameSchema, nullable: true },
+ description: { ...Users.descriptionSchema, nullable: true },
+ location: { ...Users.locationSchema, nullable: true },
+ birthday: { ...Users.birthdaySchema, nullable: true },
+ lang: { type: 'string', enum: [null, ...Object.keys(langmap)], nullable: true },
+ avatarId: { type: 'string', format: 'misskey:id', nullable: true },
+ bannerId: { type: 'string', format: 'misskey:id', nullable: true },
+ fields: { type: 'array',
+ minItems: 0,
+ maxItems: 16,
+ items: {
+ type: 'object',
+ properties: {
+ name: { type: 'string' },
+ value: { type: 'string' },
+ },
+ required: ['name', 'value'],
+ },
+ },
+ isLocked: { type: 'boolean' },
+ isExplorable: { type: 'boolean' },
+ hideOnlineStatus: { type: 'boolean' },
+ publicReactions: { type: 'boolean' },
+ carefulBot: { type: 'boolean' },
+ autoAcceptFollowed: { type: 'boolean' },
+ noCrawle: { type: 'boolean' },
+ isBot: { type: 'boolean' },
+ isCat: { type: 'boolean' },
+ showTimelineReplies: { type: 'boolean' },
+ injectFeaturedNote: { type: 'boolean' },
+ receiveAnnouncementEmail: { type: 'boolean' },
+ alwaysMarkNsfw: { type: 'boolean' },
+ ffVisibility: { type: 'string', enum: ['public', 'followers', 'private'] },
+ pinnedPageId: { type: 'array', items: {
+ type: 'string', format: 'misskey:id',
+ } },
+ mutedWords: { type: 'array' },
+ mutedInstances: { type: 'array', items: {
+ type: 'string',
+ } },
+ mutingNotificationTypes: { type: 'array', items: {
+ type: 'string', enum: notificationTypes,
+ } },
+ emailNotificationTypes: { type: 'array', items: {
+ type: 'string',
+ } },
+ },
+} as const;
+
// 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 user = await Users.findOneOrFail(_user.id);
const isSecure = token == null;
@@ -235,12 +175,6 @@ export default define(meta, async (ps, _user, token) => {
if (avatar == null || avatar.userId !== user.id) throw new ApiError(meta.errors.noSuchAvatar);
if (!avatar.type.startsWith('image/')) throw new ApiError(meta.errors.avatarNotAnImage);
-
- updates.avatarUrl = DriveFiles.getPublicUrl(avatar, true);
-
- if (avatar.blurhash) {
- updates.avatarBlurhash = avatar.blurhash;
- }
}
if (ps.bannerId) {
@@ -248,12 +182,6 @@ export default define(meta, async (ps, _user, token) => {
if (banner == null || banner.userId !== user.id) throw new ApiError(meta.errors.noSuchBanner);
if (!banner.type.startsWith('image/')) throw new ApiError(meta.errors.bannerNotAnImage);
-
- updates.bannerUrl = DriveFiles.getPublicUrl(banner, false);
-
- if (banner.blurhash) {
- updates.bannerBlurhash = banner.blurhash;
- }
}
if (ps.pinnedPageId) {
diff --git a/packages/backend/src/server/api/endpoints/i/user-group-invites.ts b/packages/backend/src/server/api/endpoints/i/user-group-invites.ts
index 76a3131e6..1d7e4a16b 100644
--- a/packages/backend/src/server/api/endpoints/i/user-group-invites.ts
+++ b/packages/backend/src/server/api/endpoints/i/user-group-invites.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { UserGroupInvitations } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { UserGroupInvitations } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['account', 'groups'],
@@ -11,21 +9,6 @@ export const meta = {
kind: 'read:user-groups',
- params: {
- 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,
@@ -48,14 +31,24 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(UserGroupInvitations.createQueryBuilder('invitation'), ps.sinceId, ps.untilId)
.andWhere(`invitation.userId = :meId`, { meId: user.id })
.leftJoinAndSelect('invitation.userGroup', 'user_group');
const invitations = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await UserGroupInvitations.packMany(invitations);
diff --git a/packages/backend/src/server/api/endpoints/messaging/history.ts b/packages/backend/src/server/api/endpoints/messaging/history.ts
index 5ac49cf96..14de4e102 100644
--- a/packages/backend/src/server/api/endpoints/messaging/history.ts
+++ b/packages/backend/src/server/api/endpoints/messaging/history.ts
@@ -1,7 +1,6 @@
-import $ from 'cafy';
-import define from '../../define';
-import { MessagingMessage } from '@/models/entities/messaging-message';
-import { MessagingMessages, Mutings, UserGroupJoinings } from '@/models/index';
+import define from '../../define.js';
+import { MessagingMessage } from '@/models/entities/messaging-message.js';
+import { MessagingMessages, Mutings, UserGroupJoinings } from '@/models/index.js';
import { Brackets } from 'typeorm';
export const meta = {
@@ -11,18 +10,6 @@ export const meta = {
kind: 'read:messaging',
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- group: {
- validator: $.optional.bool,
- default: false,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -34,8 +21,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ group: { type: 'boolean', default: false },
+ },
+ 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 mute = await Mutings.find({
muterId: user.id,
});
@@ -50,7 +46,7 @@ export default define(meta, async (ps, user) => {
const history: MessagingMessage[] = [];
- for (let i = 0; i < ps.limit!; i++) {
+ for (let i = 0; i < ps.limit; i++) {
const found = ps.group
? history.map(m => m.groupId!)
: history.map(m => (m.userId === user.id) ? m.recipientId! : m.userId!);
diff --git a/packages/backend/src/server/api/endpoints/messaging/messages.ts b/packages/backend/src/server/api/endpoints/messaging/messages.ts
index 7dbddd80e..49ace2160 100644
--- a/packages/backend/src/server/api/endpoints/messaging/messages.ts
+++ b/packages/backend/src/server/api/endpoints/messaging/messages.ts
@@ -1,12 +1,10 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { getUser } from '../../common/getters';
-import { MessagingMessages, UserGroups, UserGroupJoinings, Users } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { getUser } from '../../common/getters.js';
+import { MessagingMessages, UserGroups, UserGroupJoinings, Users } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { Brackets } from 'typeorm';
-import { readUserMessagingMessage, readGroupMessagingMessage, deliverReadActivity } from '../../common/read-messaging-message';
+import { readUserMessagingMessage, readGroupMessagingMessage, deliverReadActivity } from '../../common/read-messaging-message.js';
export const meta = {
tags: ['messaging'],
@@ -15,34 +13,6 @@ export const meta = {
kind: 'read:messaging',
- params: {
- userId: {
- validator: $.optional.type(ID),
- },
-
- groupId: {
- validator: $.optional.type(ID),
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
-
- markAsRead: {
- validator: $.optional.bool,
- default: true,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -74,8 +44,21 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
+ groupId: { 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' },
+ markAsRead: { type: 'boolean', default: true },
+ },
+ 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) => {
if (ps.userId != null) {
// Fetch recipient (user)
const recipient = await getUser(ps.userId).catch(e => {
@@ -97,7 +80,7 @@ export default define(meta, async (ps, user) => {
.setParameter('meId', user.id)
.setParameter('recipientId', recipient.id);
- const messages = await query.take(ps.limit!).getMany();
+ const messages = await query.take(ps.limit).getMany();
// Mark all as read
if (ps.markAsRead) {
@@ -133,7 +116,7 @@ export default define(meta, async (ps, user) => {
const query = makePaginationQuery(MessagingMessages.createQueryBuilder('message'), ps.sinceId, ps.untilId)
.andWhere(`message.groupId = :groupId`, { groupId: recipientGroup.id });
- const messages = await query.take(ps.limit!).getMany();
+ const messages = await query.take(ps.limit).getMany();
// Mark all as read
if (ps.markAsRead) {
diff --git a/packages/backend/src/server/api/endpoints/messaging/messages/create.ts b/packages/backend/src/server/api/endpoints/messaging/messages/create.ts
index 5ec16f5e5..a9b926c4f 100644
--- a/packages/backend/src/server/api/endpoints/messaging/messages/create.ts
+++ b/packages/backend/src/server/api/endpoints/messaging/messages/create.ts
@@ -1,12 +1,10 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getUser } from '../../../common/getters';
-import { MessagingMessages, DriveFiles, UserGroups, UserGroupJoinings, Blockings } from '@/models/index';
-import { User } from '@/models/entities/user';
-import { UserGroup } from '@/models/entities/user-group';
-import { createMessage } from '@/services/messages/create';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getUser } from '../../../common/getters.js';
+import { MessagingMessages, DriveFiles, UserGroups, UserGroupJoinings, Blockings } from '@/models/index.js';
+import { User } from '@/models/entities/user.js';
+import { UserGroup } from '@/models/entities/user-group.js';
+import { createMessage } from '@/services/messages/create.js';
export const meta = {
tags: ['messaging'],
@@ -15,24 +13,6 @@ export const meta = {
kind: 'write:messaging',
- params: {
- userId: {
- validator: $.optional.type(ID),
- },
-
- groupId: {
- validator: $.optional.type(ID),
- },
-
- text: {
- validator: $.optional.str.pipe(MessagingMessages.validateText),
- },
-
- fileId: {
- validator: $.optional.type(ID),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -84,8 +64,19 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
+ groupId: { type: 'string', format: 'misskey:id' },
+ text: { type: 'string', nullable: true, maxLength: 3000 },
+ fileId: { type: 'string', format: 'misskey:id' },
+ },
+ 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 recipientUser: User | undefined;
let recipientGroup: UserGroup | undefined;
diff --git a/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts b/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts
index 2975419ce..a0945af51 100644
--- a/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts
+++ b/packages/backend/src/server/api/endpoints/messaging/messages/delete.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
+import define from '../../../define.js';
import ms from 'ms';
-import { ApiError } from '../../../error';
-import { MessagingMessages } from '@/models/index';
-import { deleteMessage } from '@/services/messages/delete';
+import { ApiError } from '../../../error.js';
+import { MessagingMessages } from '@/models/index.js';
+import { deleteMessage } from '@/services/messages/delete.js';
export const meta = {
tags: ['messaging'],
@@ -19,12 +17,6 @@ export const meta = {
minInterval: ms('1sec'),
},
- params: {
- messageId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchMessage: {
message: 'No such message.',
@@ -34,8 +26,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ messageId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['messageId'],
+} 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 message = await MessagingMessages.findOne({
id: ps.messageId,
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/messaging/messages/read.ts b/packages/backend/src/server/api/endpoints/messaging/messages/read.ts
index 42c3f49f6..8d38e509a 100644
--- a/packages/backend/src/server/api/endpoints/messaging/messages/read.ts
+++ b/packages/backend/src/server/api/endpoints/messaging/messages/read.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { MessagingMessages } from '@/models/index';
-import { readUserMessagingMessage, readGroupMessagingMessage } from '../../../common/read-messaging-message';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { MessagingMessages } from '@/models/index.js';
+import { readUserMessagingMessage, readGroupMessagingMessage } from '../../../common/read-messaging-message.js';
export const meta = {
tags: ['messaging'],
@@ -12,12 +10,6 @@ export const meta = {
kind: 'write:messaging',
- params: {
- messageId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchMessage: {
message: 'No such message.',
@@ -27,8 +19,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ messageId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['messageId'],
+} 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 message = await MessagingMessages.findOne(ps.messageId);
if (message == null) {
diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts
index 16ea99af6..1aff1f63f 100644
--- a/packages/backend/src/server/api/endpoints/meta.ts
+++ b/packages/backend/src/server/api/endpoints/meta.ts
@@ -1,23 +1,16 @@
-import $ from 'cafy';
-import config from '@/config/index';
-import define from '../define';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { Ads, Emojis, Users } from '@/models/index';
-import { DB_MAX_NOTE_TEXT_LENGTH } from '@/misc/hard-limits';
+import config from '@/config/index.js';
+import define from '../define.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { Ads, Emojis, Users } from '@/models/index.js';
+import { DB_MAX_NOTE_TEXT_LENGTH } from '@/misc/hard-limits.js';
import { MoreThan } from 'typeorm';
+import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
export const meta = {
tags: ['meta'],
requireCredential: false,
- params: {
- detail: {
- validator: $.optional.bool,
- default: true,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -71,10 +64,13 @@ export const meta = {
optional: false, nullable: false,
default: 'https://github.com/misskey-dev/misskey/issues/new',
},
- secure: {
- type: 'boolean',
- optional: false, nullable: false,
- default: false,
+ defaultDarkTheme: {
+ type: 'string',
+ optional: false, nullable: true,
+ },
+ defaultLightTheme: {
+ type: 'string',
+ optional: false, nullable: true,
},
disableRegistration: {
type: 'boolean',
@@ -100,10 +96,6 @@ export const meta = {
type: 'boolean',
optional: false, nullable: false,
},
- proxyRemoteFiles: {
- type: 'boolean',
- optional: false, nullable: false,
- },
emailRequiredForSignup: {
type: 'boolean',
optional: false, nullable: false,
@@ -149,7 +141,6 @@ export const meta = {
maxNoteTextLength: {
type: 'number',
optional: false, nullable: false,
- default: 500,
},
emojis: {
type: 'array',
@@ -448,8 +439,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ detail: { type: 'boolean', default: true },
+ },
+ 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 instance = await fetchMeta(true);
const emojis = await Emojis.find({
@@ -485,9 +484,6 @@ export default define(meta, async (ps, me) => {
tosUrl: instance.ToSUrl,
repositoryUrl: instance.repositoryUrl,
feedbackUrl: instance.feedbackUrl,
-
- secure: config.https != null,
-
disableRegistration: instance.disableRegistration,
disableLocalTimeline: instance.disableLocalTimeline,
disableGlobalTimeline: instance.disableGlobalTimeline,
@@ -506,8 +502,10 @@ export default define(meta, async (ps, me) => {
iconUrl: instance.iconUrl,
backgroundImageUrl: instance.backgroundImageUrl,
logoImageUrl: instance.logoImageUrl,
- maxNoteTextLength: Math.min(instance.maxNoteTextLength, DB_MAX_NOTE_TEXT_LENGTH),
+ maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, // 後方互換性のため
emojis: await Emojis.packMany(emojis),
+ defaultLightTheme: instance.defaultLightTheme,
+ defaultDarkTheme: instance.defaultDarkTheme,
ads: ads.map(ad => ({
id: ad.id,
url: ad.url,
@@ -529,7 +527,6 @@ export default define(meta, async (ps, me) => {
pinnedPages: instance.pinnedPages,
pinnedClipId: instance.pinnedClipId,
cacheRemoteFiles: instance.cacheRemoteFiles,
- proxyRemoteFiles: instance.proxyRemoteFiles,
requireSetup: (await Users.count({
host: null,
})) === 0,
diff --git a/packages/backend/src/server/api/endpoints/miauth/gen-token.ts b/packages/backend/src/server/api/endpoints/miauth/gen-token.ts
index 158c8877e..73ecdaeb0 100644
--- a/packages/backend/src/server/api/endpoints/miauth/gen-token.ts
+++ b/packages/backend/src/server/api/endpoints/miauth/gen-token.ts
@@ -1,8 +1,7 @@
-import $ from 'cafy';
-import define from '../../define';
-import { AccessTokens } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { secureRndstr } from '@/misc/secure-rndstr';
+import define from '../../define.js';
+import { AccessTokens } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { secureRndstr } from '@/misc/secure-rndstr.js';
export const meta = {
tags: ['auth'],
@@ -11,28 +10,6 @@ export const meta = {
secure: true,
- params: {
- session: {
- validator: $.nullable.str,
- },
-
- name: {
- validator: $.nullable.optional.str,
- },
-
- description: {
- validator: $.nullable.optional.str,
- },
-
- iconUrl: {
- validator: $.nullable.optional.str,
- },
-
- permission: {
- validator: $.arr($.str).unique(),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -45,8 +22,22 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ session: { type: 'string', nullable: true },
+ name: { type: 'string', nullable: true },
+ description: { type: 'string', nullable: true },
+ iconUrl: { type: 'string', nullable: true },
+ permission: { type: 'array', uniqueItems: true, items: {
+ type: 'string',
+ } },
+ },
+ required: ['session', 'permission'],
+} 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) => {
// Generate access token
const accessToken = secureRndstr(32, true);
diff --git a/packages/backend/src/server/api/endpoints/mute/create.ts b/packages/backend/src/server/api/endpoints/mute/create.ts
index 6ba5a453c..dacee40d0 100644
--- a/packages/backend/src/server/api/endpoints/mute/create.ts
+++ b/packages/backend/src/server/api/endpoints/mute/create.ts
@@ -1,12 +1,10 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { getUser } from '../../common/getters';
-import { genId } from '@/misc/gen-id';
-import { Mutings, NoteWatchings } from '@/models/index';
-import { Muting } from '@/models/entities/muting';
-import { publishUserEvent } from '@/services/stream';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { getUser } from '../../common/getters.js';
+import { genId } from '@/misc/gen-id.js';
+import { Mutings, NoteWatchings } from '@/models/index.js';
+import { Muting } from '@/models/entities/muting.js';
+import { publishUserEvent } from '@/services/stream.js';
export const meta = {
tags: ['account'],
@@ -15,12 +13,6 @@ export const meta = {
kind: 'write:mutes',
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -42,8 +34,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
+ expiresAt: { type: 'integer', nullable: true },
+ },
+ required: ['userId'],
+} 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 muter = user;
// 自分自身
@@ -67,10 +68,15 @@ export default define(meta, async (ps, user) => {
throw new ApiError(meta.errors.alreadyMuting);
}
+ if (ps.expiresAt && ps.expiresAt <= Date.now()) {
+ return;
+ }
+
// Create mute
await Mutings.insert({
id: genId(),
createdAt: new Date(),
+ expiresAt: ps.expiresAt ? new Date(ps.expiresAt) : null,
muterId: muter.id,
muteeId: mutee.id,
} as Muting);
diff --git a/packages/backend/src/server/api/endpoints/mute/delete.ts b/packages/backend/src/server/api/endpoints/mute/delete.ts
index 21948dc3d..a8cf2a666 100644
--- a/packages/backend/src/server/api/endpoints/mute/delete.ts
+++ b/packages/backend/src/server/api/endpoints/mute/delete.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { getUser } from '../../common/getters';
-import { Mutings } from '@/models/index';
-import { publishUserEvent } from '@/services/stream';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { getUser } from '../../common/getters.js';
+import { Mutings } from '@/models/index.js';
+import { publishUserEvent } from '@/services/stream.js';
export const meta = {
tags: ['account'],
@@ -13,12 +11,6 @@ export const meta = {
kind: 'write:mutes',
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -40,8 +32,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, user) => {
+export default define(meta, paramDef, async (ps, user) => {
const muter = user;
// Check if the mutee is yourself
diff --git a/packages/backend/src/server/api/endpoints/mute/list.ts b/packages/backend/src/server/api/endpoints/mute/list.ts
index 4c6a81b63..31283cf4c 100644
--- a/packages/backend/src/server/api/endpoints/mute/list.ts
+++ b/packages/backend/src/server/api/endpoints/mute/list.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { Mutings } from '@/models/index';
+import define from '../../define.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { Mutings } from '@/models/index.js';
export const meta = {
tags: ['account'],
@@ -11,21 +9,6 @@ export const meta = {
kind: 'read:mutes',
- params: {
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 30,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -37,13 +20,23 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 30 },
+ sinceId: { type: 'string', format: 'misskey:id' },
+ untilId: { type: 'string', format: 'misskey:id' },
+ },
+ 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(Mutings.createQueryBuilder('muting'), ps.sinceId, ps.untilId)
.andWhere(`muting.muterId = :meId`, { meId: me.id });
const mutings = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Mutings.packMany(mutings, me);
diff --git a/packages/backend/src/server/api/endpoints/my/apps.ts b/packages/backend/src/server/api/endpoints/my/apps.ts
index 42bd5c5f7..85b75c15d 100644
--- a/packages/backend/src/server/api/endpoints/my/apps.ts
+++ b/packages/backend/src/server/api/endpoints/my/apps.ts
@@ -1,83 +1,40 @@
-import $ from 'cafy';
-import define from '../../define';
-import { Apps } from '@/models/index';
+import define from '../../define.js';
+import { Apps } from '@/models/index.js';
export const meta = {
tags: ['account', 'app'],
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,
items: {
type: 'object',
optional: false, nullable: false,
- properties: {
- id: {
- type: 'string',
- optional: false, nullable: false,
- },
- name: {
- type: 'string',
- optional: false, nullable: false,
- },
- callbackUrl: {
- type: 'string',
- optional: false, nullable: false,
- },
- permission: {
- type: 'array',
- optional: false, nullable: false,
- items: {
- type: 'string',
- optional: false, nullable: false,
- },
- },
- secret: {
- type: 'string',
- optional: true, nullable: false,
- },
- isAuthorized: {
- type: 'object',
- optional: true, nullable: false,
- properties: {
- appId: {
- type: 'string',
- optional: false, nullable: false,
- },
- userId: {
- type: 'string',
- optional: false, nullable: false,
- },
- },
- },
- },
+ ref: 'App',
},
},
} as const;
+export 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 = {
userId: user.id,
};
const apps = await Apps.find({
where: query,
- take: ps.limit!,
+ take: ps.limit,
skip: ps.offset,
});
diff --git a/packages/backend/src/server/api/endpoints/notes.ts b/packages/backend/src/server/api/endpoints/notes.ts
index 9edc6cb11..96657f8d3 100644
--- a/packages/backend/src/server/api/endpoints/notes.ts
+++ b/packages/backend/src/server/api/endpoints/notes.ts
@@ -1,47 +1,10 @@
-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';
+import define from '../define.js';
+import { makePaginationQuery } from '../common/make-pagination-query.js';
+import { Notes } from '@/models/index.js';
export const meta = {
tags: ['notes'],
- params: {
- local: {
- validator: $.optional.bool,
- },
-
- reply: {
- validator: $.optional.bool,
- },
-
- renote: {
- validator: $.optional.bool,
- },
-
- withFiles: {
- validator: $.optional.bool,
- },
-
- poll: {
- validator: $.optional.bool,
- },
-
- 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,
@@ -53,16 +16,37 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ local: { type: 'boolean' },
+ reply: { type: 'boolean' },
+ renote: { type: 'boolean' },
+ withFiles: { type: 'boolean' },
+ poll: { type: 'boolean' },
+ 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
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(`note.visibility = 'public'`)
.andWhere(`note.localOnly = FALSE`)
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
if (ps.local) {
query.andWhere('note.userHost IS NULL');
@@ -89,7 +73,7 @@ export default define(meta, async (ps) => {
// query.isBot = bot;
//}
- const notes = await query.take(ps.limit!).getMany();
+ const notes = await query.take(ps.limit).getMany();
return await Notes.packMany(notes);
});
diff --git a/packages/backend/src/server/api/endpoints/notes/children.ts b/packages/backend/src/server/api/endpoints/notes/children.ts
index 088ef65e9..86dde30d6 100644
--- a/packages/backend/src/server/api/endpoints/notes/children.ts
+++ b/packages/backend/src/server/api/endpoints/notes/children.ts
@@ -1,38 +1,17 @@
-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';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
+import define from '../../define.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { Brackets } from 'typeorm';
-import { Notes } from '@/models/index';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
-import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query';
+import { Notes } from '@/models/index.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
+import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js';
export const meta = {
tags: ['notes'],
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;
+export 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 })
@@ -59,17 +49,23 @@ export default define(meta, async (ps, user) => {
}));
}))
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, 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);
});
diff --git a/packages/backend/src/server/api/endpoints/notes/clips.ts b/packages/backend/src/server/api/endpoints/notes/clips.ts
index b89c6db4a..9a863b714 100644
--- a/packages/backend/src/server/api/endpoints/notes/clips.ts
+++ b/packages/backend/src/server/api/endpoints/notes/clips.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ClipNotes, Clips } from '@/models/index';
-import { getNote } from '../../common/getters';
-import { ApiError } from '../../error';
+import define from '../../define.js';
+import { ClipNotes, Clips } from '@/models/index.js';
+import { getNote } from '../../common/getters.js';
+import { ApiError } from '../../error.js';
import { In } from 'typeorm';
export const meta = {
@@ -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;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/notes/conversation.ts b/packages/backend/src/server/api/endpoints/notes/conversation.ts
index 4bd89c32e..2552c0f99 100644
--- a/packages/backend/src/server/api/endpoints/notes/conversation.ts
+++ b/packages/backend/src/server/api/endpoints/notes/conversation.ts
@@ -1,32 +1,14 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { getNote } from '../../common/getters';
-import { Note } from '@/models/entities/note';
-import { Notes } from '@/models/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { getNote } from '../../common/getters.js';
+import { Note } from '@/models/entities/note.js';
+import { Notes } from '@/models/index.js';
export const meta = {
tags: ['notes'],
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;
+export 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;
}
diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts
index 4efa76b24..e4a9b2889 100644
--- a/packages/backend/src/server/api/endpoints/notes/create.ts
+++ b/packages/backend/src/server/api/endpoints/notes/create.ts
@@ -1,26 +1,14 @@
-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';
-import { Note } from '@/models/entities/note';
-import { DB_MAX_NOTE_TEXT_LENGTH } from '@/misc/hard-limits';
-import { noteVisibilities } from '../../../../types';
-import { Channel } from '@/models/entities/channel';
-
-let maxNoteTextLength = 500;
-
-setInterval(() => {
- fetchMeta().then(m => {
- maxNoteTextLength = m.maxNoteTextLength;
- });
-}, 3000);
+import create from '@/services/note/create.js';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { User } from '@/models/entities/user.js';
+import { Users, DriveFiles, Notes, Channels, Blockings } from '@/models/index.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { Note } from '@/models/entities/note.js';
+import { noteVisibilities } from '../../../../types.js';
+import { Channel } from '@/models/entities/channel.js';
+import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
export const meta = {
tags: ['notes'],
@@ -34,84 +22,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 +85,49 @@ export const meta = {
},
} as const;
+export 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: MAX_NOTE_TEXT_LENGTH, 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))))
diff --git a/packages/backend/src/server/api/endpoints/notes/delete.ts b/packages/backend/src/server/api/endpoints/notes/delete.ts
index 9e080d9e9..22ff2275c 100644
--- a/packages/backend/src/server/api/endpoints/notes/delete.ts
+++ b/packages/backend/src/server/api/endpoints/notes/delete.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import deleteNote from '@/services/note/delete';
-import define from '../../define';
+import deleteNote from '@/services/note/delete.js';
+import define from '../../define.js';
import ms from 'ms';
-import { getNote } from '../../common/getters';
-import { ApiError } from '../../error';
-import { Users } from '@/models/index';
+import { getNote } from '../../common/getters.js';
+import { ApiError } from '../../error.js';
+import { Users } from '@/models/index.js';
export const meta = {
tags: ['notes'],
@@ -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;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/notes/favorites/create.ts b/packages/backend/src/server/api/endpoints/notes/favorites/create.ts
index 78da6a3b0..bcc2c44c0 100644
--- a/packages/backend/src/server/api/endpoints/notes/favorites/create.ts
+++ b/packages/backend/src/server/api/endpoints/notes/favorites/create.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getNote } from '../../../common/getters';
-import { NoteFavorites } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getNote } from '../../../common/getters.js';
+import { NoteFavorites } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
tags: ['notes', 'favorites'],
@@ -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;
+export 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);
diff --git a/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts b/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts
index 3f3d50f0d..d41fab22d 100644
--- a/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts
+++ b/packages/backend/src/server/api/endpoints/notes/favorites/delete.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getNote } from '../../../common/getters';
-import { NoteFavorites } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getNote } from '../../../common/getters.js';
+import { NoteFavorites } from '@/models/index.js';
export const meta = {
tags: ['notes', 'favorites'],
@@ -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;
+export 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);
diff --git a/packages/backend/src/server/api/endpoints/notes/featured.ts b/packages/backend/src/server/api/endpoints/notes/featured.ts
index 5a47fb9e0..6308d2369 100644
--- a/packages/backend/src/server/api/endpoints/notes/featured.ts
+++ b/packages/backend/src/server/api/endpoints/notes/featured.ts
@@ -1,26 +1,13 @@
-import $ from 'cafy';
-import define from '../../define';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { Notes } from '@/models/index';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
+import define from '../../define.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { Notes } from '@/models/index.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
export const meta = {
tags: ['notes'],
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;
+export 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日前まで
@@ -44,10 +40,16 @@ export default define(meta, async (ps, user) => {
.andWhere(`note.createdAt > :date`, { date: new Date(Date.now() - day) })
.andWhere(`note.visibility = 'public'`)
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
if (user) generateMutedUserQuery(query, user);
if (user) generateBlockedUserQuery(query, user);
diff --git a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
index cdd110994..26aaa0919 100644
--- a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
@@ -1,47 +1,18 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { ApiError } from '../../error';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { Notes } from '@/models/index';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query';
-import { activeUsersChart } from '@/services/chart/index';
-import { generateRepliesQuery } from '../../common/generate-replies-query';
-import { generateMutedNoteQuery } from '../../common/generate-muted-note-query';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
+import define from '../../define.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { ApiError } from '../../error.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { Notes } from '@/models/index.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js';
+import { activeUsersChart } from '@/services/chart/index.js';
+import { generateRepliesQuery } from '../../common/generate-replies-query.js';
+import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
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;
+export 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)) {
@@ -76,10 +60,16 @@ export default define(meta, async (ps, user) => {
.andWhere('note.visibility = \'public\'')
.andWhere('note.channelId IS NULL')
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateRepliesQuery(query, user);
if (user) generateMutedUserQuery(query, user);
@@ -92,7 +82,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) {
diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts
index b43849102..9bcb64b65 100644
--- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts
@@ -1,67 +1,23 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { ApiError } from '../../error';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { Followings, Notes } from '@/models/index';
+import define from '../../define.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { ApiError } from '../../error.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { Followings, Notes } from '@/models/index.js';
import { Brackets } from 'typeorm';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query';
-import { activeUsersChart } from '@/services/chart/index';
-import { generateRepliesQuery } from '../../common/generate-replies-query';
-import { generateMutedNoteQuery } from '../../common/generate-muted-note-query';
-import { generateChannelQuery } from '../../common/generate-channel-query';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js';
+import { activeUsersChart } from '@/services/chart/index.js';
+import { generateRepliesQuery } from '../../common/generate-replies-query.js';
+import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
+import { generateChannelQuery } from '../../common/generate-channel-query.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
export const meta = {
tags: ['notes'],
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;
+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' },
+ 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);
@@ -100,10 +72,16 @@ export default define(meta, async (ps, user) => {
.orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)');
}))
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
.leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner')
.setParameters(followingQuery.getParameters());
generateChannelQuery(query, user);
@@ -149,7 +127,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) {
diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
index ce0bcbeb7..12fc88b1f 100644
--- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
@@ -1,58 +1,20 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { ApiError } from '../../error';
-import { Notes } from '@/models/index';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
-import { activeUsersChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { ApiError } from '../../error.js';
+import { Notes } from '@/models/index.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { activeUsersChart } from '@/services/chart/index.js';
import { Brackets } from 'typeorm';
-import { generateRepliesQuery } from '../../common/generate-replies-query';
-import { generateMutedNoteQuery } from '../../common/generate-muted-note-query';
-import { generateChannelQuery } from '../../common/generate-channel-query';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
+import { generateRepliesQuery } from '../../common/generate-replies-query.js';
+import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
+import { generateChannelQuery } from '../../common/generate-channel-query.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
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;
+export 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)) {
@@ -86,10 +65,16 @@ export default define(meta, async (ps, user) => {
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)')
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateChannelQuery(query, user);
generateRepliesQuery(query, user);
@@ -118,7 +103,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) {
diff --git a/packages/backend/src/server/api/endpoints/notes/mentions.ts b/packages/backend/src/server/api/endpoints/notes/mentions.ts
index 81b384436..eafbba322 100644
--- a/packages/backend/src/server/api/endpoints/notes/mentions.ts
+++ b/packages/backend/src/server/api/endpoints/notes/mentions.ts
@@ -1,44 +1,18 @@
-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';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import read from '@/services/note/read.js';
+import { Notes, Followings } from '@/models/index.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { Brackets } from 'typeorm';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
-import { generateMutedNoteThreadQuery } from '../../common/generate-muted-note-thread-query';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
+import { generateMutedNoteThreadQuery } from '../../common/generate-muted-note-thread-query.js';
export const meta = {
tags: ['notes'],
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;
+export 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 });
@@ -62,10 +48,16 @@ export default define(meta, async (ps, user) => {
.orWhere(`'{"${user.id}"}' <@ note.visibleUserIds`);
}))
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, user);
generateMutedUserQuery(query, user);
@@ -81,7 +73,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);
diff --git a/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts b/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts
index 79b558e65..bdd1aeecd 100644
--- a/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts
+++ b/packages/backend/src/server/api/endpoints/notes/polls/recommendation.ts
@@ -1,6 +1,5 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { Polls, Mutings, Notes, PollVotes } from '@/models/index';
+import define from '../../../define.js';
+import { Polls, Mutings, Notes, PollVotes } from '@/models/index.js';
import { Brackets, In } from 'typeorm';
export const meta = {
@@ -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;
+export 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 [];
diff --git a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts
index 77387cacb..ef52d0366 100644
--- a/packages/backend/src/server/api/endpoints/notes/polls/vote.ts
+++ b/packages/backend/src/server/api/endpoints/notes/polls/vote.ts
@@ -1,18 +1,16 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { publishNoteStream } from '@/services/stream';
-import { createNotification } from '@/services/create-notification';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getNote } from '../../../common/getters';
-import { deliver } from '@/queue/index';
-import { renderActivity } from '@/remote/activitypub/renderer/index';
-import renderVote from '@/remote/activitypub/renderer/vote';
-import { deliverQuestionUpdate } from '@/services/note/polls/update';
-import { PollVotes, NoteWatchings, Users, Polls, Blockings } from '@/models/index';
+import { publishNoteStream } from '@/services/stream.js';
+import { createNotification } from '@/services/create-notification.js';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getNote } from '../../../common/getters.js';
+import { deliver } from '@/queue/index.js';
+import { renderActivity } from '@/remote/activitypub/renderer/index.js';
+import renderVote from '@/remote/activitypub/renderer/vote.js';
+import { deliverQuestionUpdate } from '@/services/note/polls/update.js';
+import { PollVotes, NoteWatchings, Users, Polls, Blockings } from '@/models/index.js';
import { Not } from 'typeorm';
-import { IRemoteUser } from '@/models/entities/user';
-import { genId } from '@/misc/gen-id';
+import { IRemoteUser } from '@/models/entities/user.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
tags: ['notes'],
@@ -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;
+export 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
diff --git a/packages/backend/src/server/api/endpoints/notes/reactions.ts b/packages/backend/src/server/api/endpoints/notes/reactions.ts
index 5205a7817..43e5d1ef6 100644
--- a/packages/backend/src/server/api/endpoints/notes/reactions.ts
+++ b/packages/backend/src/server/api/endpoints/notes/reactions.ts
@@ -1,45 +1,15 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { getNote } from '../../common/getters';
-import { ApiError } from '../../error';
-import { NoteReactions } from '@/models/index';
+import define from '../../define.js';
+import { getNote } from '../../common/getters.js';
+import { ApiError } from '../../error.js';
+import { NoteReactions } from '@/models/index.js';
import { DeepPartial } from 'typeorm';
-import { NoteReaction } from '@/models/entities/note-reaction';
+import { NoteReaction } from '@/models/entities/note-reaction.js';
export const meta = {
tags: ['notes', 'reactions'],
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;
+export 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,11 +63,12 @@ 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,
},
+ relations: ['user', 'user.avatar', 'user.banner', 'note'],
});
return await Promise.all(reactions.map(reaction => NoteReactions.pack(reaction, user)));
diff --git a/packages/backend/src/server/api/endpoints/notes/reactions/create.ts b/packages/backend/src/server/api/endpoints/notes/reactions/create.ts
index 1b42781ce..07e52a926 100644
--- a/packages/backend/src/server/api/endpoints/notes/reactions/create.ts
+++ b/packages/backend/src/server/api/endpoints/notes/reactions/create.ts
@@ -1,9 +1,7 @@
-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';
-import { ApiError } from '../../../error';
+import createReaction from '@/services/note/reaction/create.js';
+import define from '../../../define.js';
+import { getNote } from '../../../common/getters.js';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['reactions', 'notes'],
@@ -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;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts b/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts
index 1d686b597..639ecae26 100644
--- a/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts
+++ b/packages/backend/src/server/api/endpoints/notes/reactions/delete.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
+import define from '../../../define.js';
import ms from 'ms';
-import deleteReaction from '@/services/note/reaction/delete';
-import { getNote } from '../../../common/getters';
-import { ApiError } from '../../../error';
+import deleteReaction from '@/services/note/reaction/delete.js';
+import { getNote } from '../../../common/getters.js';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['reactions', 'notes'],
@@ -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;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/notes/renotes.ts b/packages/backend/src/server/api/endpoints/notes/renotes.ts
index f71d23146..87c855a5e 100644
--- a/packages/backend/src/server/api/endpoints/notes/renotes.ts
+++ b/packages/backend/src/server/api/endpoints/notes/renotes.ts
@@ -1,38 +1,17 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { getNote } from '../../common/getters';
-import { ApiError } from '../../error';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { Notes } from '@/models/index';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
+import define from '../../define.js';
+import { getNote } from '../../common/getters.js';
+import { ApiError } from '../../error.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { Notes } from '@/models/index.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
export const meta = {
tags: ['notes'],
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;
+export 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;
@@ -62,16 +52,22 @@ export default define(meta, async (ps, user) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(`note.renoteId = :renoteId`, { renoteId: note.id })
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, 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);
});
diff --git a/packages/backend/src/server/api/endpoints/notes/replies.ts b/packages/backend/src/server/api/endpoints/notes/replies.ts
index 62c56534e..3053eabe3 100644
--- a/packages/backend/src/server/api/endpoints/notes/replies.ts
+++ b/packages/backend/src/server/api/endpoints/notes/replies.ts
@@ -1,36 +1,15 @@
-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';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
+import define from '../../define.js';
+import { Notes } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
export const meta = {
tags: ['notes'],
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,21 +21,38 @@ export const meta = {
},
} as const;
+export 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')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, 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);
});
diff --git a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts
index 87eaffe2f..c6503eb05 100644
--- a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts
+++ b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts
@@ -1,60 +1,16 @@
-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';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
+import define from '../../define.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { Notes } from '@/models/index.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { Brackets } from 'typeorm';
-import { safeForSql } from '@/misc/safe-for-sql';
-import { normalizeForSearch } from '@/misc/normalize-for-search';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
+import { safeForSql } from '@/misc/safe-for-sql.js';
+import { normalizeForSearch } from '@/misc/normalize-for-search.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
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,14 +22,40 @@ export const meta = {
},
} as const;
+export 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('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, me);
if (me) generateMutedUserQuery(query, me);
@@ -129,7 +111,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);
});
diff --git a/packages/backend/src/server/api/endpoints/notes/search.ts b/packages/backend/src/server/api/endpoints/notes/search.ts
index e75212b14..e77892b15 100644
--- a/packages/backend/src/server/api/endpoints/notes/search.ts
+++ b/packages/backend/src/server/api/endpoints/notes/search.ts
@@ -1,54 +1,18 @@
-import $ from 'cafy';
-import es from '../../../../db/elasticsearch';
-import define from '../../define';
-import { Notes } from '@/models/index';
+import es from '../../../../db/elasticsearch.js';
+import define from '../../define.js';
+import { Notes } from '@/models/index.js';
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';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
+import config from '@/config/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
export const meta = {
tags: ['notes'],
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;
+export 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);
@@ -77,16 +56,22 @@ export default define(meta, async (ps, me) => {
query
.andWhere('note.text ILIKE :q', { q: `%${ps.query}%` })
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, 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 +100,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: {
diff --git a/packages/backend/src/server/api/endpoints/notes/show.ts b/packages/backend/src/server/api/endpoints/notes/show.ts
index feb94be1a..d6692923c 100644
--- a/packages/backend/src/server/api/endpoints/notes/show.ts
+++ b/packages/backend/src/server/api/endpoints/notes/show.ts
@@ -1,21 +1,13 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { getNote } from '../../common/getters';
-import { ApiError } from '../../error';
-import { Notes } from '@/models/index';
+import define from '../../define.js';
+import { getNote } from '../../common/getters.js';
+import { ApiError } from '../../error.js';
+import { Notes } from '@/models/index.js';
export const meta = {
tags: ['notes'],
requireCredential: false,
- params: {
- noteId: {
- validator: $.type(ID),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -31,8 +23,16 @@ export const meta = {
},
} as const;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/notes/state.ts b/packages/backend/src/server/api/endpoints/notes/state.ts
index c3e9090bb..6fdb8e88f 100644
--- a/packages/backend/src/server/api/endpoints/notes/state.ts
+++ b/packages/backend/src/server/api/endpoints/notes/state.ts
@@ -1,19 +1,11 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { NoteFavorites, Notes, NoteThreadMutings, NoteWatchings } from '@/models/index';
+import define from '../../define.js';
+import { NoteFavorites, Notes, NoteThreadMutings, NoteWatchings } from '@/models/index.js';
export const meta = {
tags: ['notes'],
requireCredential: true,
- params: {
- noteId: {
- validator: $.type(ID),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -34,8 +26,16 @@ export const meta = {
},
} as const;
+export 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([
diff --git a/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts b/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts
index a8b50d90f..e48a2cf57 100644
--- a/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts
+++ b/packages/backend/src/server/api/endpoints/notes/thread-muting/create.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { getNote } from '../../../common/getters';
-import { ApiError } from '../../../error';
-import { Notes, NoteThreadMutings } from '@/models';
-import { genId } from '@/misc/gen-id';
-import readNote from '@/services/note/read';
+import define from '../../../define.js';
+import { getNote } from '../../../common/getters.js';
+import { ApiError } from '../../../error.js';
+import { Notes, NoteThreadMutings } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import readNote from '@/services/note/read.js';
export const meta = {
tags: ['notes'],
@@ -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;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts b/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts
index f76b526ce..4fb3137a5 100644
--- a/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts
+++ b/packages/backend/src/server/api/endpoints/notes/thread-muting/delete.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { getNote } from '../../../common/getters';
-import { ApiError } from '../../../error';
-import { NoteThreadMutings } from '@/models';
+import define from '../../../define.js';
+import { getNote } from '../../../common/getters.js';
+import { ApiError } from '../../../error.js';
+import { NoteThreadMutings } from '@/models/index.js';
export const meta = {
tags: ['notes'],
@@ -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;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts
index f8cd08324..fde66b241 100644
--- a/packages/backend/src/server/api/endpoints/notes/timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts
@@ -1,65 +1,21 @@
-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';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
-import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query';
-import { activeUsersChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { Notes, Followings } from '@/models/index.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
+import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js';
+import { activeUsersChart } from '@/services/chart/index.js';
import { Brackets } from 'typeorm';
-import { generateRepliesQuery } from '../../common/generate-replies-query';
-import { generateMutedNoteQuery } from '../../common/generate-muted-note-query';
-import { generateChannelQuery } from '../../common/generate-channel-query';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
+import { generateRepliesQuery } from '../../common/generate-replies-query.js';
+import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
+import { generateChannelQuery } from '../../common/generate-channel-query.js';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
export const meta = {
tags: ['notes'],
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;
+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' },
+ 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,
@@ -92,10 +64,16 @@ export default define(meta, async (ps, user) => {
if (hasFollowing) qb.orWhere(`note.userId IN (${ followingQuery.getQuery() })`);
}))
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
.leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner')
.setParameters(followingQuery.getParameters());
generateChannelQuery(query, user);
@@ -141,7 +119,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) {
diff --git a/packages/backend/src/server/api/endpoints/notes/translate.ts b/packages/backend/src/server/api/endpoints/notes/translate.ts
index ed069cb75..068df6940 100644
--- a/packages/backend/src/server/api/endpoints/notes/translate.ts
+++ b/packages/backend/src/server/api/endpoints/notes/translate.ts
@@ -1,29 +1,18 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { getNote } from '../../common/getters';
-import { ApiError } from '../../error';
+import define from '../../define.js';
+import { getNote } from '../../common/getters.js';
+import { ApiError } from '../../error.js';
import fetch from 'node-fetch';
-import config from '@/config/index';
-import { getAgentByUrl } from '@/misc/fetch';
-import { URLSearchParams } from 'url';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { Notes } from '@/models';
+import config from '@/config/index.js';
+import { getAgentByUrl } from '@/misc/fetch.js';
+import { URLSearchParams } from 'node:url';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { Notes } from '@/models/index.js';
export const meta = {
tags: ['notes'],
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;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/notes/unrenote.ts b/packages/backend/src/server/api/endpoints/notes/unrenote.ts
index 8db543d32..a9aadba33 100644
--- a/packages/backend/src/server/api/endpoints/notes/unrenote.ts
+++ b/packages/backend/src/server/api/endpoints/notes/unrenote.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import deleteNote from '@/services/note/delete';
-import define from '../../define';
+import deleteNote from '@/services/note/delete.js';
+import define from '../../define.js';
import ms from 'ms';
-import { getNote } from '../../common/getters';
-import { ApiError } from '../../error';
-import { Notes, Users } from '@/models/index';
+import { getNote } from '../../common/getters.js';
+import { ApiError } from '../../error.js';
+import { Notes, Users } from '@/models/index.js';
export const meta = {
tags: ['notes'],
@@ -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;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
index 3512fb363..0829d0e4c 100644
--- a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { UserLists, UserListJoinings, Notes } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
-import { activeUsersChart } from '@/services/chart/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { UserLists, UserListJoinings, Notes } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { activeUsersChart } from '@/services/chart/index.js';
import { Brackets } from 'typeorm';
export const meta = {
@@ -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;
+export 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,
@@ -97,10 +66,16 @@ export default define(meta, async (ps, user) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(`note.userId IN (${ listQuery.getQuery() })`)
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
.leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner')
.setParameters(listQuery.getParameters());
generateVisibilityQuery(query, user);
@@ -140,7 +115,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);
diff --git a/packages/backend/src/server/api/endpoints/notes/watching/create.ts b/packages/backend/src/server/api/endpoints/notes/watching/create.ts
index 6433c6bc2..8fdf84624 100644
--- a/packages/backend/src/server/api/endpoints/notes/watching/create.ts
+++ b/packages/backend/src/server/api/endpoints/notes/watching/create.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import watch from '@/services/note/watch';
-import { getNote } from '../../../common/getters';
-import { ApiError } from '../../../error';
+import define from '../../../define.js';
+import watch from '@/services/note/watch.js';
+import { getNote } from '../../../common/getters.js';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['notes'],
@@ -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;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/notes/watching/delete.ts b/packages/backend/src/server/api/endpoints/notes/watching/delete.ts
index 3e9faa2b2..d58f09797 100644
--- a/packages/backend/src/server/api/endpoints/notes/watching/delete.ts
+++ b/packages/backend/src/server/api/endpoints/notes/watching/delete.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import unwatch from '@/services/note/unwatch';
-import { getNote } from '../../../common/getters';
-import { ApiError } from '../../../error';
+import define from '../../../define.js';
+import unwatch from '@/services/note/unwatch.js';
+import { getNote } from '../../../common/getters.js';
+import { ApiError } from '../../../error.js';
export const meta = {
tags: ['notes'],
@@ -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;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/notifications/create.ts b/packages/backend/src/server/api/endpoints/notifications/create.ts
index bd8a7ba1b..b339c8723 100644
--- a/packages/backend/src/server/api/endpoints/notifications/create.ts
+++ b/packages/backend/src/server/api/endpoints/notifications/create.ts
@@ -1,6 +1,5 @@
-import $ from 'cafy';
-import define from '../../define';
-import { createNotification } from '@/services/create-notification';
+import define from '../../define.js';
+import { createNotification } from '@/services/create-notification.js';
export const meta = {
tags: ['notifications'],
@@ -9,26 +8,22 @@ export const meta = {
kind: 'write:notifications',
- params: {
- body: {
- validator: $.str,
- },
-
- header: {
- validator: $.optional.nullable.str,
- },
-
- icon: {
- validator: $.optional.nullable.str,
- },
- },
-
errors: {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ body: { type: 'string' },
+ header: { type: 'string', nullable: true },
+ icon: { type: 'string', nullable: true },
+ },
+ required: ['body'],
+} as const;
+
// 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) => {
createNotification(user.id, 'app', {
appAccessTokenId: token ? token.id : null,
customBody: ps.body,
diff --git a/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts b/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts
index 4cec38a95..abefe07be 100644
--- a/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts
+++ b/packages/backend/src/server/api/endpoints/notifications/mark-all-as-read.ts
@@ -1,6 +1,6 @@
-import { publishMainStream } from '@/services/stream';
-import define from '../../define';
-import { Notifications } from '@/models/index';
+import { publishMainStream } from '@/services/stream.js';
+import define from '../../define.js';
+import { Notifications } from '@/models/index.js';
export const meta = {
tags: ['notifications', 'account'],
@@ -10,8 +10,14 @@ export const meta = {
kind: 'write:notifications',
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
// Update documents
await Notifications.update({
notifieeId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/notifications/read.ts b/packages/backend/src/server/api/endpoints/notifications/read.ts
index 7e23bc234..34f4c155f 100644
--- a/packages/backend/src/server/api/endpoints/notifications/read.ts
+++ b/packages/backend/src/server/api/endpoints/notifications/read.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { publishMainStream } from '@/services/stream';
-import define from '../../define';
-import { Notifications } from '@/models/index';
-import { readNotification } from '../../common/read-notification';
-import { ApiError } from '../../error';
+import { publishMainStream } from '@/services/stream.js';
+import define from '../../define.js';
+import { Notifications } from '@/models/index.js';
+import { readNotification } from '../../common/read-notification.js';
+import { ApiError } from '../../error.js';
export const meta = {
tags: ['notifications', 'account'],
@@ -13,12 +11,6 @@ export const meta = {
kind: 'write:notifications',
- params: {
- notificationId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchNotification: {
message: 'No such notification.',
@@ -28,8 +20,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ notificationId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['notificationId'],
+} 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 notification = await Notifications.findOne({
notifieeId: user.id,
id: ps.notificationId,
diff --git a/packages/backend/src/server/api/endpoints/page-push.ts b/packages/backend/src/server/api/endpoints/page-push.ts
index 61c0160f8..acaa11847 100644
--- a/packages/backend/src/server/api/endpoints/page-push.ts
+++ b/packages/backend/src/server/api/endpoints/page-push.ts
@@ -1,28 +1,12 @@
-import $ from 'cafy';
-import define from '../define';
-import { ID } from '@/misc/cafy-id';
-import { publishMainStream } from '@/services/stream';
-import { Users, Pages } from '@/models/index';
-import { ApiError } from '../error';
+import define from '../define.js';
+import { publishMainStream } from '@/services/stream.js';
+import { Users, Pages } from '@/models/index.js';
+import { ApiError } from '../error.js';
export const meta = {
requireCredential: true,
secure: true,
- params: {
- pageId: {
- validator: $.type(ID),
- },
-
- event: {
- validator: $.str,
- },
-
- var: {
- validator: $.optional.nullable.any,
- },
- },
-
errors: {
noSuchPage: {
message: 'No such page.',
@@ -32,8 +16,18 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ pageId: { type: 'string', format: 'misskey:id' },
+ event: { type: 'string' },
+ var: {},
+ },
+ required: ['pageId', 'event'],
+} 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 page = await Pages.findOne(ps.pageId);
if (page == null) {
throw new ApiError(meta.errors.noSuchPage);
diff --git a/packages/backend/src/server/api/endpoints/pages/create.ts b/packages/backend/src/server/api/endpoints/pages/create.ts
index 7ee50fbdf..7cac53060 100644
--- a/packages/backend/src/server/api/endpoints/pages/create.ts
+++ b/packages/backend/src/server/api/endpoints/pages/create.ts
@@ -1,11 +1,9 @@
-import $ from 'cafy';
import ms from 'ms';
-import define from '../../define';
-import { ID } from '@/misc/cafy-id';
-import { Pages, DriveFiles } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { Page } from '@/models/entities/page';
-import { ApiError } from '../../error';
+import define from '../../define.js';
+import { Pages, DriveFiles } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { Page } from '@/models/entities/page.js';
+import { ApiError } from '../../error.js';
export const meta = {
tags: ['pages'],
@@ -19,51 +17,6 @@ export const meta = {
max: 300,
},
- params: {
- title: {
- validator: $.str,
- },
-
- name: {
- validator: $.str.min(1),
- },
-
- summary: {
- validator: $.optional.nullable.str,
- },
-
- content: {
- validator: $.arr($.obj()),
- },
-
- variables: {
- validator: $.arr($.obj()),
- },
-
- script: {
- validator: $.str,
- },
-
- eyeCatchingImageId: {
- validator: $.optional.nullable.type(ID),
- },
-
- font: {
- validator: $.optional.str.or(['serif', 'sans-serif']),
- default: 'sans-serif',
- },
-
- alignCenter: {
- validator: $.optional.bool,
- default: false,
- },
-
- hideTitleWhenPinned: {
- validator: $.optional.bool,
- default: false,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -84,8 +37,29 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ title: { type: 'string' },
+ name: { type: 'string', minLength: 1 },
+ summary: { type: 'string', nullable: true },
+ content: { type: 'array', items: {
+ type: 'object', additionalProperties: true,
+ } },
+ variables: { type: 'array', items: {
+ type: 'object', additionalProperties: true,
+ } },
+ script: { type: 'string' },
+ eyeCatchingImageId: { type: 'string', format: 'misskey:id', nullable: true },
+ font: { type: 'string', enum: ['serif', 'sans-serif'], default: "sans-serif" },
+ alignCenter: { type: 'boolean', default: false },
+ hideTitleWhenPinned: { type: 'boolean', default: false },
+ },
+ required: ['title', 'name', 'content', 'variables', 'script'],
+} 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 eyeCatchingImage = null;
if (ps.eyeCatchingImageId != null) {
eyeCatchingImage = await DriveFiles.findOne({
diff --git a/packages/backend/src/server/api/endpoints/pages/delete.ts b/packages/backend/src/server/api/endpoints/pages/delete.ts
index aeda823e5..ddf691f53 100644
--- a/packages/backend/src/server/api/endpoints/pages/delete.ts
+++ b/packages/backend/src/server/api/endpoints/pages/delete.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Pages } from '@/models/index';
-import { ID } from '@/misc/cafy-id';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Pages } from '@/models/index.js';
export const meta = {
tags: ['pages'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'write:pages',
- params: {
- pageId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchPage: {
message: 'No such page.',
@@ -32,8 +24,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ pageId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['pageId'],
+} 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 page = await Pages.findOne(ps.pageId);
if (page == null) {
throw new ApiError(meta.errors.noSuchPage);
diff --git a/packages/backend/src/server/api/endpoints/pages/featured.ts b/packages/backend/src/server/api/endpoints/pages/featured.ts
index 7f0d58b35..eeb6d509c 100644
--- a/packages/backend/src/server/api/endpoints/pages/featured.ts
+++ b/packages/backend/src/server/api/endpoints/pages/featured.ts
@@ -1,5 +1,5 @@
-import define from '../../define';
-import { Pages } from '@/models/index';
+import define from '../../define.js';
+import { Pages } from '@/models/index.js';
export const meta = {
tags: ['pages'],
@@ -17,8 +17,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 = Pages.createQueryBuilder('page')
.where('page.visibility = \'public\'')
.andWhere('page.likedCount > 0')
diff --git a/packages/backend/src/server/api/endpoints/pages/like.ts b/packages/backend/src/server/api/endpoints/pages/like.ts
index c479f637a..cab78e576 100644
--- a/packages/backend/src/server/api/endpoints/pages/like.ts
+++ b/packages/backend/src/server/api/endpoints/pages/like.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Pages, PageLikes } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Pages, PageLikes } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
tags: ['pages'],
@@ -12,12 +10,6 @@ export const meta = {
kind: 'write:page-likes',
- params: {
- pageId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchPage: {
message: 'No such page.',
@@ -39,8 +31,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ pageId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['pageId'],
+} 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 page = await Pages.findOne(ps.pageId);
if (page == null) {
throw new ApiError(meta.errors.noSuchPage);
diff --git a/packages/backend/src/server/api/endpoints/pages/show.ts b/packages/backend/src/server/api/endpoints/pages/show.ts
index 5cda5386d..4e3facae5 100644
--- a/packages/backend/src/server/api/endpoints/pages/show.ts
+++ b/packages/backend/src/server/api/endpoints/pages/show.ts
@@ -1,29 +1,13 @@
-import $ from 'cafy';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Pages, Users } from '@/models/index';
-import { ID } from '@/misc/cafy-id';
-import { Page } from '@/models/entities/page';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Pages, Users } from '@/models/index.js';
+import { Page } from '@/models/entities/page.js';
export const meta = {
tags: ['pages'],
requireCredential: false,
- params: {
- pageId: {
- validator: $.optional.type(ID),
- },
-
- name: {
- validator: $.optional.str,
- },
-
- username: {
- validator: $.optional.str,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -39,8 +23,18 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ pageId: { type: 'string', format: 'misskey:id' },
+ name: { type: 'string' },
+ username: { 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) => {
let page: Page | undefined;
if (ps.pageId) {
diff --git a/packages/backend/src/server/api/endpoints/pages/unlike.ts b/packages/backend/src/server/api/endpoints/pages/unlike.ts
index cca5e5b5a..31cd1a335 100644
--- a/packages/backend/src/server/api/endpoints/pages/unlike.ts
+++ b/packages/backend/src/server/api/endpoints/pages/unlike.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Pages, PageLikes } from '@/models/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Pages, PageLikes } from '@/models/index.js';
export const meta = {
tags: ['pages'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'write:page-likes',
- params: {
- pageId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchPage: {
message: 'No such page.',
@@ -32,8 +24,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ pageId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['pageId'],
+} 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 page = await Pages.findOne(ps.pageId);
if (page == null) {
throw new ApiError(meta.errors.noSuchPage);
diff --git a/packages/backend/src/server/api/endpoints/pages/update.ts b/packages/backend/src/server/api/endpoints/pages/update.ts
index 991085ee0..24c8f467e 100644
--- a/packages/backend/src/server/api/endpoints/pages/update.ts
+++ b/packages/backend/src/server/api/endpoints/pages/update.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
import ms from 'ms';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Pages, DriveFiles } from '@/models/index';
-import { ID } from '@/misc/cafy-id';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Pages, DriveFiles } from '@/models/index.js';
import { Not } from 'typeorm';
export const meta = {
@@ -18,52 +16,6 @@ export const meta = {
max: 300,
},
- params: {
- pageId: {
- validator: $.type(ID),
- },
-
- title: {
- validator: $.str,
- },
-
- name: {
- validator: $.str.min(1),
- },
-
- summary: {
- validator: $.optional.nullable.str,
- },
-
- content: {
- validator: $.arr($.obj()),
- },
-
- variables: {
- validator: $.arr($.obj()),
- },
-
- script: {
- validator: $.str,
- },
-
- eyeCatchingImageId: {
- validator: $.optional.nullable.type(ID),
- },
-
- font: {
- validator: $.optional.str.or(['serif', 'sans-serif']),
- },
-
- alignCenter: {
- validator: $.optional.bool,
- },
-
- hideTitleWhenPinned: {
- validator: $.optional.bool,
- },
- },
-
errors: {
noSuchPage: {
message: 'No such page.',
@@ -90,8 +42,30 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ pageId: { type: 'string', format: 'misskey:id' },
+ title: { type: 'string' },
+ name: { type: 'string', minLength: 1 },
+ summary: { type: 'string', nullable: true },
+ content: { type: 'array', items: {
+ type: 'object', additionalProperties: true,
+ } },
+ variables: { type: 'array', items: {
+ type: 'object', additionalProperties: true,
+ } },
+ script: { type: 'string' },
+ eyeCatchingImageId: { type: 'string', format: 'misskey:id', nullable: true },
+ font: { type: 'string', enum: ['serif', 'sans-serif'] },
+ alignCenter: { type: 'boolean' },
+ hideTitleWhenPinned: { type: 'boolean' },
+ },
+ required: ['pageId', 'title', 'name', 'content', 'variables', 'script'],
+} 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 page = await Pages.findOne(ps.pageId);
if (page == null) {
throw new ApiError(meta.errors.noSuchPage);
diff --git a/packages/backend/src/server/api/endpoints/ping.ts b/packages/backend/src/server/api/endpoints/ping.ts
index 3eab70ae2..2891a0860 100644
--- a/packages/backend/src/server/api/endpoints/ping.ts
+++ b/packages/backend/src/server/api/endpoints/ping.ts
@@ -1,13 +1,10 @@
-import define from '../define';
+import define from '../define.js';
export const meta = {
requireCredential: false,
tags: ['meta'],
- params: {
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -20,8 +17,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async () => {
+export default define(meta, paramDef, async () => {
return {
pong: Date.now(),
};
diff --git a/packages/backend/src/server/api/endpoints/pinned-users.ts b/packages/backend/src/server/api/endpoints/pinned-users.ts
index ff0e22555..1d26ab266 100644
--- a/packages/backend/src/server/api/endpoints/pinned-users.ts
+++ b/packages/backend/src/server/api/endpoints/pinned-users.ts
@@ -1,17 +1,14 @@
-import define from '../define';
-import { Users } from '@/models/index';
-import { fetchMeta } from '@/misc/fetch-meta';
-import * as Acct from 'misskey-js/built/acct';
-import { User } from '@/models/entities/user';
+import define from '../define.js';
+import { Users } from '@/models/index.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import * as Acct from '@/misc/acct.js';
+import { User } from '@/models/entities/user.js';
export const meta = {
tags: ['users'],
requireCredential: false,
- params: {
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -23,8 +20,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 meta = await fetchMeta();
const users = await Promise.all(meta.pinnedUsers.map(acct => Users.findOne(Acct.parse(acct))));
diff --git a/packages/backend/src/server/api/endpoints/promo/read.ts b/packages/backend/src/server/api/endpoints/promo/read.ts
index 8d8c60d75..ea34ca3aa 100644
--- a/packages/backend/src/server/api/endpoints/promo/read.ts
+++ b/packages/backend/src/server/api/endpoints/promo/read.ts
@@ -1,22 +1,14 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { getNote } from '../../common/getters';
-import { PromoReads } from '@/models/index';
-import { genId } from '@/misc/gen-id';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { getNote } from '../../common/getters.js';
+import { PromoReads } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
export const meta = {
tags: ['notes'],
requireCredential: true,
- params: {
- noteId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchNote: {
message: 'No such note.',
@@ -26,8 +18,16 @@ export const meta = {
},
} as const;
+export 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;
diff --git a/packages/backend/src/server/api/endpoints/request-reset-password.ts b/packages/backend/src/server/api/endpoints/request-reset-password.ts
index af1aeb431..18cd98b16 100644
--- a/packages/backend/src/server/api/endpoints/request-reset-password.ts
+++ b/packages/backend/src/server/api/endpoints/request-reset-password.ts
@@ -1,13 +1,12 @@
-import $ from 'cafy';
-import { publishMainStream } from '@/services/stream';
-import define from '../define';
+import { publishMainStream } from '@/services/stream.js';
+import define from '../define.js';
import rndstr from 'rndstr';
-import config from '@/config/index';
+import config from '@/config/index.js';
import ms from 'ms';
-import { Users, UserProfiles, PasswordResetRequests } from '@/models/index';
-import { sendEmail } from '@/services/send-email';
-import { ApiError } from '../error';
-import { genId } from '@/misc/gen-id';
+import { Users, UserProfiles, PasswordResetRequests } from '@/models/index.js';
+import { sendEmail } from '@/services/send-email.js';
+import { ApiError } from '../error.js';
+import { genId } from '@/misc/gen-id.js';
import { IsNull } from 'typeorm';
export const meta = {
@@ -18,23 +17,22 @@ export const meta = {
max: 3,
},
- params: {
- username: {
- validator: $.str,
- },
-
- email: {
- validator: $.str,
- },
- },
-
errors: {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ username: { type: 'string' },
+ email: { type: 'string' },
+ },
+ required: ['username', 'email'],
+} as const;
+
// 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({
usernameLower: ps.username.toLowerCase(),
host: IsNull(),
diff --git a/packages/backend/src/server/api/endpoints/reset-db.ts b/packages/backend/src/server/api/endpoints/reset-db.ts
index e99dc9db1..dbe64e9a1 100644
--- a/packages/backend/src/server/api/endpoints/reset-db.ts
+++ b/packages/backend/src/server/api/endpoints/reset-db.ts
@@ -1,21 +1,23 @@
-import $ from 'cafy';
-import define from '../define';
-import { ApiError } from '../error';
-import { resetDb } from '@/db/postgre';
+import define from '../define.js';
+import { ApiError } from '../error.js';
+import { resetDb } from '@/db/postgre.js';
export const meta = {
requireCredential: false,
- params: {
- },
-
errors: {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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) => {
if (process.env.NODE_ENV !== 'test') throw 'NODE_ENV is not a test';
await resetDb();
diff --git a/packages/backend/src/server/api/endpoints/reset-password.ts b/packages/backend/src/server/api/endpoints/reset-password.ts
index a7366584b..3abf232af 100644
--- a/packages/backend/src/server/api/endpoints/reset-password.ts
+++ b/packages/backend/src/server/api/endpoints/reset-password.ts
@@ -1,30 +1,28 @@
-import $ from 'cafy';
-import * as bcrypt from 'bcryptjs';
-import { publishMainStream } from '@/services/stream';
-import define from '../define';
-import { Users, UserProfiles, PasswordResetRequests } from '@/models/index';
-import { ApiError } from '../error';
+import bcrypt from 'bcryptjs';
+import { publishMainStream } from '@/services/stream.js';
+import define from '../define.js';
+import { Users, UserProfiles, PasswordResetRequests } from '@/models/index.js';
+import { ApiError } from '../error.js';
export const meta = {
requireCredential: false,
- params: {
- token: {
- validator: $.str,
- },
-
- password: {
- validator: $.str,
- },
- },
-
errors: {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ token: { type: 'string' },
+ password: { type: 'string' },
+ },
+ required: ['token', 'password'],
+} 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 req = await PasswordResetRequests.findOneOrFail({
token: ps.token,
});
diff --git a/packages/backend/src/server/api/endpoints/server-info.ts b/packages/backend/src/server/api/endpoints/server-info.ts
index 1ad2c54ab..99f3730e9 100644
--- a/packages/backend/src/server/api/endpoints/server-info.ts
+++ b/packages/backend/src/server/api/endpoints/server-info.ts
@@ -1,21 +1,21 @@
-import * as os from 'os';
-import * as si from 'systeminformation';
-import define from '../define';
+import * as os from 'node:os';
+import si from 'systeminformation';
+import define from '../define.js';
export const meta = {
requireCredential: false,
- desc: {
- },
-
tags: ['meta'],
+} as const;
- params: {
- },
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
} as const;
// 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 fsStats = await si.fsSize();
diff --git a/packages/backend/src/server/api/endpoints/stats.ts b/packages/backend/src/server/api/endpoints/stats.ts
index 82b0bb329..92fea4de6 100644
--- a/packages/backend/src/server/api/endpoints/stats.ts
+++ b/packages/backend/src/server/api/endpoints/stats.ts
@@ -1,15 +1,12 @@
-import define from '../define';
-import { Instances, NoteReactions, Notes, Users } from '@/models/index';
-import { } from '@/services/chart/index';
+import define from '../define.js';
+import { Instances, NoteReactions, Notes, Users } from '@/models/index.js';
+import { } from '@/services/chart/index.js';
export const meta = {
requireCredential: false,
tags: ['meta'],
- params: {
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -46,8 +43,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ required: [],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async () => {
+export default define(meta, paramDef, async () => {
const [
notesCount,
originalNotesCount,
diff --git a/packages/backend/src/server/api/endpoints/sw/register.ts b/packages/backend/src/server/api/endpoints/sw/register.ts
index ae3e9ce77..6c7714e19 100644
--- a/packages/backend/src/server/api/endpoints/sw/register.ts
+++ b/packages/backend/src/server/api/endpoints/sw/register.ts
@@ -1,47 +1,42 @@
-import $ from 'cafy';
-import define from '../../define';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { genId } from '@/misc/gen-id';
-import { SwSubscriptions } from '@/models/index';
+import define from '../../define.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { genId } from '@/misc/gen-id.js';
+import { SwSubscriptions } from '@/models/index.js';
export const meta = {
tags: ['account'],
requireCredential: true,
- params: {
- endpoint: {
- validator: $.str,
- },
-
- auth: {
- validator: $.str,
- },
-
- publickey: {
- validator: $.str,
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
properties: {
state: {
type: 'string',
- optional: false, nullable: false,
+ optional: true, nullable: false,
enum: ['already-subscribed', 'subscribed'],
},
key: {
type: 'string',
- optional: false, nullable: false,
+ optional: false, nullable: true,
},
},
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ endpoint: { type: 'string' },
+ auth: { type: 'string' },
+ publickey: { type: 'string' },
+ },
+ required: ['endpoint', 'auth', 'publickey'],
+} 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) => {
// if already subscribed
const exist = await SwSubscriptions.findOne({
userId: user.id,
@@ -54,7 +49,7 @@ export default define(meta, async (ps, user) => {
if (exist != null) {
return {
- state: 'already-subscribed',
+ state: 'already-subscribed' as const,
key: instance.swPublicKey,
};
}
@@ -69,7 +64,7 @@ export default define(meta, async (ps, user) => {
});
return {
- state: 'subscribed',
+ state: 'subscribed' as const,
key: instance.swPublicKey,
};
});
diff --git a/packages/backend/src/server/api/endpoints/sw/unregister.ts b/packages/backend/src/server/api/endpoints/sw/unregister.ts
index 6f569e941..9748f2a22 100644
--- a/packages/backend/src/server/api/endpoints/sw/unregister.ts
+++ b/packages/backend/src/server/api/endpoints/sw/unregister.ts
@@ -1,21 +1,22 @@
-import $ from 'cafy';
-import define from '../../define';
-import { SwSubscriptions } from '../../../../models';
+import define from '../../define.js';
+import { SwSubscriptions } from '@/models/index.js';
export const meta = {
tags: ['account'],
requireCredential: true,
+} as const;
- params: {
- endpoint: {
- validator: $.str,
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ endpoint: { type: 'string' },
},
+ required: ['endpoint'],
} 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) => {
await SwSubscriptions.delete({
userId: user.id,
endpoint: ps.endpoint,
diff --git a/packages/backend/src/server/api/endpoints/test.ts b/packages/backend/src/server/api/endpoints/test.ts
new file mode 100644
index 000000000..256da1a66
--- /dev/null
+++ b/packages/backend/src/server/api/endpoints/test.ts
@@ -0,0 +1,22 @@
+import define from '../define.js';
+
+export const meta = {
+ requireCredential: false,
+} as const;
+
+export const paramDef = {
+ type: 'object',
+ properties: {
+ required: { type: 'boolean' },
+ string: { type: 'string' },
+ default: { type: 'string', default: 'hello' },
+ nullableDefault: { type: 'string', nullable: true, default: 'hello' },
+ id: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['required'],
+} as const;
+
+// eslint-disable-next-line import/no-default-export
+export default define(meta, paramDef, async (ps, me) => {
+ return ps;
+});
diff --git a/packages/backend/src/server/api/endpoints/username/available.ts b/packages/backend/src/server/api/endpoints/username/available.ts
index 74120fc40..5a1c4128a 100644
--- a/packages/backend/src/server/api/endpoints/username/available.ts
+++ b/packages/backend/src/server/api/endpoints/username/available.ts
@@ -1,18 +1,11 @@
-import $ from 'cafy';
-import define from '../../define';
-import { Users, UsedUsernames } from '@/models/index';
+import define from '../../define.js';
+import { Users, UsedUsernames } from '@/models/index.js';
export const meta = {
tags: ['users'],
requireCredential: false,
- params: {
- username: {
- validator: $.use(Users.validateLocalUsername),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -25,8 +18,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ username: Users.localUsernameSchema,
+ },
+ required: ['username'],
+} as const;
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps) => {
+export default define(meta, paramDef, async (ps) => {
// Get exist
const exist = await Users.count({
host: null,
diff --git a/packages/backend/src/server/api/endpoints/users.ts b/packages/backend/src/server/api/endpoints/users.ts
index 6b11ec0f0..10527d15c 100644
--- a/packages/backend/src/server/api/endpoints/users.ts
+++ b/packages/backend/src/server/api/endpoints/users.ts
@@ -1,57 +1,13 @@
-import $ from 'cafy';
-import define from '../define';
-import { Users } from '@/models/index';
-import { generateMutedUserQueryForUsers } from '../common/generate-muted-user-query';
-import { generateBlockQueryForUsers } from '../common/generate-block-query';
+import define from '../define.js';
+import { Users } from '@/models/index.js';
+import { generateMutedUserQueryForUsers } from '../common/generate-muted-user-query.js';
+import { generateBlockQueryForUsers } from '../common/generate-block-query.js';
export const meta = {
tags: ['users'],
requireCredential: false,
- 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',
- 'admin',
- 'moderator',
- 'adminOrModerator',
- 'alive',
- ]),
- default: 'all',
- },
-
- origin: {
- validator: $.optional.str.or([
- 'combined',
- 'local',
- 'remote',
- ]),
- default: 'local',
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -63,8 +19,20 @@ export const meta = {
},
} 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', 'admin', 'moderator', 'adminOrModerator', 'alive'], default: "all" },
+ origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "local" },
+ },
+ 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 = Users.createQueryBuilder('user');
query.where('user.isExplorable = TRUE');
@@ -93,7 +61,7 @@ export default define(meta, async (ps, me) => {
if (me) generateMutedUserQueryForUsers(query, me);
if (me) generateBlockQueryForUsers(query, me);
- query.take(ps.limit!);
+ query.take(ps.limit);
query.skip(ps.offset);
const users = await query.getMany();
diff --git a/packages/backend/src/server/api/endpoints/users/clips.ts b/packages/backend/src/server/api/endpoints/users/clips.ts
index d4152fbf5..424c59474 100644
--- a/packages/backend/src/server/api/endpoints/users/clips.ts
+++ b/packages/backend/src/server/api/endpoints/users/clips.ts
@@ -1,40 +1,30 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Clips } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { Clips } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['users', 'clips'],
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { 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: ['userId'],
} 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(Clips.createQueryBuilder('clip'), ps.sinceId, ps.untilId)
.andWhere(`clip.userId = :userId`, { userId: ps.userId })
.andWhere('clip.isPublic = true');
const clips = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Clips.packMany(clips);
diff --git a/packages/backend/src/server/api/endpoints/users/followers.ts b/packages/backend/src/server/api/endpoints/users/followers.ts
index 6214ab40b..1e104b6bc 100644
--- a/packages/backend/src/server/api/endpoints/users/followers.ts
+++ b/packages/backend/src/server/api/endpoints/users/followers.ts
@@ -1,43 +1,14 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Users, Followings, UserProfiles } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { toPunyNullable } from '@/misc/convert-host';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Users, Followings, UserProfiles } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { toPunyNullable } from '@/misc/convert-host.js';
export const meta = {
tags: ['users'],
requireCredential: false,
- params: {
- userId: {
- validator: $.optional.type(ID),
- },
-
- username: {
- validator: $.optional.str,
- },
-
- host: {
- validator: $.optional.nullable.str,
- },
-
- 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,
@@ -63,8 +34,21 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
+ username: { type: 'string' },
+ host: { type: 'string', nullable: true },
+ 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 user = await Users.findOne(ps.userId != null
? { id: ps.userId }
: { usernameLower: ps.username!.toLowerCase(), host: toPunyNullable(ps.host) });
@@ -98,7 +82,7 @@ export default define(meta, async (ps, me) => {
.innerJoinAndSelect('following.follower', 'follower');
const followings = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Followings.packMany(followings, me, { populateFollower: true });
diff --git a/packages/backend/src/server/api/endpoints/users/following.ts b/packages/backend/src/server/api/endpoints/users/following.ts
index 76112eab2..b0a1036c7 100644
--- a/packages/backend/src/server/api/endpoints/users/following.ts
+++ b/packages/backend/src/server/api/endpoints/users/following.ts
@@ -1,43 +1,14 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { Users, Followings, UserProfiles } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { toPunyNullable } from '@/misc/convert-host';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { Users, Followings, UserProfiles } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { toPunyNullable } from '@/misc/convert-host.js';
export const meta = {
tags: ['users'],
requireCredential: false,
- params: {
- userId: {
- validator: $.optional.type(ID),
- },
-
- username: {
- validator: $.optional.str,
- },
-
- host: {
- validator: $.optional.nullable.str,
- },
-
- 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,
@@ -63,8 +34,21 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
+ username: { type: 'string' },
+ host: { type: 'string', nullable: true },
+ 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 user = await Users.findOne(ps.userId != null
? { id: ps.userId }
: { usernameLower: ps.username!.toLowerCase(), host: toPunyNullable(ps.host) });
@@ -98,7 +82,7 @@ export default define(meta, async (ps, me) => {
.innerJoinAndSelect('following.followee', 'followee');
const followings = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Followings.packMany(followings, me, { populateFollowee: true });
diff --git a/packages/backend/src/server/api/endpoints/users/gallery/posts.ts b/packages/backend/src/server/api/endpoints/users/gallery/posts.ts
index c5f08b4c9..d7c435256 100644
--- a/packages/backend/src/server/api/endpoints/users/gallery/posts.ts
+++ b/packages/backend/src/server/api/endpoints/users/gallery/posts.ts
@@ -1,39 +1,29 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { GalleryPosts } from '@/models/index';
-import { makePaginationQuery } from '../../../common/make-pagination-query';
+import define from '../../../define.js';
+import { GalleryPosts } from '@/models/index.js';
+import { makePaginationQuery } from '../../../common/make-pagination-query.js';
export const meta = {
tags: ['users', 'gallery'],
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { 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: ['userId'],
} 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(GalleryPosts.createQueryBuilder('post'), ps.sinceId, ps.untilId)
.andWhere(`post.userId = :userId`, { userId: ps.userId });
const posts = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await GalleryPosts.packMany(posts, user);
diff --git a/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts b/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts
index d886d3355..73cadc0df 100644
--- a/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts
+++ b/packages/backend/src/server/api/endpoints/users/get-frequently-replied-users.ts
@@ -1,28 +1,15 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { maximum } from '@/prelude/array';
-import { ApiError } from '../../error';
-import { getUser } from '../../common/getters';
+import define from '../../define.js';
+import { maximum } from '@/prelude/array.js';
+import { ApiError } from '../../error.js';
+import { getUser } from '../../common/getters.js';
import { Not, In, IsNull } from 'typeorm';
-import { Notes, Users } from '@/models/index';
+import { Notes, Users } from '@/models/index.js';
export const meta = {
tags: ['users'],
requireCredential: false,
- params: {
- userId: {
- validator: $.type(ID),
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -52,8 +39,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ },
+ required: ['userId'],
+} 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) => {
// Lookup user
const user = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
@@ -104,7 +100,7 @@ export default define(meta, async (ps, me) => {
const repliedUsersSorted = Object.keys(repliedUsers).sort((a, b) => repliedUsers[b] - repliedUsers[a]);
// Extract top replied users
- const topRepliedUsers = repliedUsersSorted.slice(0, ps.limit!);
+ const topRepliedUsers = repliedUsersSorted.slice(0, ps.limit);
// Make replies object (includes weights)
const repliesObj = await Promise.all(topRepliedUsers.map(async (user) => ({
diff --git a/packages/backend/src/server/api/endpoints/users/groups/create.ts b/packages/backend/src/server/api/endpoints/users/groups/create.ts
index 25e29de01..9f6d8464d 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/create.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/create.ts
@@ -1,9 +1,8 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { UserGroups, UserGroupJoinings } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { UserGroup } from '@/models/entities/user-group';
-import { UserGroupJoining } from '@/models/entities/user-group-joining';
+import define from '../../../define.js';
+import { UserGroups, UserGroupJoinings } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { UserGroup } from '@/models/entities/user-group.js';
+import { UserGroupJoining } from '@/models/entities/user-group-joining.js';
export const meta = {
tags: ['groups'],
@@ -12,12 +11,6 @@ export const meta = {
kind: 'write:user-groups',
- params: {
- name: {
- validator: $.str.range(1, 100),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -25,8 +18,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ name: { type: 'string', minLength: 1, maxLength: 100 },
+ },
+ required: ['name'],
+} 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 userGroup = await UserGroups.insert({
id: genId(),
createdAt: new Date(),
diff --git a/packages/backend/src/server/api/endpoints/users/groups/delete.ts b/packages/backend/src/server/api/endpoints/users/groups/delete.ts
index f30ab78ca..f4898a3c7 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/delete.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/delete.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { UserGroups } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { UserGroups } from '@/models/index.js';
export const meta = {
tags: ['groups'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'write:user-groups',
- params: {
- groupId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchGroup: {
message: 'No such group.',
@@ -26,8 +18,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ groupId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['groupId'],
+} 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 userGroup = await UserGroups.findOne({
id: ps.groupId,
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts b/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts
index 7061db538..efbdf968f 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/invitations/accept.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../../define';
-import { ApiError } from '../../../../error';
-import { UserGroupJoinings, UserGroupInvitations } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { UserGroupJoining } from '@/models/entities/user-group-joining';
+import define from '../../../../define.js';
+import { ApiError } from '../../../../error.js';
+import { UserGroupJoinings, UserGroupInvitations } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { UserGroupJoining } from '@/models/entities/user-group-joining.js';
export const meta = {
tags: ['groups', 'users'],
@@ -13,12 +11,6 @@ export const meta = {
kind: 'write:user-groups',
- params: {
- invitationId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchInvitation: {
message: 'No such invitation.',
@@ -28,8 +20,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ invitationId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['invitationId'],
+} 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) => {
// Fetch the invitation
const invitation = await UserGroupInvitations.findOne({
id: ps.invitationId,
diff --git a/packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts b/packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts
index f5ca3dec8..fe5d431ea 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/invitations/reject.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../../define';
-import { ApiError } from '../../../../error';
-import { UserGroupInvitations } from '@/models/index';
+import define from '../../../../define.js';
+import { ApiError } from '../../../../error.js';
+import { UserGroupInvitations } from '@/models/index.js';
export const meta = {
tags: ['groups', 'users'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'write:user-groups',
- params: {
- invitationId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchInvitation: {
message: 'No such invitation.',
@@ -26,8 +18,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ invitationId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['invitationId'],
+} 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) => {
// Fetch the invitation
const invitation = await UserGroupInvitations.findOne({
id: ps.invitationId,
diff --git a/packages/backend/src/server/api/endpoints/users/groups/invite.ts b/packages/backend/src/server/api/endpoints/users/groups/invite.ts
index 3b7a4edb8..10bfb7eca 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/invite.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/invite.ts
@@ -1,12 +1,10 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getUser } from '../../../common/getters';
-import { UserGroups, UserGroupJoinings, UserGroupInvitations } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { UserGroupInvitation } from '@/models/entities/user-group-invitation';
-import { createNotification } from '@/services/create-notification';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getUser } from '../../../common/getters.js';
+import { UserGroups, UserGroupJoinings, UserGroupInvitations } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { UserGroupInvitation } from '@/models/entities/user-group-invitation.js';
+import { createNotification } from '@/services/create-notification.js';
export const meta = {
tags: ['groups', 'users'],
@@ -15,16 +13,6 @@ export const meta = {
kind: 'write:user-groups',
- params: {
- groupId: {
- validator: $.type(ID),
- },
-
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchGroup: {
message: 'No such group.',
@@ -52,8 +40,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ groupId: { type: 'string', format: 'misskey:id' },
+ userId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['groupId', 'userId'],
+} 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) => {
// Fetch the group
const userGroup = await UserGroups.findOne({
id: ps.groupId,
diff --git a/packages/backend/src/server/api/endpoints/users/groups/joined.ts b/packages/backend/src/server/api/endpoints/users/groups/joined.ts
index ab48b1910..e52de7859 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/joined.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/joined.ts
@@ -1,5 +1,5 @@
-import define from '../../../define';
-import { UserGroups, UserGroupJoinings } from '@/models/index';
+import define from '../../../define.js';
+import { UserGroups, UserGroupJoinings } from '@/models/index.js';
import { Not, In } from 'typeorm';
export const meta = {
@@ -20,8 +20,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 ownedGroups = await UserGroups.find({
userId: me.id,
});
diff --git a/packages/backend/src/server/api/endpoints/users/groups/leave.ts b/packages/backend/src/server/api/endpoints/users/groups/leave.ts
index d2fcdab30..c1a8c2c02 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/leave.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/leave.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { UserGroups, UserGroupJoinings } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { UserGroups, UserGroupJoinings } from '@/models/index.js';
export const meta = {
tags: ['groups', 'users'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'write:user-groups',
- params: {
- groupId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchGroup: {
message: 'No such group.',
@@ -32,8 +24,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ groupId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['groupId'],
+} 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) => {
// Fetch the group
const userGroup = await UserGroups.findOne({
id: ps.groupId,
diff --git a/packages/backend/src/server/api/endpoints/users/groups/owned.ts b/packages/backend/src/server/api/endpoints/users/groups/owned.ts
index 6193a7101..11aad0f73 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/owned.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/owned.ts
@@ -1,5 +1,5 @@
-import define from '../../../define';
-import { UserGroups } from '@/models/index';
+import define from '../../../define.js';
+import { UserGroups } from '@/models/index.js';
export const meta = {
tags: ['groups', 'account'],
@@ -19,8 +19,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 userGroups = await UserGroups.find({
userId: me.id,
});
diff --git a/packages/backend/src/server/api/endpoints/users/groups/pull.ts b/packages/backend/src/server/api/endpoints/users/groups/pull.ts
index 785bea140..55ec9f915 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/pull.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/pull.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getUser } from '../../../common/getters';
-import { UserGroups, UserGroupJoinings } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getUser } from '../../../common/getters.js';
+import { UserGroups, UserGroupJoinings } from '@/models/index.js';
export const meta = {
tags: ['groups', 'users'],
@@ -12,16 +10,6 @@ export const meta = {
kind: 'write:user-groups',
- params: {
- groupId: {
- validator: $.type(ID),
- },
-
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchGroup: {
message: 'No such group.',
@@ -43,8 +31,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ groupId: { type: 'string', format: 'misskey:id' },
+ userId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['groupId', 'userId'],
+} 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) => {
// Fetch the group
const userGroup = await UserGroups.findOne({
id: ps.groupId,
diff --git a/packages/backend/src/server/api/endpoints/users/groups/show.ts b/packages/backend/src/server/api/endpoints/users/groups/show.ts
index eb26eac2a..28ca1162c 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/show.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/show.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { UserGroups, UserGroupJoinings } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { UserGroups, UserGroupJoinings } from '@/models/index.js';
export const meta = {
tags: ['groups', 'account'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'read:user-groups',
- params: {
- groupId: {
- validator: $.type(ID),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -32,8 +24,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ groupId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['groupId'],
+} 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) => {
// Fetch the group
const userGroup = await UserGroups.findOne({
id: ps.groupId,
diff --git a/packages/backend/src/server/api/endpoints/users/groups/transfer.ts b/packages/backend/src/server/api/endpoints/users/groups/transfer.ts
index 4b1c8fbbd..f48e1ddbf 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/transfer.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/transfer.ts
@@ -1,9 +1,7 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getUser } from '../../../common/getters';
-import { UserGroups, UserGroupJoinings } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getUser } from '../../../common/getters.js';
+import { UserGroups, UserGroupJoinings } from '@/models/index.js';
export const meta = {
tags: ['groups', 'users'],
@@ -12,16 +10,6 @@ export const meta = {
kind: 'write:user-groups',
- params: {
- groupId: {
- validator: $.type(ID),
- },
-
- userId: {
- validator: $.type(ID),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -49,8 +37,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ groupId: { type: 'string', format: 'misskey:id' },
+ userId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['groupId', 'userId'],
+} 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) => {
// Fetch the group
const userGroup = await UserGroups.findOne({
id: ps.groupId,
diff --git a/packages/backend/src/server/api/endpoints/users/groups/update.ts b/packages/backend/src/server/api/endpoints/users/groups/update.ts
index 6caf90355..b3e17dfd9 100644
--- a/packages/backend/src/server/api/endpoints/users/groups/update.ts
+++ b/packages/backend/src/server/api/endpoints/users/groups/update.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { UserGroups } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { UserGroups } from '@/models/index.js';
export const meta = {
tags: ['groups'],
@@ -11,16 +9,6 @@ export const meta = {
kind: 'write:user-groups',
- params: {
- groupId: {
- validator: $.type(ID),
- },
-
- name: {
- validator: $.str.range(1, 100),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -36,8 +24,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ groupId: { type: 'string', format: 'misskey:id' },
+ name: { type: 'string', minLength: 1, maxLength: 100 },
+ },
+ required: ['groupId', 'name'],
+} 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) => {
// Fetch the group
const userGroup = await UserGroups.findOne({
id: ps.groupId,
diff --git a/packages/backend/src/server/api/endpoints/users/lists/create.ts b/packages/backend/src/server/api/endpoints/users/lists/create.ts
index 945b51162..1a0599f9e 100644
--- a/packages/backend/src/server/api/endpoints/users/lists/create.ts
+++ b/packages/backend/src/server/api/endpoints/users/lists/create.ts
@@ -1,8 +1,7 @@
-import $ from 'cafy';
-import define from '../../../define';
-import { UserLists } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { UserList } from '@/models/entities/user-list';
+import define from '../../../define.js';
+import { UserLists } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { UserList } from '@/models/entities/user-list.js';
export const meta = {
tags: ['lists'],
@@ -11,12 +10,6 @@ export const meta = {
kind: 'write:account',
- params: {
- name: {
- validator: $.str.range(1, 100),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -24,8 +17,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ name: { type: 'string', minLength: 1, maxLength: 100 },
+ },
+ required: ['name'],
+} 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 userList = await UserLists.insert({
id: genId(),
createdAt: new Date(),
diff --git a/packages/backend/src/server/api/endpoints/users/lists/delete.ts b/packages/backend/src/server/api/endpoints/users/lists/delete.ts
index 3183d2a09..aeefb98c8 100644
--- a/packages/backend/src/server/api/endpoints/users/lists/delete.ts
+++ b/packages/backend/src/server/api/endpoints/users/lists/delete.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { UserLists } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { UserLists } from '@/models/index.js';
export const meta = {
tags: ['lists'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'write:account',
- params: {
- listId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchList: {
message: 'No such list.',
@@ -26,8 +18,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ listId: { type: 'string', format: 'misskey:id' },
+ },
+ 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 userList = await UserLists.findOne({
id: ps.listId,
userId: user.id,
diff --git a/packages/backend/src/server/api/endpoints/users/lists/list.ts b/packages/backend/src/server/api/endpoints/users/lists/list.ts
index ae66b0aac..a8663ada8 100644
--- a/packages/backend/src/server/api/endpoints/users/lists/list.ts
+++ b/packages/backend/src/server/api/endpoints/users/lists/list.ts
@@ -1,5 +1,5 @@
-import define from '../../../define';
-import { UserLists } from '@/models/index';
+import define from '../../../define.js';
+import { UserLists } from '@/models/index.js';
export const meta = {
tags: ['lists', 'account'],
@@ -19,8 +19,14 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {},
+ 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 userLists = await UserLists.find({
userId: me.id,
});
diff --git a/packages/backend/src/server/api/endpoints/users/lists/pull.ts b/packages/backend/src/server/api/endpoints/users/lists/pull.ts
index 4c74aefa8..2c4c61d51 100644
--- a/packages/backend/src/server/api/endpoints/users/lists/pull.ts
+++ b/packages/backend/src/server/api/endpoints/users/lists/pull.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import { publishUserListStream } from '@/services/stream';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getUser } from '../../../common/getters';
-import { UserLists, UserListJoinings, Users } from '@/models/index';
+import { publishUserListStream } from '@/services/stream.js';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getUser } from '../../../common/getters.js';
+import { UserLists, UserListJoinings, Users } from '@/models/index.js';
export const meta = {
tags: ['lists', 'users'],
@@ -13,16 +11,6 @@ export const meta = {
kind: 'write:account',
- params: {
- listId: {
- validator: $.type(ID),
- },
-
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchList: {
message: 'No such list.',
@@ -38,8 +26,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ listId: { type: 'string', format: 'misskey:id' },
+ userId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['listId', 'userId'],
+} 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) => {
// Fetch the list
const userList = await UserLists.findOne({
id: ps.listId,
diff --git a/packages/backend/src/server/api/endpoints/users/lists/push.ts b/packages/backend/src/server/api/endpoints/users/lists/push.ts
index 8b50c475b..034a9d2db 100644
--- a/packages/backend/src/server/api/endpoints/users/lists/push.ts
+++ b/packages/backend/src/server/api/endpoints/users/lists/push.ts
@@ -1,10 +1,8 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { getUser } from '../../../common/getters';
-import { pushUserToUserList } from '@/services/user-list/push';
-import { UserLists, UserListJoinings, Blockings } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { getUser } from '../../../common/getters.js';
+import { pushUserToUserList } from '@/services/user-list/push.js';
+import { UserLists, UserListJoinings, Blockings } from '@/models/index.js';
export const meta = {
tags: ['lists', 'users'],
@@ -13,16 +11,6 @@ export const meta = {
kind: 'write:account',
- params: {
- listId: {
- validator: $.type(ID),
- },
-
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchList: {
message: 'No such list.',
@@ -50,8 +38,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ listId: { type: 'string', format: 'misskey:id' },
+ userId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['listId', 'userId'],
+} 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) => {
// Fetch the list
const userList = await UserLists.findOne({
id: ps.listId,
diff --git a/packages/backend/src/server/api/endpoints/users/lists/show.ts b/packages/backend/src/server/api/endpoints/users/lists/show.ts
index 06555c1a8..fadb94c90 100644
--- a/packages/backend/src/server/api/endpoints/users/lists/show.ts
+++ b/packages/backend/src/server/api/endpoints/users/lists/show.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { UserLists } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { UserLists } from '@/models/index.js';
export const meta = {
tags: ['lists', 'account'],
@@ -11,12 +9,6 @@ export const meta = {
kind: 'read:account',
- params: {
- listId: {
- validator: $.type(ID),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -32,8 +24,16 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ listId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['listId'],
+} 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) => {
// Fetch the list
const userList = await UserLists.findOne({
id: ps.listId,
diff --git a/packages/backend/src/server/api/endpoints/users/lists/update.ts b/packages/backend/src/server/api/endpoints/users/lists/update.ts
index 02b0d5fe1..5ec99031e 100644
--- a/packages/backend/src/server/api/endpoints/users/lists/update.ts
+++ b/packages/backend/src/server/api/endpoints/users/lists/update.ts
@@ -1,8 +1,6 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../../define';
-import { ApiError } from '../../../error';
-import { UserLists } from '@/models/index';
+import define from '../../../define.js';
+import { ApiError } from '../../../error.js';
+import { UserLists } from '@/models/index.js';
export const meta = {
tags: ['lists'],
@@ -11,16 +9,6 @@ export const meta = {
kind: 'write:account',
- params: {
- listId: {
- validator: $.type(ID),
- },
-
- name: {
- validator: $.str.range(1, 100),
- },
- },
-
res: {
type: 'object',
optional: false, nullable: false,
@@ -36,8 +24,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ listId: { type: 'string', format: 'misskey:id' },
+ name: { type: 'string', minLength: 1, maxLength: 100 },
+ },
+ required: ['listId', 'name'],
+} 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) => {
// Fetch the list
const userList = await UserLists.findOne({
id: ps.listId,
diff --git a/packages/backend/src/server/api/endpoints/users/notes.ts b/packages/backend/src/server/api/endpoints/users/notes.ts
index 99158fb0a..16318d222 100644
--- a/packages/backend/src/server/api/endpoints/users/notes.ts
+++ b/packages/backend/src/server/api/endpoints/users/notes.ts
@@ -1,70 +1,17 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { getUser } from '../../common/getters';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
-import { Notes } from '@/models/index';
-import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { getUser } from '../../common/getters.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { Notes } from '@/models/index.js';
+import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { Brackets } from 'typeorm';
-import { generateBlockedUserQuery } from '../../common/generate-block-query';
-import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query';
+import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
+import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js';
export const meta = {
tags: ['users', 'notes'],
- params: {
- userId: {
- validator: $.type(ID),
- },
-
- includeReplies: {
- validator: $.optional.bool,
- default: true,
- },
-
- 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,
- },
-
- withFiles: {
- validator: $.optional.bool,
- default: false,
- },
-
- fileType: {
- validator: $.optional.arr($.str),
- },
-
- excludeNsfw: {
- validator: $.optional.bool,
- default: false,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -84,8 +31,28 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
+ includeReplies: { type: 'boolean', default: true },
+ 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 },
+ withFiles: { type: 'boolean', default: false },
+ fileType: { type: 'array', items: {
+ type: 'string',
+ } },
+ excludeNsfw: { type: 'boolean', default: false },
+ },
+ required: ['userId'],
+} 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) => {
// Lookup user
const user = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
@@ -96,10 +63,16 @@ export default define(meta, async (ps, me) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('note.userId = :userId', { userId: user.id })
.innerJoinAndSelect('note.user', 'user')
+ .leftJoinAndSelect('user.avatar', 'avatar')
+ .leftJoinAndSelect('user.banner', 'banner')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
.leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('replyUser.avatar', 'replyUserAvatar')
+ .leftJoinAndSelect('replyUser.banner', 'replyUserBanner')
+ .leftJoinAndSelect('renote.user', 'renoteUser')
+ .leftJoinAndSelect('renoteUser.avatar', 'renoteUserAvatar')
+ .leftJoinAndSelect('renoteUser.banner', 'renoteUserBanner');
generateVisibilityQuery(query, me);
if (me) generateMutedUserQuery(query, me, user);
@@ -141,7 +114,7 @@ export default define(meta, async (ps, me) => {
//#endregion
- const timeline = await query.take(ps.limit!).getMany();
+ const timeline = await query.take(ps.limit).getMany();
return await Notes.packMany(timeline, me);
});
diff --git a/packages/backend/src/server/api/endpoints/users/pages.ts b/packages/backend/src/server/api/endpoints/users/pages.ts
index 6e003dd1a..b8b3e8192 100644
--- a/packages/backend/src/server/api/endpoints/users/pages.ts
+++ b/packages/backend/src/server/api/endpoints/users/pages.ts
@@ -1,40 +1,30 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { Pages } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
+import define from '../../define.js';
+import { Pages } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['users', 'pages'],
+} as const;
- params: {
- userId: {
- validator: $.type(ID),
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- sinceId: {
- validator: $.optional.type(ID),
- },
-
- untilId: {
- validator: $.optional.type(ID),
- },
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { 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: ['userId'],
} 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(Pages.createQueryBuilder('page'), ps.sinceId, ps.untilId)
.andWhere(`page.userId = :userId`, { userId: ps.userId })
.andWhere('page.visibility = \'public\'');
const pages = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Pages.packMany(pages);
diff --git a/packages/backend/src/server/api/endpoints/users/reactions.ts b/packages/backend/src/server/api/endpoints/users/reactions.ts
index 312d4dbf2..7b55a1671 100644
--- a/packages/backend/src/server/api/endpoints/users/reactions.ts
+++ b/packages/backend/src/server/api/endpoints/users/reactions.ts
@@ -1,43 +1,14 @@
-import $ from 'cafy';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { NoteReactions, UserProfiles } from '@/models/index';
-import { makePaginationQuery } from '../../common/make-pagination-query';
-import { generateVisibilityQuery } from '../../common/generate-visibility-query';
-import { ApiError } from '../../error';
+import define from '../../define.js';
+import { NoteReactions, UserProfiles } from '@/models/index.js';
+import { makePaginationQuery } from '../../common/make-pagination-query.js';
+import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
+import { ApiError } from '../../error.js';
export const meta = {
tags: ['users', 'reactions'],
requireCredential: false,
- params: {
- userId: {
- 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,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -57,8 +28,21 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { 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: ['userId'],
+} 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 profile = await UserProfiles.findOneOrFail(ps.userId);
if (me == null || (me.id !== ps.userId && !profile.publicReactions)) {
@@ -73,7 +57,7 @@ export default define(meta, async (ps, me) => {
generateVisibilityQuery(query, me);
const reactions = await query
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
return await Promise.all(reactions.map(reaction => NoteReactions.pack(reaction, me, { withNote: true })));
diff --git a/packages/backend/src/server/api/endpoints/users/recommendation.ts b/packages/backend/src/server/api/endpoints/users/recommendation.ts
index 9ea39eb2d..a8f18de52 100644
--- a/packages/backend/src/server/api/endpoints/users/recommendation.ts
+++ b/packages/backend/src/server/api/endpoints/users/recommendation.ts
@@ -1,9 +1,8 @@
import ms from 'ms';
-import $ from 'cafy';
-import define from '../../define';
-import { Users, Followings } from '@/models/index';
-import { generateMutedUserQueryForUsers } from '../../common/generate-muted-user-query';
-import { generateBlockedUserQuery, generateBlockQueryForUsers } from '../../common/generate-block-query';
+import define from '../../define.js';
+import { Users, Followings } from '@/models/index.js';
+import { generateMutedUserQueryForUsers } from '../../common/generate-muted-user-query.js';
+import { generateBlockedUserQuery, generateBlockQueryForUsers } from '../../common/generate-block-query.js';
export const meta = {
tags: ['users'],
@@ -12,18 +11,6 @@ export const meta = {
kind: 'read:account',
- 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,
@@ -35,8 +22,17 @@ export const meta = {
},
} as const;
+export 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, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const query = Users.createQueryBuilder('user')
.where('user.isLocked = FALSE')
.andWhere('user.isExplorable = TRUE')
@@ -58,7 +54,7 @@ export default define(meta, async (ps, me) => {
query.setParameters(followingQuery.getParameters());
- const users = await query.take(ps.limit!).skip(ps.offset).getMany();
+ const users = await query.take(ps.limit).skip(ps.offset).getMany();
return await Users.packMany(users, me, { detail: true });
});
diff --git a/packages/backend/src/server/api/endpoints/users/relation.ts b/packages/backend/src/server/api/endpoints/users/relation.ts
index 7e319ca10..c6262122d 100644
--- a/packages/backend/src/server/api/endpoints/users/relation.ts
+++ b/packages/backend/src/server/api/endpoints/users/relation.ts
@@ -1,19 +1,11 @@
-import $ from 'cafy';
-import define from '../../define';
-import { ID } from '@/misc/cafy-id';
-import { Users } from '@/models/index';
+import define from '../../define.js';
+import { Users } from '@/models/index.js';
export const meta = {
tags: ['users'],
requireCredential: true,
- params: {
- userId: {
- validator: $.either($.type(ID), $.arr($.type(ID)).unique()),
- },
- },
-
res: {
optional: false, nullable: false,
oneOf: [
@@ -101,8 +93,24 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: {
+ anyOf: [
+ { type: 'string', format: 'misskey:id' },
+ {
+ type: 'array',
+ items: { type: 'string', format: 'misskey:id' },
+ },
+ ],
+ },
+ },
+ required: ['userId'],
+} 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 ids = Array.isArray(ps.userId) ? ps.userId : [ps.userId];
const relations = await Promise.all(ids.map(id => Users.getRelation(me.id, id)));
diff --git a/packages/backend/src/server/api/endpoints/users/report-abuse.ts b/packages/backend/src/server/api/endpoints/users/report-abuse.ts
index ed2aa7bb2..e091b8e1b 100644
--- a/packages/backend/src/server/api/endpoints/users/report-abuse.ts
+++ b/packages/backend/src/server/api/endpoints/users/report-abuse.ts
@@ -1,30 +1,18 @@
-import $ from 'cafy';
import * as sanitizeHtml from 'sanitize-html';
-import { ID } from '@/misc/cafy-id';
-import define from '../../define';
-import { publishAdminStream } from '@/services/stream';
-import { ApiError } from '../../error';
-import { getUser } from '../../common/getters';
-import { AbuseUserReports, Users } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { sendEmail } from '@/services/send-email';
-import { fetchMeta } from '@/misc/fetch-meta';
+import define from '../../define.js';
+import { publishAdminStream } from '@/services/stream.js';
+import { ApiError } from '../../error.js';
+import { getUser } from '../../common/getters.js';
+import { AbuseUserReports, Users } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { sendEmail } from '@/services/send-email.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
export const meta = {
tags: ['users'],
requireCredential: true,
- params: {
- userId: {
- validator: $.type(ID),
- },
-
- comment: {
- validator: $.str.range(1, 2048),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -46,8 +34,17 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
+ comment: { type: 'string', minLength: 1, maxLength: 2048 },
+ },
+ required: ['userId', 'comment'],
+} 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) => {
// Lookup user
const user = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
diff --git a/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts b/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts
index 72e79c882..897b5de3f 100644
--- a/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts
+++ b/packages/backend/src/server/api/endpoints/users/search-by-username-and-host.ts
@@ -1,35 +1,14 @@
-import $ from 'cafy';
-import define from '../../define';
-import { Followings, Users } from '@/models/index';
+import define from '../../define.js';
+import { Followings, Users } from '@/models/index.js';
import { Brackets } from 'typeorm';
-import { USER_ACTIVE_THRESHOLD } from '@/const';
-import { User } from '@/models/entities/user';
+import { USER_ACTIVE_THRESHOLD } from '@/const.js';
+import { User } from '@/models/entities/user.js';
export const meta = {
tags: ['users'],
requireCredential: false,
- params: {
- username: {
- validator: $.optional.nullable.str,
- },
-
- host: {
- validator: $.optional.nullable.str,
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- detail: {
- validator: $.optional.bool,
- default: true,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -41,8 +20,21 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ username: { type: 'string', nullable: true },
+ host: { type: 'string', nullable: true },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ detail: { type: 'boolean', default: true },
+ },
+ required: [],
+} as const;
+
+// TODO: avatar,bannerをJOINしたいけどエラーになる
+
// eslint-disable-next-line import/no-default-export
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const activeThreshold = new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)); // 30日
if (ps.host) {
@@ -57,7 +49,7 @@ export default define(meta, async (ps, me) => {
q.andWhere('user.updatedAt IS NOT NULL');
q.orderBy('user.updatedAt', 'DESC');
- const users = await q.take(ps.limit!).getMany();
+ const users = await q.take(ps.limit).getMany();
return await Users.packMany(users, me, { detail: ps.detail });
} else if (ps.username) {
@@ -82,10 +74,10 @@ export default define(meta, async (ps, me) => {
users = await query
.orderBy('user.usernameLower', 'ASC')
- .take(ps.limit!)
+ .take(ps.limit)
.getMany();
- if (users.length < ps.limit!) {
+ if (users.length < ps.limit) {
const otherQuery = await Users.createQueryBuilder('user')
.where(`user.id NOT IN (${ followingQuery.getQuery() })`)
.andWhere(`user.id != :meId`, { meId: me.id })
@@ -97,7 +89,7 @@ export default define(meta, async (ps, me) => {
const otherUsers = await otherQuery
.orderBy('user.updatedAt', 'DESC')
- .take(ps.limit! - users.length)
+ .take(ps.limit - users.length)
.getMany();
users = users.concat(otherUsers);
@@ -108,7 +100,7 @@ export default define(meta, async (ps, me) => {
.andWhere('user.usernameLower LIKE :username', { username: ps.username.toLowerCase() + '%' })
.andWhere('user.updatedAt IS NOT NULL')
.orderBy('user.updatedAt', 'DESC')
- .take(ps.limit! - users.length)
+ .take(ps.limit - users.length)
.getMany();
}
diff --git a/packages/backend/src/server/api/endpoints/users/search.ts b/packages/backend/src/server/api/endpoints/users/search.ts
index 26f818afc..a72a58a84 100644
--- a/packages/backend/src/server/api/endpoints/users/search.ts
+++ b/packages/backend/src/server/api/endpoints/users/search.ts
@@ -1,7 +1,6 @@
-import $ from 'cafy';
-import define from '../../define';
-import { UserProfiles, Users } from '@/models/index';
-import { User } from '@/models/entities/user';
+import define from '../../define.js';
+import { UserProfiles, Users } from '@/models/index.js';
+import { User } from '@/models/entities/user.js';
import { Brackets } from 'typeorm';
export const meta = {
@@ -9,32 +8,6 @@ export const meta = {
requireCredential: false,
- params: {
- query: {
- validator: $.str,
- },
-
- offset: {
- validator: $.optional.num.min(0),
- default: 0,
- },
-
- limit: {
- validator: $.optional.num.range(1, 100),
- default: 10,
- },
-
- origin: {
- validator: $.optional.str.or(['local', 'remote', 'combined']),
- default: 'combined',
- },
-
- detail: {
- validator: $.optional.bool,
- default: true,
- },
- },
-
res: {
type: 'array',
optional: false, nullable: false,
@@ -46,8 +19,20 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ query: { type: 'string' },
+ offset: { type: 'integer', default: 0 },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
+ origin: { type: 'string', enum: ['local', 'remote', 'combined'], default: "combined" },
+ detail: { type: 'boolean', default: true },
+ },
+ 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) => {
const activeThreshold = new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)); // 30日
const isUsername = ps.query.startsWith('@');
@@ -71,7 +56,7 @@ export default define(meta, async (ps, me) => {
users = await usernameQuery
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
- .take(ps.limit!)
+ .take(ps.limit)
.skip(ps.offset)
.getMany();
} else {
@@ -91,11 +76,11 @@ export default define(meta, async (ps, me) => {
users = await nameQuery
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
- .take(ps.limit!)
+ .take(ps.limit)
.skip(ps.offset)
.getMany();
- if (users.length < ps.limit!) {
+ if (users.length < ps.limit) {
const profQuery = UserProfiles.createQueryBuilder('prof')
.select('prof.userId')
.where('prof.description ILIKE :query', { query: '%' + ps.query + '%' });
@@ -117,7 +102,7 @@ export default define(meta, async (ps, me) => {
users = users.concat(await query
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
- .take(ps.limit!)
+ .take(ps.limit)
.skip(ps.offset)
.getMany()
);
diff --git a/packages/backend/src/server/api/endpoints/users/show.ts b/packages/backend/src/server/api/endpoints/users/show.ts
index 92910e9ed..263c102a7 100644
--- a/packages/backend/src/server/api/endpoints/users/show.ts
+++ b/packages/backend/src/server/api/endpoints/users/show.ts
@@ -1,36 +1,16 @@
-import $ from 'cafy';
-import { resolveUser } from '@/remote/resolve-user';
-import define from '../../define';
-import { apiLogger } from '../../logger';
-import { ApiError } from '../../error';
-import { ID } from '@/misc/cafy-id';
-import { Users } from '@/models/index';
+import { resolveUser } from '@/remote/resolve-user.js';
+import define from '../../define.js';
+import { apiLogger } from '../../logger.js';
+import { ApiError } from '../../error.js';
+import { Users } from '@/models/index.js';
import { In } from 'typeorm';
-import { User } from '@/models/entities/user';
+import { User } from '@/models/entities/user.js';
export const meta = {
tags: ['users'],
requireCredential: false,
- params: {
- userId: {
- validator: $.optional.type(ID),
- },
-
- userIds: {
- validator: $.optional.arr($.type(ID)).unique(),
- },
-
- username: {
- validator: $.optional.str,
- },
-
- host: {
- validator: $.optional.nullable.str,
- },
- },
-
res: {
optional: false, nullable: false,
oneOf: [
@@ -64,8 +44,21 @@ export const meta = {
},
} as const;
+export const paramDef = {
+ type: 'object',
+ properties: {
+ userId: { type: 'string', format: 'misskey:id' },
+ userIds: { type: 'array', uniqueItems: true, items: {
+ type: 'string', format: 'misskey:id',
+ } },
+ username: { type: 'string' },
+ host: { type: 'string', nullable: true },
+ },
+ 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) => {
let user;
const isAdminOrModerator = me && (me.isAdmin || me.isModerator);
diff --git a/packages/backend/src/server/api/endpoints/users/stats.ts b/packages/backend/src/server/api/endpoints/users/stats.ts
index 381e43347..180a9386d 100644
--- a/packages/backend/src/server/api/endpoints/users/stats.ts
+++ b/packages/backend/src/server/api/endpoints/users/stats.ts
@@ -1,20 +1,12 @@
-import $ from 'cafy';
-import define from '../../define';
-import { ApiError } from '../../error';
-import { ID } from '@/misc/cafy-id';
-import { DriveFiles, Followings, NoteFavorites, NoteReactions, Notes, PageLikes, PollVotes, Users } from '@/models/index';
+import define from '../../define.js';
+import { ApiError } from '../../error.js';
+import { DriveFiles, Followings, NoteFavorites, NoteReactions, Notes, PageLikes, PollVotes, Users } from '@/models/index.js';
export const meta = {
tags: ['users'],
requireCredential: false,
- params: {
- userId: {
- validator: $.type(ID),
- },
- },
-
errors: {
noSuchUser: {
message: 'No such user.',
@@ -24,8 +16,16 @@ export const meta = {
},
} 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
-export default define(meta, async (ps, me) => {
+export default define(meta, paramDef, async (ps, me) => {
const user = await Users.findOne(ps.userId);
if (user == null) {
throw new ApiError(meta.errors.noSuchUser);
diff --git a/packages/backend/src/server/api/index.ts b/packages/backend/src/server/api/index.ts
index 8f8a9d999..ba2a71951 100644
--- a/packages/backend/src/server/api/index.ts
+++ b/packages/backend/src/server/api/index.ts
@@ -2,22 +2,22 @@
* API Server
*/
-import * as Koa from 'koa';
-import * as Router from '@koa/router';
-import * as multer from '@koa/multer';
-import * as bodyParser from 'koa-bodyparser';
-import * as cors from '@koa/cors';
+import Koa from 'koa';
+import Router from '@koa/router';
+import multer from '@koa/multer';
+import bodyParser from 'koa-bodyparser';
+import cors from '@koa/cors';
-import endpoints from './endpoints';
-import handler from './api-handler';
-import signup from './private/signup';
-import signin from './private/signin';
-import signupPending from './private/signup-pending';
-import discord from './service/discord';
-import github from './service/github';
-import twitter from './service/twitter';
-import { Instances, AccessTokens, Users } from '@/models/index';
-import config from '@/config';
+import endpoints from './endpoints.js';
+import handler from './api-handler.js';
+import signup from './private/signup.js';
+import signin from './private/signin.js';
+import signupPending from './private/signup-pending.js';
+import discord from './service/discord.js';
+import github from './service/github.js';
+import twitter from './service/twitter.js';
+import { Instances, AccessTokens, Users } from '@/models/index.js';
+import config from '@/config/index.js';
// Init app
const app = new Koa();
diff --git a/packages/backend/src/server/api/limiter.ts b/packages/backend/src/server/api/limiter.ts
index 4721f6263..7e6b93b39 100644
--- a/packages/backend/src/server/api/limiter.ts
+++ b/packages/backend/src/server/api/limiter.ts
@@ -1,9 +1,9 @@
-import * as Limiter from 'ratelimiter';
-import { redisClient } from '../../db/redis';
-import { IEndpoint } from './endpoints';
-import * as Acct from 'misskey-js/built/acct';
-import { User } from '@/models/entities/user';
-import Logger from '@/services/logger';
+import Limiter from 'ratelimiter';
+import { redisClient } from '../../db/redis.js';
+import { IEndpoint } from './endpoints.js';
+import * as Acct from '@/misc/acct.js';
+import { User } from '@/models/entities/user.js';
+import Logger from '@/services/logger.js';
const logger = new Logger('limiter');
diff --git a/packages/backend/src/server/api/logger.ts b/packages/backend/src/server/api/logger.ts
index 750defe54..ec22d6c3e 100644
--- a/packages/backend/src/server/api/logger.ts
+++ b/packages/backend/src/server/api/logger.ts
@@ -1,3 +1,3 @@
-import Logger from '@/services/logger';
+import Logger from '@/services/logger.js';
export const apiLogger = new Logger('api');
diff --git a/packages/backend/src/server/api/openapi/gen-spec.ts b/packages/backend/src/server/api/openapi/gen-spec.ts
index 1efef8d26..c6e557aef 100644
--- a/packages/backend/src/server/api/openapi/gen-spec.ts
+++ b/packages/backend/src/server/api/openapi/gen-spec.ts
@@ -1,8 +1,7 @@
-import endpoints from '../endpoints';
-import { Context } from 'cafy';
-import config from '@/config/index';
-import { errors as basicErrors } from './errors';
-import { schemas, convertSchemaToOpenApiSchema } from './schemas';
+import endpoints from '../endpoints.js';
+import config from '@/config/index.js';
+import { errors as basicErrors } from './errors.js';
+import { schemas, convertSchemaToOpenApiSchema } from './schemas.js';
export function genOpenapiSpec(lang = 'ja-JP') {
const spec = {
@@ -38,47 +37,7 @@ export function genOpenapiSpec(lang = 'ja-JP') {
},
};
- function genProps(props: { [key: string]: Context; }) {
- const properties = {} as any;
-
- for (const [k, v] of Object.entries(props)) {
- properties[k] = genProp(v);
- }
-
- return properties;
- }
-
- function genProp(param: Context): any {
- const required = param.name === 'Object' ? (param as any).props ? Object.entries((param as any).props).filter(([k, v]: any) => !v.isOptional).map(([k, v]) => k) : [] : [];
- return {
- description: (param.data || {}).desc,
- default: (param.data || {}).default,
- deprecated: (param.data || {}).deprecated,
- ...((param.data || {}).default ? { default: (param.data || {}).default } : {}),
- type: param.name === 'ID' ? 'string' : param.name.toLowerCase(),
- ...(param.name === 'ID' ? { example: 'xxxxxxxxxx', format: 'id' } : {}),
- nullable: param.isNullable,
- ...(param.name === 'String' ? {
- ...((param as any).enum ? { enum: (param as any).enum } : {}),
- ...((param as any).minLength ? { minLength: (param as any).minLength } : {}),
- ...((param as any).maxLength ? { maxLength: (param as any).maxLength } : {}),
- } : {}),
- ...(param.name === 'Number' ? {
- ...((param as any).minimum ? { minimum: (param as any).minimum } : {}),
- ...((param as any).maximum ? { maximum: (param as any).maximum } : {}),
- } : {}),
- ...(param.name === 'Object' ? {
- ...(required.length > 0 ? { required } : {}),
- properties: (param as any).props ? genProps((param as any).props) : {},
- } : {}),
- ...(param.name === 'Array' ? {
- items: (param as any).ctx ? genProp((param as any).ctx) : {},
- } : {}),
- };
- }
-
for (const endpoint of endpoints.filter(ep => !ep.meta.secure)) {
- const porops = {} as any;
const errors = {} as any;
if (endpoint.meta.errors) {
@@ -91,21 +50,9 @@ export function genOpenapiSpec(lang = 'ja-JP') {
}
}
- if (endpoint.meta.params) {
- for (const [k, v] of Object.entries(endpoint.meta.params)) {
- if (v.validator.data == null) v.validator.data = {};
- if (v.desc) v.validator.data.desc = v.desc[lang];
- if (v.deprecated) v.validator.data.deprecated = v.deprecated;
- if (v.default) v.validator.data.default = v.default;
- porops[k] = v.validator;
- }
- }
-
- const required = endpoint.meta.params ? Object.entries(endpoint.meta.params).filter(([k, v]) => !v.validator.isOptional).map(([k, v]) => k) : [];
-
const resSchema = endpoint.meta.res ? convertSchemaToOpenApiSchema(endpoint.meta.res) : {};
- let desc = (endpoint.meta.desc ? endpoint.meta.desc[lang] : 'No description provided.') + '\n\n';
+ let desc = (endpoint.meta.description ? endpoint.meta.description : 'No description provided.') + '\n\n';
desc += `**Credential required**: *${endpoint.meta.requireCredential ? 'Yes' : 'No'}*`;
if (endpoint.meta.kind) {
const kind = endpoint.meta.kind;
@@ -132,11 +79,7 @@ export function genOpenapiSpec(lang = 'ja-JP') {
required: true,
content: {
'application/json': {
- schema: {
- type: 'object',
- ...(required.length > 0 ? { required } : {}),
- properties: endpoint.meta.params ? genProps(porops) : {},
- },
+ schema: endpoint.params,
},
},
},
diff --git a/packages/backend/src/server/api/openapi/schemas.ts b/packages/backend/src/server/api/openapi/schemas.ts
index eb42667fd..14bef9cab 100644
--- a/packages/backend/src/server/api/openapi/schemas.ts
+++ b/packages/backend/src/server/api/openapi/schemas.ts
@@ -1,6 +1,6 @@
-import { refs, MinimumSchema } from '@/misc/schema';
+import { refs, Schema } from '@/misc/schema.js';
-export function convertSchemaToOpenApiSchema(schema: MinimumSchema) {
+export function convertSchemaToOpenApiSchema(schema: Schema) {
const res: any = schema;
if (schema.type === 'object' && schema.properties) {
diff --git a/packages/backend/src/server/api/private/signin.ts b/packages/backend/src/server/api/private/signin.ts
index 7b733b768..b0f88948a 100644
--- a/packages/backend/src/server/api/private/signin.ts
+++ b/packages/backend/src/server/api/private/signin.ts
@@ -1,13 +1,13 @@
-import * as Koa from 'koa';
-import * as bcrypt from 'bcryptjs';
+import Koa from 'koa';
+import bcrypt from 'bcryptjs';
import * as speakeasy from 'speakeasy';
-import signin from '../common/signin';
-import config from '@/config/index';
-import { Users, Signins, UserProfiles, UserSecurityKeys, AttestationChallenges } from '@/models/index';
-import { ILocalUser } from '@/models/entities/user';
-import { genId } from '@/misc/gen-id';
-import { verifyLogin, hash } from '../2fa';
-import { randomBytes } from 'crypto';
+import signin from '../common/signin.js';
+import config from '@/config/index.js';
+import { Users, Signins, UserProfiles, UserSecurityKeys, AttestationChallenges } from '@/models/index.js';
+import { ILocalUser } from '@/models/entities/user.js';
+import { genId } from '@/misc/gen-id.js';
+import { verifyLogin, hash } from '../2fa.js';
+import { randomBytes } from 'node:crypto';
export default async (ctx: Koa.Context) => {
ctx.set('Access-Control-Allow-Origin', config.url);
diff --git a/packages/backend/src/server/api/private/signup-pending.ts b/packages/backend/src/server/api/private/signup-pending.ts
index c0638a1cd..1a667ddb4 100644
--- a/packages/backend/src/server/api/private/signup-pending.ts
+++ b/packages/backend/src/server/api/private/signup-pending.ts
@@ -1,7 +1,7 @@
-import * as Koa from 'koa';
-import { Users, UserPendings, UserProfiles } from '@/models/index';
-import { signup } from '../common/signup';
-import signin from '../common/signin';
+import Koa from 'koa';
+import { Users, UserPendings, UserProfiles } from '@/models/index.js';
+import { signup } from '../common/signup.js';
+import signin from '../common/signin.js';
export default async (ctx: Koa.Context) => {
const body = ctx.request.body;
diff --git a/packages/backend/src/server/api/private/signup.ts b/packages/backend/src/server/api/private/signup.ts
index eaab8e711..01f284a57 100644
--- a/packages/backend/src/server/api/private/signup.ts
+++ b/packages/backend/src/server/api/private/signup.ts
@@ -1,14 +1,14 @@
-import * as Koa from 'koa';
+import Koa from 'koa';
import rndstr from 'rndstr';
-import * as bcrypt from 'bcryptjs';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { verifyHcaptcha, verifyRecaptcha } from '@/misc/captcha';
-import { Users, RegistrationTickets, UserPendings } from '@/models/index';
-import { signup } from '../common/signup';
-import config from '@/config';
-import { sendEmail } from '@/services/send-email';
-import { genId } from '@/misc/gen-id';
-import { validateEmailForAccount } from '@/services/validate-email-for-account';
+import bcrypt from 'bcryptjs';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { verifyHcaptcha, verifyRecaptcha } from '@/misc/captcha.js';
+import { Users, RegistrationTickets, UserPendings } from '@/models/index.js';
+import { signup } from '../common/signup.js';
+import config from '@/config/index.js';
+import { sendEmail } from '@/services/send-email.js';
+import { genId } from '@/misc/gen-id.js';
+import { validateEmailForAccount } from '@/services/validate-email-for-account.js';
export default async (ctx: Koa.Context) => {
const body = ctx.request.body;
@@ -38,7 +38,7 @@ export default async (ctx: Koa.Context) => {
const emailAddress = body['emailAddress'];
if (instance.emailRequiredForSignup) {
- if (emailAddress == null || typeof emailAddress != 'string') {
+ if (emailAddress == null || typeof emailAddress !== 'string') {
ctx.status = 400;
return;
}
@@ -51,7 +51,7 @@ export default async (ctx: Koa.Context) => {
}
if (instance.disableRegistration) {
- if (invitationCode == null || typeof invitationCode != 'string') {
+ if (invitationCode == null || typeof invitationCode !== 'string') {
ctx.status = 400;
return;
}
diff --git a/packages/backend/src/server/api/service/discord.ts b/packages/backend/src/server/api/service/discord.ts
index dd731c422..089f7de0c 100644
--- a/packages/backend/src/server/api/service/discord.ts
+++ b/packages/backend/src/server/api/service/discord.ts
@@ -1,15 +1,15 @@
-import * as Koa from 'koa';
-import * as Router from '@koa/router';
-import { getJson } from '@/misc/fetch';
+import Koa from 'koa';
+import Router from '@koa/router';
+import { getJson } from '@/misc/fetch.js';
import { OAuth2 } from 'oauth';
-import config from '@/config/index';
-import { publishMainStream } from '@/services/stream';
-import { redisClient } from '../../../db/redis';
+import config from '@/config/index.js';
+import { publishMainStream } from '@/services/stream.js';
+import { redisClient } from '../../../db/redis.js';
import { v4 as uuid } from 'uuid';
-import signin from '../common/signin';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { Users, UserProfiles } from '@/models/index';
-import { ILocalUser } from '@/models/entities/user';
+import signin from '../common/signin.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { Users, UserProfiles } from '@/models/index.js';
+import { ILocalUser } from '@/models/entities/user.js';
function getUserToken(ctx: Koa.BaseContext): string | null {
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
diff --git a/packages/backend/src/server/api/service/github.ts b/packages/backend/src/server/api/service/github.ts
index b23219986..ce032db18 100644
--- a/packages/backend/src/server/api/service/github.ts
+++ b/packages/backend/src/server/api/service/github.ts
@@ -1,15 +1,15 @@
-import * as Koa from 'koa';
-import * as Router from '@koa/router';
-import { getJson } from '@/misc/fetch';
+import Koa from 'koa';
+import Router from '@koa/router';
+import { getJson } from '@/misc/fetch.js';
import { OAuth2 } from 'oauth';
-import config from '@/config/index';
-import { publishMainStream } from '@/services/stream';
-import { redisClient } from '../../../db/redis';
+import config from '@/config/index.js';
+import { publishMainStream } from '@/services/stream.js';
+import { redisClient } from '../../../db/redis.js';
import { v4 as uuid } from 'uuid';
-import signin from '../common/signin';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { Users, UserProfiles } from '@/models/index';
-import { ILocalUser } from '@/models/entities/user';
+import signin from '../common/signin.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { Users, UserProfiles } from '@/models/index.js';
+import { ILocalUser } from '@/models/entities/user.js';
function getUserToken(ctx: Koa.BaseContext): string | null {
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
diff --git a/packages/backend/src/server/api/service/twitter.ts b/packages/backend/src/server/api/service/twitter.ts
index bca00b792..e6e4398fa 100644
--- a/packages/backend/src/server/api/service/twitter.ts
+++ b/packages/backend/src/server/api/service/twitter.ts
@@ -1,14 +1,14 @@
-import * as Koa from 'koa';
-import * as Router from '@koa/router';
+import Koa from 'koa';
+import Router from '@koa/router';
import { v4 as uuid } from 'uuid';
import autwh from 'autwh';
-import { redisClient } from '../../../db/redis';
-import { publishMainStream } from '@/services/stream';
-import config from '@/config/index';
-import signin from '../common/signin';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { Users, UserProfiles } from '@/models/index';
-import { ILocalUser } from '@/models/entities/user';
+import { redisClient } from '../../../db/redis.js';
+import { publishMainStream } from '@/services/stream.js';
+import config from '@/config/index.js';
+import signin from '../common/signin.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { Users, UserProfiles } from '@/models/index.js';
+import { ILocalUser } from '@/models/entities/user.js';
function getUserToken(ctx: Koa.BaseContext): string | null {
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
diff --git a/packages/backend/src/server/api/stream/channel.ts b/packages/backend/src/server/api/stream/channel.ts
index 98337bb31..d2cc5122d 100644
--- a/packages/backend/src/server/api/stream/channel.ts
+++ b/packages/backend/src/server/api/stream/channel.ts
@@ -1,4 +1,3 @@
-import autobind from 'autobind-decorator';
import Connection from '.';
/**
@@ -44,7 +43,6 @@ export default abstract class Channel {
this.connection = connection;
}
- @autobind
public send(typeOrPayload: any, payload?: any) {
const type = payload === undefined ? typeOrPayload.type : typeOrPayload;
const body = payload === undefined ? typeOrPayload.body : payload;
diff --git a/packages/backend/src/server/api/stream/channels/admin.ts b/packages/backend/src/server/api/stream/channels/admin.ts
index 1ff932d1d..945182ea1 100644
--- a/packages/backend/src/server/api/stream/channels/admin.ts
+++ b/packages/backend/src/server/api/stream/channels/admin.ts
@@ -1,12 +1,10 @@
-import autobind from 'autobind-decorator';
-import Channel from '../channel';
+import Channel from '../channel.js';
export default class extends Channel {
public readonly chName = 'admin';
public static shouldShare = true;
public static requireCredential = true;
- @autobind
public async init(params: any) {
// Subscribe admin stream
this.subscriber.on(`adminStream:${this.user!.id}`, data => {
diff --git a/packages/backend/src/server/api/stream/channels/antenna.ts b/packages/backend/src/server/api/stream/channels/antenna.ts
index 3cbdfebb4..afd14946e 100644
--- a/packages/backend/src/server/api/stream/channels/antenna.ts
+++ b/packages/backend/src/server/api/stream/channels/antenna.ts
@@ -1,9 +1,8 @@
-import autobind from 'autobind-decorator';
-import Channel from '../channel';
-import { Notes } from '@/models/index';
-import { isMutedUserRelated } from '@/misc/is-muted-user-related';
-import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
-import { StreamMessages } from '../types';
+import Channel from '../channel.js';
+import { Notes } from '@/models/index.js';
+import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
+import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
+import { StreamMessages } from '../types.js';
export default class extends Channel {
public readonly chName = 'antenna';
@@ -11,7 +10,11 @@ export default class extends Channel {
public static requireCredential = false;
private antennaId: string;
- @autobind
+ constructor(id: string, connection: Channel['connection']) {
+ super(id, connection);
+ this.onEvent = this.onEvent.bind(this);
+ }
+
public async init(params: any) {
this.antennaId = params.antennaId as string;
@@ -19,7 +22,6 @@ export default class extends Channel {
this.subscriber.on(`antennaStream:${this.antennaId}`, this.onEvent);
}
- @autobind
private async onEvent(data: StreamMessages['antenna']['payload']) {
if (data.type === 'note') {
const note = await Notes.pack(data.body.id, this.user, { detail: true });
@@ -37,7 +39,6 @@ export default class extends Channel {
}
}
- @autobind
public dispose() {
// Unsubscribe events
this.subscriber.off(`antennaStream:${this.antennaId}`, this.onEvent);
diff --git a/packages/backend/src/server/api/stream/channels/channel.ts b/packages/backend/src/server/api/stream/channels/channel.ts
index 1e51a81c4..16ad80939 100644
--- a/packages/backend/src/server/api/stream/channels/channel.ts
+++ b/packages/backend/src/server/api/stream/channels/channel.ts
@@ -1,11 +1,10 @@
-import autobind from 'autobind-decorator';
-import Channel from '../channel';
-import { Notes, Users } from '@/models/index';
-import { isMutedUserRelated } from '@/misc/is-muted-user-related';
-import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
-import { User } from '@/models/entities/user';
-import { StreamMessages } from '../types';
-import { Packed } from '@/misc/schema';
+import Channel from '../channel.js';
+import { Notes, Users } from '@/models/index.js';
+import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
+import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
+import { User } from '@/models/entities/user.js';
+import { StreamMessages } from '../types.js';
+import { Packed } from '@/misc/schema.js';
export default class extends Channel {
public readonly chName = 'channel';
@@ -15,7 +14,11 @@ export default class extends Channel {
private typers: Record = {};
private emitTypersIntervalId: ReturnType;
- @autobind
+ constructor(id: string, connection: Channel['connection']) {
+ super(id, connection);
+ this.onNote = this.onNote.bind(this);
+ }
+
public async init(params: any) {
this.channelId = params.channelId as string;
@@ -25,7 +28,6 @@ export default class extends Channel {
this.emitTypersIntervalId = setInterval(this.emitTypers, 5000);
}
- @autobind
private async onNote(note: Packed<'Note'>) {
if (note.channelId !== this.channelId) return;
@@ -52,7 +54,6 @@ export default class extends Channel {
this.send('note', note);
}
- @autobind
private onEvent(data: StreamMessages['channel']['payload']) {
if (data.type === 'typing') {
const id = data.body;
@@ -64,7 +65,6 @@ export default class extends Channel {
}
}
- @autobind
private async emitTypers() {
const now = new Date();
@@ -81,7 +81,6 @@ export default class extends Channel {
});
}
- @autobind
public dispose() {
// Unsubscribe events
this.subscriber.off('notesStream', this.onNote);
diff --git a/packages/backend/src/server/api/stream/channels/drive.ts b/packages/backend/src/server/api/stream/channels/drive.ts
index 4112dd9b0..140255acd 100644
--- a/packages/backend/src/server/api/stream/channels/drive.ts
+++ b/packages/backend/src/server/api/stream/channels/drive.ts
@@ -1,12 +1,10 @@
-import autobind from 'autobind-decorator';
-import Channel from '../channel';
+import Channel from '../channel.js';
export default class extends Channel {
public readonly chName = 'drive';
public static shouldShare = true;
public static requireCredential = true;
- @autobind
public async init(params: any) {
// Subscribe drive stream
this.subscriber.on(`driveStream:${this.user!.id}`, data => {
diff --git a/packages/backend/src/server/api/stream/channels/global-timeline.ts b/packages/backend/src/server/api/stream/channels/global-timeline.ts
index ecd87d093..1c7e038ab 100644
--- a/packages/backend/src/server/api/stream/channels/global-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts
@@ -1,19 +1,22 @@
-import autobind from 'autobind-decorator';
-import { isMutedUserRelated } from '@/misc/is-muted-user-related';
-import Channel from '../channel';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { Notes } from '@/models/index';
-import { checkWordMute } from '@/misc/check-word-mute';
-import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
-import { isInstanceMuted } from '@/misc/is-instance-muted';
-import { Packed } from '@/misc/schema';
+import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
+import Channel from '../channel.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { Notes } from '@/models/index.js';
+import { checkWordMute } from '@/misc/check-word-mute.js';
+import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
+import { isInstanceMuted } from '@/misc/is-instance-muted.js';
+import { Packed } from '@/misc/schema.js';
export default class extends Channel {
public readonly chName = 'globalTimeline';
public static shouldShare = true;
public static requireCredential = false;
- @autobind
+ constructor(id: string, connection: Channel['connection']) {
+ super(id, connection);
+ this.onNote = this.onNote.bind(this);
+ }
+
public async init(params: any) {
const meta = await fetchMeta();
if (meta.disableGlobalTimeline) {
@@ -24,7 +27,6 @@ export default class extends Channel {
this.subscriber.on('notesStream', this.onNote);
}
- @autobind
private async onNote(note: Packed<'Note'>) {
if (note.visibility !== 'public') return;
if (note.channelId != null) return;
@@ -69,7 +71,6 @@ export default class extends Channel {
this.send('note', note);
}
- @autobind
public dispose() {
// Unsubscribe events
this.subscriber.off('notesStream', this.onNote);
diff --git a/packages/backend/src/server/api/stream/channels/hashtag.ts b/packages/backend/src/server/api/stream/channels/hashtag.ts
index 820095dfc..1b7a58022 100644
--- a/packages/backend/src/server/api/stream/channels/hashtag.ts
+++ b/packages/backend/src/server/api/stream/channels/hashtag.ts
@@ -1,10 +1,9 @@
-import autobind from 'autobind-decorator';
-import { isMutedUserRelated } from '@/misc/is-muted-user-related';
-import Channel from '../channel';
-import { Notes } from '@/models/index';
-import { normalizeForSearch } from '@/misc/normalize-for-search';
-import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
-import { Packed } from '@/misc/schema';
+import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
+import Channel from '../channel.js';
+import { Notes } from '@/models/index.js';
+import { normalizeForSearch } from '@/misc/normalize-for-search.js';
+import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
+import { Packed } from '@/misc/schema.js';
export default class extends Channel {
public readonly chName = 'hashtag';
@@ -12,7 +11,11 @@ export default class extends Channel {
public static requireCredential = false;
private q: string[][];
- @autobind
+ constructor(id: string, connection: Channel['connection']) {
+ super(id, connection);
+ this.onNote = this.onNote.bind(this);
+ }
+
public async init(params: any) {
this.q = params.q;
@@ -22,7 +25,6 @@ export default class extends Channel {
this.subscriber.on('notesStream', this.onNote);
}
- @autobind
private async onNote(note: Packed<'Note'>) {
const noteTags = note.tags ? note.tags.map((t: string) => t.toLowerCase()) : [];
const matched = this.q.some(tags => tags.every(tag => noteTags.includes(normalizeForSearch(tag))));
@@ -45,7 +47,6 @@ export default class extends Channel {
this.send('note', note);
}
- @autobind
public dispose() {
// Unsubscribe events
this.subscriber.off('notesStream', this.onNote);
diff --git a/packages/backend/src/server/api/stream/channels/home-timeline.ts b/packages/backend/src/server/api/stream/channels/home-timeline.ts
index 445db5c38..3a8e55202 100644
--- a/packages/backend/src/server/api/stream/channels/home-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts
@@ -1,24 +1,26 @@
-import autobind from 'autobind-decorator';
-import { isMutedUserRelated } from '@/misc/is-muted-user-related';
-import Channel from '../channel';
-import { Notes } from '@/models/index';
-import { checkWordMute } from '@/misc/check-word-mute';
-import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
-import { isInstanceMuted } from '@/misc/is-instance-muted';
-import { Packed } from '@/misc/schema';
+import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
+import Channel from '../channel.js';
+import { Notes } from '@/models/index.js';
+import { checkWordMute } from '@/misc/check-word-mute.js';
+import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
+import { isInstanceMuted } from '@/misc/is-instance-muted.js';
+import { Packed } from '@/misc/schema.js';
export default class extends Channel {
public readonly chName = 'homeTimeline';
public static shouldShare = true;
public static requireCredential = true;
- @autobind
+ constructor(id: string, connection: Channel['connection']) {
+ super(id, connection);
+ this.onNote = this.onNote.bind(this);
+ }
+
public async init(params: any) {
// Subscribe events
this.subscriber.on('notesStream', this.onNote);
}
- @autobind
private async onNote(note: Packed<'Note'>) {
if (note.channelId) {
if (!this.followingChannels.has(note.channelId)) return;
@@ -77,7 +79,6 @@ export default class extends Channel {
this.send('note', note);
}
- @autobind
public dispose() {
// Unsubscribe events
this.subscriber.off('notesStream', this.onNote);
diff --git a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts
index c0be71fe2..f3ceeffa1 100644
--- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts
@@ -1,19 +1,22 @@
-import autobind from 'autobind-decorator';
-import { isMutedUserRelated } from '@/misc/is-muted-user-related';
-import Channel from '../channel';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { Notes } from '@/models/index';
-import { checkWordMute } from '@/misc/check-word-mute';
-import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
-import { isInstanceMuted } from '@/misc/is-instance-muted';
-import { Packed } from '@/misc/schema';
+import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
+import Channel from '../channel.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { Notes } from '@/models/index.js';
+import { checkWordMute } from '@/misc/check-word-mute.js';
+import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
+import { isInstanceMuted } from '@/misc/is-instance-muted.js';
+import { Packed } from '@/misc/schema.js';
export default class extends Channel {
public readonly chName = 'hybridTimeline';
public static shouldShare = true;
public static requireCredential = true;
- @autobind
+ constructor(id: string, connection: Channel['connection']) {
+ super(id, connection);
+ this.onNote = this.onNote.bind(this);
+ }
+
public async init(params: any) {
const meta = await fetchMeta();
if (meta.disableLocalTimeline && !this.user!.isAdmin && !this.user!.isModerator) return;
@@ -22,7 +25,6 @@ export default class extends Channel {
this.subscriber.on('notesStream', this.onNote);
}
- @autobind
private async onNote(note: Packed<'Note'>) {
// チャンネルの投稿ではなく、自分自身の投稿 または
// チャンネルの投稿ではなく、その投稿のユーザーをフォローしている または
@@ -85,7 +87,6 @@ export default class extends Channel {
this.send('note', note);
}
- @autobind
public dispose() {
// Unsubscribe events
this.subscriber.off('notesStream', this.onNote);
diff --git a/packages/backend/src/server/api/stream/channels/index.ts b/packages/backend/src/server/api/stream/channels/index.ts
index f3826c4cf..d422edde8 100644
--- a/packages/backend/src/server/api/stream/channels/index.ts
+++ b/packages/backend/src/server/api/stream/channels/index.ts
@@ -1,18 +1,18 @@
-import main from './main';
-import homeTimeline from './home-timeline';
-import localTimeline from './local-timeline';
-import hybridTimeline from './hybrid-timeline';
-import globalTimeline from './global-timeline';
-import serverStats from './server-stats';
-import queueStats from './queue-stats';
-import userList from './user-list';
-import antenna from './antenna';
-import messaging from './messaging';
-import messagingIndex from './messaging-index';
-import drive from './drive';
-import hashtag from './hashtag';
-import channel from './channel';
-import admin from './admin';
+import main from './main.js';
+import homeTimeline from './home-timeline.js';
+import localTimeline from './local-timeline.js';
+import hybridTimeline from './hybrid-timeline.js';
+import globalTimeline from './global-timeline.js';
+import serverStats from './server-stats.js';
+import queueStats from './queue-stats.js';
+import userList from './user-list.js';
+import antenna from './antenna.js';
+import messaging from './messaging.js';
+import messagingIndex from './messaging-index.js';
+import drive from './drive.js';
+import hashtag from './hashtag.js';
+import channel from './channel.js';
+import admin from './admin.js';
export default {
main,
diff --git a/packages/backend/src/server/api/stream/channels/local-timeline.ts b/packages/backend/src/server/api/stream/channels/local-timeline.ts
index ae8f62ba6..4e198482a 100644
--- a/packages/backend/src/server/api/stream/channels/local-timeline.ts
+++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts
@@ -1,18 +1,21 @@
-import autobind from 'autobind-decorator';
-import { isMutedUserRelated } from '@/misc/is-muted-user-related';
-import Channel from '../channel';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { Notes } from '@/models/index';
-import { checkWordMute } from '@/misc/check-word-mute';
-import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
-import { Packed } from '@/misc/schema';
+import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
+import Channel from '../channel.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { Notes } from '@/models/index.js';
+import { checkWordMute } from '@/misc/check-word-mute.js';
+import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
+import { Packed } from '@/misc/schema.js';
export default class extends Channel {
public readonly chName = 'localTimeline';
public static shouldShare = true;
public static requireCredential = false;
- @autobind
+ constructor(id: string, connection: Channel['connection']) {
+ super(id, connection);
+ this.onNote = this.onNote.bind(this);
+ }
+
public async init(params: any) {
const meta = await fetchMeta();
if (meta.disableLocalTimeline) {
@@ -23,7 +26,6 @@ export default class extends Channel {
this.subscriber.on('notesStream', this.onNote);
}
- @autobind
private async onNote(note: Packed<'Note'>) {
if (note.user.host !== null) return;
if (note.visibility !== 'public') return;
@@ -66,7 +68,6 @@ export default class extends Channel {
this.send('note', note);
}
- @autobind
public dispose() {
// Unsubscribe events
this.subscriber.off('notesStream', this.onNote);
diff --git a/packages/backend/src/server/api/stream/channels/main.ts b/packages/backend/src/server/api/stream/channels/main.ts
index b41eae7c7..9cfea0bfc 100644
--- a/packages/backend/src/server/api/stream/channels/main.ts
+++ b/packages/backend/src/server/api/stream/channels/main.ts
@@ -1,14 +1,12 @@
-import autobind from 'autobind-decorator';
-import Channel from '../channel';
-import { Notes } from '@/models/index';
-import { isInstanceMuted, isUserFromMutedInstance } from '@/misc/is-instance-muted';
+import Channel from '../channel.js';
+import { Notes } from '@/models/index.js';
+import { isInstanceMuted, isUserFromMutedInstance } from '@/misc/is-instance-muted.js';
export default class extends Channel {
public readonly chName = 'main';
public static shouldShare = true;
public static requireCredential = true;
- @autobind
public async init(params: any) {
// Subscribe main stream channel
this.subscriber.on(`mainStream:${this.user!.id}`, async data => {
diff --git a/packages/backend/src/server/api/stream/channels/messaging-index.ts b/packages/backend/src/server/api/stream/channels/messaging-index.ts
index 0c495398a..b930785d2 100644
--- a/packages/backend/src/server/api/stream/channels/messaging-index.ts
+++ b/packages/backend/src/server/api/stream/channels/messaging-index.ts
@@ -1,12 +1,10 @@
-import autobind from 'autobind-decorator';
-import Channel from '../channel';
+import Channel from '../channel.js';
export default class extends Channel {
public readonly chName = 'messagingIndex';
public static shouldShare = true;
public static requireCredential = true;
- @autobind
public async init(params: any) {
// Subscribe messaging index stream
this.subscriber.on(`messagingIndexStream:${this.user!.id}`, data => {
diff --git a/packages/backend/src/server/api/stream/channels/messaging.ts b/packages/backend/src/server/api/stream/channels/messaging.ts
index d8fccf076..94bbdeca5 100644
--- a/packages/backend/src/server/api/stream/channels/messaging.ts
+++ b/packages/backend/src/server/api/stream/channels/messaging.ts
@@ -1,10 +1,9 @@
-import autobind from 'autobind-decorator';
-import { readUserMessagingMessage, readGroupMessagingMessage, deliverReadActivity } from '../../common/read-messaging-message';
-import Channel from '../channel';
-import { UserGroupJoinings, Users, MessagingMessages } from '@/models/index';
-import { User, ILocalUser, IRemoteUser } from '@/models/entities/user';
-import { UserGroup } from '@/models/entities/user-group';
-import { StreamMessages } from '../types';
+import { readUserMessagingMessage, readGroupMessagingMessage, deliverReadActivity } from '../../common/read-messaging-message.js';
+import Channel from '../channel.js';
+import { UserGroupJoinings, Users, MessagingMessages } from '@/models/index.js';
+import { User, ILocalUser, IRemoteUser } from '@/models/entities/user.js';
+import { UserGroup } from '@/models/entities/user-group.js';
+import { StreamMessages } from '../types.js';
export default class extends Channel {
public readonly chName = 'messaging';
@@ -18,7 +17,13 @@ export default class extends Channel {
private typers: Record = {};
private emitTypersIntervalId: ReturnType;
- @autobind
+ constructor(id: string, connection: Channel['connection']) {
+ super(id, connection);
+ this.onEvent = this.onEvent.bind(this);
+ this.onMessage = this.onMessage.bind(this);
+ this.emitTypers = this.emitTypers.bind(this);
+ }
+
public async init(params: any) {
this.otherpartyId = params.otherparty;
this.otherparty = this.otherpartyId ? await Users.findOneOrFail({ id: this.otherpartyId }) : null;
@@ -46,7 +51,6 @@ export default class extends Channel {
this.subscriber.on(this.subCh, this.onEvent);
}
- @autobind
private onEvent(data: StreamMessages['messaging']['payload'] | StreamMessages['groupMessaging']['payload']) {
if (data.type === 'typing') {
const id = data.body;
@@ -60,7 +64,6 @@ export default class extends Channel {
}
}
- @autobind
public onMessage(type: string, body: any) {
switch (type) {
case 'read':
@@ -80,7 +83,6 @@ export default class extends Channel {
}
}
- @autobind
private async emitTypers() {
const now = new Date();
@@ -97,7 +99,6 @@ export default class extends Channel {
});
}
- @autobind
public dispose() {
this.subscriber.off(this.subCh, this.onEvent);
diff --git a/packages/backend/src/server/api/stream/channels/queue-stats.ts b/packages/backend/src/server/api/stream/channels/queue-stats.ts
index be18438fa..043d03ab8 100644
--- a/packages/backend/src/server/api/stream/channels/queue-stats.ts
+++ b/packages/backend/src/server/api/stream/channels/queue-stats.ts
@@ -1,25 +1,27 @@
-import autobind from 'autobind-decorator';
-import Xev from 'xev';
-import Channel from '../channel';
+import { default as Xev } from 'xev';
+import Channel from '../channel.js';
-const ev = new Xev();
+const ev = new Xev.default();
export default class extends Channel {
public readonly chName = 'queueStats';
public static shouldShare = true;
public static requireCredential = false;
- @autobind
+ constructor(id: string, connection: Channel['connection']) {
+ super(id, connection);
+ this.onStats = this.onStats.bind(this);
+ this.onMessage = this.onMessage.bind(this);
+ }
+
public async init(params: any) {
ev.addListener('queueStats', this.onStats);
}
- @autobind
private onStats(stats: any) {
this.send('stats', stats);
}
- @autobind
public onMessage(type: string, body: any) {
switch (type) {
case 'requestLog':
@@ -34,7 +36,6 @@ export default class extends Channel {
}
}
- @autobind
public dispose() {
ev.removeListener('queueStats', this.onStats);
}
diff --git a/packages/backend/src/server/api/stream/channels/server-stats.ts b/packages/backend/src/server/api/stream/channels/server-stats.ts
index df89b4c75..0da189576 100644
--- a/packages/backend/src/server/api/stream/channels/server-stats.ts
+++ b/packages/backend/src/server/api/stream/channels/server-stats.ts
@@ -1,25 +1,27 @@
-import autobind from 'autobind-decorator';
-import Xev from 'xev';
-import Channel from '../channel';
+import { default as Xev } from 'xev';
+import Channel from '../channel.js';
-const ev = new Xev();
+const ev = new Xev.default();
export default class extends Channel {
public readonly chName = 'serverStats';
public static shouldShare = true;
public static requireCredential = false;
- @autobind
+ constructor(id: string, connection: Channel['connection']) {
+ super(id, connection);
+ this.onStats = this.onStats.bind(this);
+ this.onMessage = this.onMessage.bind(this);
+ }
+
public async init(params: any) {
ev.addListener('serverStats', this.onStats);
}
- @autobind
private onStats(stats: any) {
this.send('stats', stats);
}
- @autobind
public onMessage(type: string, body: any) {
switch (type) {
case 'requestLog':
@@ -34,7 +36,6 @@ export default class extends Channel {
}
}
- @autobind
public dispose() {
ev.removeListener('serverStats', this.onStats);
}
diff --git a/packages/backend/src/server/api/stream/channels/user-list.ts b/packages/backend/src/server/api/stream/channels/user-list.ts
index b75920a18..57523c848 100644
--- a/packages/backend/src/server/api/stream/channels/user-list.ts
+++ b/packages/backend/src/server/api/stream/channels/user-list.ts
@@ -1,10 +1,9 @@
-import autobind from 'autobind-decorator';
-import Channel from '../channel';
-import { Notes, UserListJoinings, UserLists } from '@/models/index';
-import { isMutedUserRelated } from '@/misc/is-muted-user-related';
-import { User } from '@/models/entities/user';
-import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
-import { Packed } from '@/misc/schema';
+import Channel from '../channel.js';
+import { Notes, UserListJoinings, UserLists } from '@/models/index.js';
+import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
+import { User } from '@/models/entities/user.js';
+import { isBlockerUserRelated } from '@/misc/is-blocker-user-related.js';
+import { Packed } from '@/misc/schema.js';
export default class extends Channel {
public readonly chName = 'userList';
@@ -14,7 +13,12 @@ export default class extends Channel {
public listUsers: User['id'][] = [];
private listUsersClock: NodeJS.Timer;
- @autobind
+ constructor(id: string, connection: Channel['connection']) {
+ super(id, connection);
+ this.updateListUsers = this.updateListUsers.bind(this);
+ this.onNote = this.onNote.bind(this);
+ }
+
public async init(params: any) {
this.listId = params.listId as string;
@@ -34,7 +38,6 @@ export default class extends Channel {
this.listUsersClock = setInterval(this.updateListUsers, 5000);
}
- @autobind
private async updateListUsers() {
const users = await UserListJoinings.find({
where: {
@@ -46,7 +49,6 @@ export default class extends Channel {
this.listUsers = users.map(x => x.userId);
}
- @autobind
private async onNote(note: Packed<'Note'>) {
if (!this.listUsers.includes(note.userId)) return;
@@ -81,7 +83,6 @@ export default class extends Channel {
this.send('note', note);
}
- @autobind
public dispose() {
// Unsubscribe events
this.subscriber.off(`userListStream:${this.listId}`, this.send);
diff --git a/packages/backend/src/server/api/stream/index.ts b/packages/backend/src/server/api/stream/index.ts
index 84689bca1..0cb38e2a9 100644
--- a/packages/backend/src/server/api/stream/index.ts
+++ b/packages/backend/src/server/api/stream/index.ts
@@ -1,21 +1,20 @@
-import autobind from 'autobind-decorator';
import * as websocket from 'websocket';
-import { readNotification } from '../common/read-notification';
-import call from '../call';
-import readNote from '@/services/note/read';
-import Channel from './channel';
-import channels from './channels/index';
+import { readNotification } from '../common/read-notification.js';
+import call from '../call.js';
+import readNote from '@/services/note/read.js';
+import Channel from './channel.js';
+import channels from './channels/index.js';
import { EventEmitter } from 'events';
-import { User } from '@/models/entities/user';
-import { Channel as ChannelModel } from '@/models/entities/channel';
-import { Users, Followings, Mutings, UserProfiles, ChannelFollowings, Blockings } from '@/models/index';
-import { ApiError } from '../error';
-import { AccessToken } from '@/models/entities/access-token';
-import { UserProfile } from '@/models/entities/user-profile';
-import { publishChannelStream, publishGroupMessagingStream, publishMessagingStream } from '@/services/stream';
-import { UserGroup } from '@/models/entities/user-group';
-import { StreamEventEmitter, StreamMessages } from './types';
-import { Packed } from '@/misc/schema';
+import { User } from '@/models/entities/user.js';
+import { Channel as ChannelModel } from '@/models/entities/channel.js';
+import { Users, Followings, Mutings, UserProfiles, ChannelFollowings, Blockings } from '@/models/index.js';
+import { ApiError } from '../error.js';
+import { AccessToken } from '@/models/entities/access-token.js';
+import { UserProfile } from '@/models/entities/user-profile.js';
+import { publishChannelStream, publishGroupMessagingStream, publishMessagingStream } from '@/services/stream.js';
+import { UserGroup } from '@/models/entities/user-group.js';
+import { StreamEventEmitter, StreamMessages } from './types.js';
+import { Packed } from '@/misc/schema.js';
/**
* Main stream connection
@@ -38,13 +37,18 @@ export default class Connection {
wsConnection: websocket.connection,
subscriber: EventEmitter,
user: User | null | undefined,
- token: AccessToken | null | undefined
+ token: AccessToken | null | undefined,
) {
this.wsConnection = wsConnection;
this.subscriber = subscriber;
if (user) this.user = user;
if (token) this.token = token;
+ this.onWsConnectionMessage = this.onWsConnectionMessage.bind(this);
+ this.onUserEvent = this.onUserEvent.bind(this);
+ this.onNoteStreamMessage = this.onNoteStreamMessage.bind(this);
+ this.onBroadcastMessage = this.onBroadcastMessage.bind(this);
+
this.wsConnection.on('message', this.onWsConnectionMessage);
this.subscriber.on('broadcast', data => {
@@ -62,7 +66,6 @@ export default class Connection {
}
}
- @autobind
private onUserEvent(data: StreamMessages['user']['payload']) { // { type, body }と展開するとそれぞれ型が分離してしまう
switch (data.type) {
case 'follow':
@@ -108,8 +111,8 @@ export default class Connection {
/**
* クライアントからメッセージ受信時
*/
- @autobind
- private async onWsConnectionMessage(data: websocket.IMessage) {
+ private async onWsConnectionMessage(data: websocket.Message) {
+ if (data.type !== 'utf8') return;
if (data.utf8Data == null) return;
let obj: Record;
@@ -143,12 +146,10 @@ export default class Connection {
}
}
- @autobind
private onBroadcastMessage(data: StreamMessages['broadcast']['payload']) {
this.sendMessageToWs(data.type, data.body);
}
- @autobind
public cacheNote(note: Packed<'Note'>) {
const add = (note: Packed<'Note'>) => {
const existIndex = this.cachedNotes.findIndex(n => n.id === note.id);
@@ -168,7 +169,6 @@ export default class Connection {
if (note.renote) add(note.renote);
}
- @autobind
private readNote(body: any) {
const id = body.id;
@@ -186,7 +186,6 @@ export default class Connection {
/**
* APIリクエスト要求時
*/
- @autobind
private async onApiRequest(payload: any) {
// 新鮮なデータを利用するためにユーザーをフェッチ
const user = this.user ? await Users.findOne(this.user.id) : null;
@@ -209,7 +208,6 @@ export default class Connection {
});
}
- @autobind
private onReadNotification(payload: any) {
if (!payload.id) return;
readNotification(this.user!.id, [payload.id]);
@@ -218,7 +216,6 @@ export default class Connection {
/**
* 投稿購読要求時
*/
- @autobind
private onSubscribeNote(payload: any) {
if (!payload.id) return;
@@ -236,7 +233,6 @@ export default class Connection {
/**
* 投稿購読解除要求時
*/
- @autobind
private onUnsubscribeNote(payload: any) {
if (!payload.id) return;
@@ -247,7 +243,6 @@ export default class Connection {
}
}
- @autobind
private async onNoteStreamMessage(data: StreamMessages['note']['payload']) {
this.sendMessageToWs('noteUpdated', {
id: data.body.id,
@@ -259,7 +254,6 @@ export default class Connection {
/**
* チャンネル接続要求時
*/
- @autobind
private onChannelConnectRequested(payload: any) {
const { channel, id, params, pong } = payload;
this.connectChannel(id, params, channel, pong);
@@ -268,7 +262,6 @@ export default class Connection {
/**
* チャンネル切断要求時
*/
- @autobind
private onChannelDisconnectRequested(payload: any) {
const { id } = payload;
this.disconnectChannel(id);
@@ -277,7 +270,6 @@ export default class Connection {
/**
* クライアントにメッセージ送信
*/
- @autobind
public sendMessageToWs(type: string, payload: any) {
this.wsConnection.send(JSON.stringify({
type: type,
@@ -288,7 +280,6 @@ export default class Connection {
/**
* チャンネルに接続
*/
- @autobind
public connectChannel(id: string, params: any, channel: string, pong = false) {
if ((channels as any)[channel].requireCredential && this.user == null) {
return;
@@ -314,7 +305,6 @@ export default class Connection {
* チャンネルから切断
* @param id チャンネルコネクションID
*/
- @autobind
public disconnectChannel(id: string) {
const channel = this.channels.find(c => c.id === id);
@@ -328,7 +318,6 @@ export default class Connection {
* チャンネルへメッセージ送信要求時
* @param data メッセージ
*/
- @autobind
private onChannelMessageRequested(data: any) {
const channel = this.channels.find(c => c.id === data.id);
if (channel != null && channel.onMessage != null) {
@@ -336,14 +325,12 @@ export default class Connection {
}
}
- @autobind
private typingOnChannel(channel: ChannelModel['id']) {
if (this.user) {
publishChannelStream(channel, 'typing', this.user.id);
}
}
- @autobind
private typingOnMessaging(param: { partner?: User['id']; group?: UserGroup['id']; }) {
if (this.user) {
if (param.partner) {
@@ -354,7 +341,6 @@ export default class Connection {
}
}
- @autobind
private async updateFollowing() {
const followings = await Followings.find({
where: {
@@ -366,7 +352,6 @@ export default class Connection {
this.following = new Set(followings.map(x => x.followeeId));
}
- @autobind
private async updateMuting() {
const mutings = await Mutings.find({
where: {
@@ -378,7 +363,6 @@ export default class Connection {
this.muting = new Set(mutings.map(x => x.muteeId));
}
- @autobind
private async updateBlocking() { // ここでいうBlockingは被Blockingの意
const blockings = await Blockings.find({
where: {
@@ -390,7 +374,6 @@ export default class Connection {
this.blocking = new Set(blockings.map(x => x.blockerId));
}
- @autobind
private async updateFollowingChannels() {
const followings = await ChannelFollowings.find({
where: {
@@ -402,7 +385,6 @@ export default class Connection {
this.followingChannels = new Set(followings.map(x => x.followeeId));
}
- @autobind
private async updateUserProfile() {
this.userProfile = await UserProfiles.findOne({
userId: this.user!.id,
@@ -412,7 +394,6 @@ export default class Connection {
/**
* ストリームが切れたとき
*/
- @autobind
public dispose() {
for (const c of this.channels.filter(c => c.dispose)) {
if (c.dispose) c.dispose();
diff --git a/packages/backend/src/server/api/stream/types.ts b/packages/backend/src/server/api/stream/types.ts
index e2f1c6fc9..90cf59038 100644
--- a/packages/backend/src/server/api/stream/types.ts
+++ b/packages/backend/src/server/api/stream/types.ts
@@ -1,20 +1,20 @@
import { EventEmitter } from 'events';
import Emitter from 'strict-event-emitter-types';
-import { Channel } from '@/models/entities/channel';
-import { User } from '@/models/entities/user';
-import { UserProfile } from '@/models/entities/user-profile';
-import { Note } from '@/models/entities/note';
-import { Antenna } from '@/models/entities/antenna';
-import { DriveFile } from '@/models/entities/drive-file';
-import { DriveFolder } from '@/models/entities/drive-folder';
-import { Emoji } from '@/models/entities/emoji';
-import { UserList } from '@/models/entities/user-list';
-import { MessagingMessage } from '@/models/entities/messaging-message';
-import { UserGroup } from '@/models/entities/user-group';
-import { AbuseUserReport } from '@/models/entities/abuse-user-report';
-import { Signin } from '@/models/entities/signin';
-import { Page } from '@/models/entities/page';
-import { Packed } from '@/misc/schema';
+import { Channel } from '@/models/entities/channel.js';
+import { User } from '@/models/entities/user.js';
+import { UserProfile } from '@/models/entities/user-profile.js';
+import { Note } from '@/models/entities/note.js';
+import { Antenna } from '@/models/entities/antenna.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { DriveFolder } from '@/models/entities/drive-folder.js';
+import { Emoji } from '@/models/entities/emoji.js';
+import { UserList } from '@/models/entities/user-list.js';
+import { MessagingMessage } from '@/models/entities/messaging-message.js';
+import { UserGroup } from '@/models/entities/user-group.js';
+import { AbuseUserReport } from '@/models/entities/abuse-user-report.js';
+import { Signin } from '@/models/entities/signin.js';
+import { Page } from '@/models/entities/page.js';
+import { Packed } from '@/misc/schema.js';
//#region Stream type-body definitions
export interface InternalStreamTypes {
@@ -84,6 +84,7 @@ export interface MainStreamTypes {
};
driveFileCreated: Packed<'DriveFile'>;
readAntenna: Antenna;
+ receiveFollowRequest: Packed<'User'>;
}
export interface DriveStreamTypes {
diff --git a/packages/backend/src/server/api/streaming.ts b/packages/backend/src/server/api/streaming.ts
index b706b1b8d..2a34edac6 100644
--- a/packages/backend/src/server/api/streaming.ts
+++ b/packages/backend/src/server/api/streaming.ts
@@ -1,14 +1,14 @@
import * as http from 'http';
import * as websocket from 'websocket';
-import MainStreamConnection from './stream/index';
+import MainStreamConnection from './stream/index.js';
import { ParsedUrlQuery } from 'querystring';
-import authenticate from './authenticate';
+import authenticate from './authenticate.js';
import { EventEmitter } from 'events';
-import { subsdcriber as redisClient } from '../../db/redis';
-import { Users } from '@/models/index';
+import { subsdcriber as redisClient } from '../../db/redis.js';
+import { Users } from '@/models/index.js';
-module.exports = (server: http.Server) => {
+export const initializeStreamingServer = (server: http.Server) => {
// Init websocket server
const ws = new websocket.server({
httpServer: server,
diff --git a/packages/backend/src/server/file/index.ts b/packages/backend/src/server/file/index.ts
index 6fe6110dc..07a493700 100644
--- a/packages/backend/src/server/file/index.ts
+++ b/packages/backend/src/server/file/index.ts
@@ -2,16 +2,15 @@
* File Server
*/
-import * as fs from 'fs';
-import { fileURLToPath } from 'url';
-import { dirname } from 'path';
-import * as Koa from 'koa';
-import * as cors from '@koa/cors';
-import * as Router from '@koa/router';
-import sendDriveFile from './send-drive-file';
+import * as fs from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { dirname } from 'node:path';
+import Koa from 'koa';
+import cors from '@koa/cors';
+import Router from '@koa/router';
+import sendDriveFile from './send-drive-file.js';
-//const _filename = fileURLToPath(import.meta.url);
-const _filename = __filename;
+const _filename = fileURLToPath(import.meta.url);
const _dirname = dirname(_filename);
// Init app
@@ -38,4 +37,4 @@ router.get('/:key/(.*)', sendDriveFile);
// Register router
app.use(router.routes());
-module.exports = app;
+export default app;
diff --git a/packages/backend/src/server/file/send-drive-file.ts b/packages/backend/src/server/file/send-drive-file.ts
index f3c6c518f..4e2bba0e2 100644
--- a/packages/backend/src/server/file/send-drive-file.ts
+++ b/packages/backend/src/server/file/send-drive-file.ts
@@ -1,23 +1,22 @@
-import * as fs from 'fs';
-import { fileURLToPath } from 'url';
-import { dirname } from 'path';
-import * as Koa from 'koa';
+import * as fs from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { dirname } from 'node:path';
+import Koa from 'koa';
import * as send from 'koa-send';
-import * as rename from 'rename';
+import rename from 'rename';
import * as tmp from 'tmp';
-import { serverLogger } from '../index';
-import { contentDisposition } from '@/misc/content-disposition';
-import { DriveFiles } from '@/models/index';
-import { InternalStorage } from '@/services/drive/internal-storage';
-import { downloadUrl } from '@/misc/download-url';
-import { detectType } from '@/misc/get-file-info';
-import { convertToJpeg, convertToPng, convertToPngOrJpeg } from '@/services/drive/image-processor';
-import { GenerateVideoThumbnail } from '@/services/drive/generate-video-thumbnail';
-import { StatusError } from '@/misc/fetch';
-import { FILE_TYPE_BROWSERSAFE } from '@/const';
+import { serverLogger } from '../index.js';
+import { contentDisposition } from '@/misc/content-disposition.js';
+import { DriveFiles } from '@/models/index.js';
+import { InternalStorage } from '@/services/drive/internal-storage.js';
+import { downloadUrl } from '@/misc/download-url.js';
+import { detectType } from '@/misc/get-file-info.js';
+import { convertToJpeg, convertToPng, convertToPngOrJpeg } from '@/services/drive/image-processor.js';
+import { GenerateVideoThumbnail } from '@/services/drive/generate-video-thumbnail.js';
+import { StatusError } from '@/misc/fetch.js';
+import { FILE_TYPE_BROWSERSAFE } from '@/const.js';
-//const _filename = fileURLToPath(import.meta.url);
-const _filename = __filename;
+const _filename = fileURLToPath(import.meta.url);
const _dirname = dirname(_filename);
const assets = `${_dirname}/../../server/file/assets/`;
diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts
index 4d6b402e6..95a9ec6a0 100644
--- a/packages/backend/src/server/index.ts
+++ b/packages/backend/src/server/index.ts
@@ -2,28 +2,30 @@
* Core Server
*/
-import * as fs from 'fs';
+import * as fs from 'node:fs';
import * as http from 'http';
-import * as http2 from 'http2';
-import * as https from 'https';
-import * as Koa from 'koa';
-import * as Router from '@koa/router';
-import * as mount from 'koa-mount';
-import * as koaLogger from 'koa-logger';
+import Koa from 'koa';
+import Router from '@koa/router';
+import mount from 'koa-mount';
+import koaLogger from 'koa-logger';
import * as slow from 'koa-slow';
-import activityPub from './activitypub';
-import nodeinfo from './nodeinfo';
-import wellKnown from './well-known';
-import config from '@/config/index';
-import apiServer from './api/index';
-import Logger from '@/services/logger';
-import { envOption } from '../env';
-import { UserProfiles, Users } from '@/models/index';
-import { genIdenticon } from '@/misc/gen-identicon';
-import { createTemp } from '@/misc/create-temp';
-import { publishMainStream } from '@/services/stream';
-import * as Acct from 'misskey-js/built/acct';
+import activityPub from './activitypub.js';
+import nodeinfo from './nodeinfo.js';
+import wellKnown from './well-known.js';
+import config from '@/config/index.js';
+import apiServer from './api/index.js';
+import fileServer from './file/index.js';
+import proxyServer from './proxy/index.js';
+import webServer from './web/index.js';
+import Logger from '@/services/logger.js';
+import { envOption } from '../env.js';
+import { UserProfiles, Users } from '@/models/index.js';
+import { genIdenticon } from '@/misc/gen-identicon.js';
+import { createTemp } from '@/misc/create-temp.js';
+import { publishMainStream } from '@/services/stream.js';
+import * as Acct from '@/misc/acct.js';
+import { initializeStreamingServer } from './api/streaming.js';
export const serverLogger = new Logger('server', 'gray', false);
@@ -55,8 +57,8 @@ if (config.url.startsWith('https') && !config.disableHsts) {
}
app.use(mount('/api', apiServer));
-app.use(mount('/files', require('./file')));
-app.use(mount('/proxy', require('./proxy')));
+app.use(mount('/files', fileServer));
+app.use(mount('/proxy', proxyServer));
// Init router
const router = new Router();
@@ -72,6 +74,8 @@ router.get('/avatar/@:acct', async ctx => {
usernameLower: username.toLowerCase(),
host: host === config.host ? null : host,
isSuspended: false,
+ }, {
+ relations: ['avatar'],
});
if (user) {
@@ -114,29 +118,18 @@ router.get('/verify-email/:code', async ctx => {
// Register router
app.use(router.routes());
-app.use(mount(require('./web')));
+app.use(mount(webServer));
function createServer() {
- if (config.https) {
- const certs: any = {};
- for (const k of Object.keys(config.https)) {
- certs[k] = fs.readFileSync(config.https[k]);
- }
- certs['allowHTTP1'] = true;
- return http2.createSecureServer(certs, app.callback()) as https.Server;
- } else {
- return http.createServer(app.callback());
- }
+ return http.createServer(app.callback());
}
// For testing
export const startServer = () => {
const server = createServer();
- // Init stream server
- require('./api/streaming')(server);
+ initializeStreamingServer(server);
- // Listen
server.listen(config.port);
return server;
@@ -145,9 +138,7 @@ export const startServer = () => {
export default () => new Promise(resolve => {
const server = createServer();
- // Init stream server
- require('./api/streaming')(server);
+ initializeStreamingServer(server);
- // Listen
server.listen(config.port, resolve);
});
diff --git a/packages/backend/src/server/nodeinfo.ts b/packages/backend/src/server/nodeinfo.ts
index 4209fc7f1..f4b56fc8a 100644
--- a/packages/backend/src/server/nodeinfo.ts
+++ b/packages/backend/src/server/nodeinfo.ts
@@ -1,8 +1,9 @@
-import * as Router from '@koa/router';
-import config from '@/config/index';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { Users, Notes } from '@/models/index';
+import Router from '@koa/router';
+import config from '@/config/index.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { Users, Notes } from '@/models/index.js';
import { MoreThan } from 'typeorm';
+import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
const router = new Router();
@@ -69,7 +70,7 @@ const nodeinfo2 = async () => {
emailRequiredForSignup: meta.emailRequiredForSignup,
enableHcaptcha: meta.enableHcaptcha,
enableRecaptcha: meta.enableRecaptcha,
- maxNoteTextLength: meta.maxNoteTextLength,
+ maxNoteTextLength: MAX_NOTE_TEXT_LENGTH,
enableTwitterIntegration: meta.enableTwitterIntegration,
enableGithubIntegration: meta.enableGithubIntegration,
enableDiscordIntegration: meta.enableDiscordIntegration,
diff --git a/packages/backend/src/server/proxy/index.ts b/packages/backend/src/server/proxy/index.ts
index 7a3094311..506ba10ef 100644
--- a/packages/backend/src/server/proxy/index.ts
+++ b/packages/backend/src/server/proxy/index.ts
@@ -2,10 +2,10 @@
* Media Proxy
*/
-import * as Koa from 'koa';
-import * as cors from '@koa/cors';
-import * as Router from '@koa/router';
-import { proxyMedia } from './proxy-media';
+import Koa from 'koa';
+import cors from '@koa/cors';
+import Router from '@koa/router';
+import { proxyMedia } from './proxy-media.js';
// Init app
const app = new Koa();
@@ -23,4 +23,4 @@ router.get('/:url*', proxyMedia);
// Register router
app.use(router.routes());
-module.exports = app;
+export default app;
diff --git a/packages/backend/src/server/proxy/proxy-media.ts b/packages/backend/src/server/proxy/proxy-media.ts
index b7dcd0292..3cc5b827a 100644
--- a/packages/backend/src/server/proxy/proxy-media.ts
+++ b/packages/backend/src/server/proxy/proxy-media.ts
@@ -1,12 +1,12 @@
-import * as fs from 'fs';
-import * as Koa from 'koa';
-import { serverLogger } from '../index';
-import { IImage, convertToPng, convertToJpeg } from '@/services/drive/image-processor';
-import { createTemp } from '@/misc/create-temp';
-import { downloadUrl } from '@/misc/download-url';
-import { detectType } from '@/misc/get-file-info';
-import { StatusError } from '@/misc/fetch';
-import { FILE_TYPE_BROWSERSAFE } from '@/const';
+import * as fs from 'node:fs';
+import Koa from 'koa';
+import { serverLogger } from '../index.js';
+import { IImage, convertToPng, convertToJpeg } from '@/services/drive/image-processor.js';
+import { createTemp } from '@/misc/create-temp.js';
+import { downloadUrl } from '@/misc/download-url.js';
+import { detectType } from '@/misc/get-file-info.js';
+import { StatusError } from '@/misc/fetch.js';
+import { FILE_TYPE_BROWSERSAFE } from '@/const.js';
export async function proxyMedia(ctx: Koa.Context) {
const url = 'url' in ctx.query ? ctx.query.url : 'https://' + ctx.params.url;
diff --git a/packages/backend/src/server/web/feed.ts b/packages/backend/src/server/web/feed.ts
index db589e086..b98e3f8bf 100644
--- a/packages/backend/src/server/web/feed.ts
+++ b/packages/backend/src/server/web/feed.ts
@@ -1,7 +1,7 @@
import { Feed } from 'feed';
-import config from '@/config/index';
-import { User } from '@/models/entities/user';
-import { Notes, DriveFiles, UserProfiles } from '@/models/index';
+import config from '@/config/index.js';
+import { User } from '@/models/entities/user.js';
+import { Notes, DriveFiles, UserProfiles } from '@/models/index.js';
import { In } from 'typeorm';
export default async function(user: User) {
diff --git a/packages/backend/src/server/web/index.ts b/packages/backend/src/server/web/index.ts
index 325121bba..cc4c2cc9c 100644
--- a/packages/backend/src/server/web/index.ts
+++ b/packages/backend/src/server/web/index.ts
@@ -2,24 +2,26 @@
* Web Client Server
*/
-import { dirname } from 'path';
+import { dirname } from 'node:path';
+import { fileURLToPath } from 'node:url';
import ms from 'ms';
-import * as Koa from 'koa';
-import * as Router from '@koa/router';
-import * as send from 'koa-send';
-import * as favicon from 'koa-favicon';
-import * as views from 'koa-views';
+import Koa from 'koa';
+import Router from '@koa/router';
+import send from 'koa-send';
+import favicon from 'koa-favicon';
+import views from 'koa-views';
-import packFeed from './feed';
-import { fetchMeta } from '@/misc/fetch-meta';
-import { genOpenapiSpec } from '../api/openapi/gen-spec';
-import config from '@/config/index';
-import { Users, Notes, UserProfiles, Pages, Channels, Clips, GalleryPosts } from '@/models/index';
-import * as Acct from 'misskey-js/built/acct';
-import { getNoteSummary } from '@/misc/get-note-summary';
+import packFeed from './feed.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import { genOpenapiSpec } from '../api/openapi/gen-spec.js';
+import config from '@/config/index.js';
+import { Users, Notes, UserProfiles, Pages, Channels, Clips, GalleryPosts } from '@/models/index.js';
+import * as Acct from '@/misc/acct.js';
+import { getNoteSummary } from '@/misc/get-note-summary.js';
+import { urlPreviewHandler } from './url-preview.js';
+import { manifestHandler } from './manifest.js';
-//const _filename = fileURLToPath(import.meta.url);
-const _filename = __filename;
+const _filename = fileURLToPath(import.meta.url);
const _dirname = dirname(_filename);
const staticAssets = `${_dirname}/../../../assets/`;
@@ -105,7 +107,7 @@ router.get('/sw.js', async ctx => {
});
// Manifest
-router.get('/manifest.json', require('./manifest'));
+router.get('/manifest.json', manifestHandler);
router.get('/robots.txt', async ctx => {
await send(ctx as any, '/robots.txt', {
@@ -123,7 +125,7 @@ router.get('/api-doc', async ctx => {
});
// URL preview endpoint
-router.get('/url', require('./url-preview'));
+router.get('/url', urlPreviewHandler);
router.get('/api.json', async ctx => {
ctx.body = genOpenapiSpec();
@@ -426,4 +428,4 @@ router.get('(.*)', async ctx => {
// Register router
app.use(router.routes());
-module.exports = app;
+export default app;
diff --git a/packages/backend/src/server/web/manifest.ts b/packages/backend/src/server/web/manifest.ts
index 464b893d6..bcbf9b76a 100644
--- a/packages/backend/src/server/web/manifest.ts
+++ b/packages/backend/src/server/web/manifest.ts
@@ -1,8 +1,8 @@
-import * as Koa from 'koa';
-import * as manifest from './manifest.json';
-import { fetchMeta } from '@/misc/fetch-meta';
+import Koa from 'koa';
+import manifest from './manifest.json' assert { type: 'json' };
+import { fetchMeta } from '@/misc/fetch-meta.js';
-module.exports = async (ctx: Koa.Context) => {
+export const manifestHandler = async (ctx: Koa.Context) => {
const json = JSON.parse(JSON.stringify(manifest));
const instance = await fetchMeta(true);
diff --git a/packages/backend/src/server/web/url-preview.ts b/packages/backend/src/server/web/url-preview.ts
index 26fffbea8..6bd8ead5b 100644
--- a/packages/backend/src/server/web/url-preview.ts
+++ b/packages/backend/src/server/web/url-preview.ts
@@ -1,14 +1,14 @@
-import * as Koa from 'koa';
+import Koa from 'koa';
import summaly from 'summaly';
-import { fetchMeta } from '@/misc/fetch-meta';
-import Logger from '@/services/logger';
-import config from '@/config/index';
-import { query } from '@/prelude/url';
-import { getJson } from '@/misc/fetch';
+import { fetchMeta } from '@/misc/fetch-meta.js';
+import Logger from '@/services/logger.js';
+import config from '@/config/index.js';
+import { query } from '@/prelude/url.js';
+import { getJson } from '@/misc/fetch.js';
const logger = new Logger('url-preview');
-module.exports = async (ctx: Koa.Context) => {
+export const urlPreviewHandler = async (ctx: Koa.Context) => {
const url = ctx.query.url;
if (typeof url !== 'string') {
ctx.status = 400;
@@ -31,7 +31,7 @@ module.exports = async (ctx: Koa.Context) => {
const summary = meta.summalyProxy ? await getJson(`${meta.summalyProxy}?${query({
url: url,
lang: lang ?? 'ja-JP',
- })}`) : await summaly(url, {
+ })}`) : await summaly.default(url, {
followRedirects: false,
lang: lang ?? 'ja-JP',
});
diff --git a/packages/backend/src/server/web/views/base.pug b/packages/backend/src/server/web/views/base.pug
index e1cb2cfa9..abacb1ccf 100644
--- a/packages/backend/src/server/web/views/base.pug
+++ b/packages/backend/src/server/web/views/base.pug
@@ -59,5 +59,5 @@ html
br
| Please turn on your JavaScript
div#splash
- img(src='/favicon.ico')
+ img(src= icon || '/static-assets/splash.png')
block content
diff --git a/packages/backend/src/server/well-known.ts b/packages/backend/src/server/well-known.ts
index d1f13b70b..7a5d08541 100644
--- a/packages/backend/src/server/well-known.ts
+++ b/packages/backend/src/server/well-known.ts
@@ -1,11 +1,11 @@
-import * as Router from '@koa/router';
+import Router from '@koa/router';
-import config from '@/config/index';
-import * as Acct from 'misskey-js/built/acct';
-import { links } from './nodeinfo';
-import { escapeAttribute, escapeValue } from '@/prelude/xml';
-import { Users } from '@/models/index';
-import { User } from '@/models/entities/user';
+import config from '@/config/index.js';
+import * as Acct from '@/misc/acct.js';
+import { links } from './nodeinfo.js';
+import { escapeAttribute, escapeValue } from '@/prelude/xml.js';
+import { Users } from '@/models/index.js';
+import { User } from '@/models/entities/user.js';
// Init router
const router = new Router();
diff --git a/packages/backend/src/services/add-note-to-antenna.ts b/packages/backend/src/services/add-note-to-antenna.ts
index 168e3a614..e88c38723 100644
--- a/packages/backend/src/services/add-note-to-antenna.ts
+++ b/packages/backend/src/services/add-note-to-antenna.ts
@@ -1,10 +1,10 @@
-import { Antenna } from '@/models/entities/antenna';
-import { Note } from '@/models/entities/note';
-import { AntennaNotes, Mutings, Notes } from '@/models/index';
-import { genId } from '@/misc/gen-id';
-import { isMutedUserRelated } from '@/misc/is-muted-user-related';
-import { publishAntennaStream, publishMainStream } from '@/services/stream';
-import { User } from '@/models/entities/user';
+import { Antenna } from '@/models/entities/antenna.js';
+import { Note } from '@/models/entities/note.js';
+import { AntennaNotes, Mutings, Notes } from '@/models/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { isMutedUserRelated } from '@/misc/is-muted-user-related.js';
+import { publishAntennaStream, publishMainStream } from '@/services/stream.js';
+import { User } from '@/models/entities/user.js';
export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: { id: User['id']; }) {
// 通知しない設定になっているか、自分自身の投稿なら既読にする
diff --git a/packages/backend/src/services/blocking/create.ts b/packages/backend/src/services/blocking/create.ts
index 907e4c311..198d28705 100644
--- a/packages/backend/src/services/blocking/create.ts
+++ b/packages/backend/src/services/blocking/create.ts
@@ -1,15 +1,15 @@
-import { publishMainStream, publishUserEvent } from '@/services/stream';
-import { renderActivity } from '@/remote/activitypub/renderer/index';
-import renderFollow from '@/remote/activitypub/renderer/follow';
-import renderUndo from '@/remote/activitypub/renderer/undo';
-import renderBlock from '@/remote/activitypub/renderer/block';
-import { deliver } from '@/queue/index';
-import renderReject from '@/remote/activitypub/renderer/reject';
-import { User } from '@/models/entities/user';
-import { Blockings, Users, FollowRequests, Followings, UserListJoinings, UserLists } from '@/models/index';
-import { perUserFollowingChart } from '@/services/chart/index';
-import { genId } from '@/misc/gen-id';
-import { IdentifiableError } from '@/misc/identifiable-error';
+import { publishMainStream, publishUserEvent } from '@/services/stream.js';
+import { renderActivity } from '@/remote/activitypub/renderer/index.js';
+import renderFollow from '@/remote/activitypub/renderer/follow.js';
+import renderUndo from '@/remote/activitypub/renderer/undo.js';
+import renderBlock from '@/remote/activitypub/renderer/block.js';
+import { deliver } from '@/queue/index.js';
+import renderReject from '@/remote/activitypub/renderer/reject.js';
+import { User } from '@/models/entities/user.js';
+import { Blockings, Users, FollowRequests, Followings, UserListJoinings, UserLists } from '@/models/index.js';
+import { perUserFollowingChart } from '@/services/chart/index.js';
+import { genId } from '@/misc/gen-id.js';
+import { IdentifiableError } from '@/misc/identifiable-error.js';
export default async function(blocker: User, blockee: User) {
await Promise.all([
diff --git a/packages/backend/src/services/blocking/delete.ts b/packages/backend/src/services/blocking/delete.ts
index 271bf4854..c4f3784b0 100644
--- a/packages/backend/src/services/blocking/delete.ts
+++ b/packages/backend/src/services/blocking/delete.ts
@@ -1,10 +1,10 @@
-import { renderActivity } from '@/remote/activitypub/renderer/index';
-import renderBlock from '@/remote/activitypub/renderer/block';
-import renderUndo from '@/remote/activitypub/renderer/undo';
-import { deliver } from '@/queue/index';
-import Logger from '../logger';
-import { User } from '@/models/entities/user';
-import { Blockings, Users } from '@/models/index';
+import { renderActivity } from '@/remote/activitypub/renderer/index.js';
+import renderBlock from '@/remote/activitypub/renderer/block.js';
+import renderUndo from '@/remote/activitypub/renderer/undo.js';
+import { deliver } from '@/queue/index.js';
+import Logger from '../logger.js';
+import { User } from '@/models/entities/user.js';
+import { Blockings, Users } from '@/models/index.js';
const logger = new Logger('blocking/delete');
diff --git a/packages/backend/src/services/chart/charts/active-users.ts b/packages/backend/src/services/chart/charts/active-users.ts
index 5baf46f77..d952ea53b 100644
--- a/packages/backend/src/services/chart/charts/active-users.ts
+++ b/packages/backend/src/services/chart/charts/active-users.ts
@@ -1,8 +1,7 @@
-import autobind from 'autobind-decorator';
-import Chart, { KVs } from '../core';
-import { User } from '@/models/entities/user';
-import { Users } from '@/models/index';
-import { name, schema } from './entities/active-users';
+import Chart, { KVs } from '../core.js';
+import { User } from '@/models/entities/user.js';
+import { Users } from '@/models/index.js';
+import { name, schema } from './entities/active-users.js';
const week = 1000 * 60 * 60 * 24 * 7;
const month = 1000 * 60 * 60 * 24 * 30;
@@ -17,17 +16,14 @@ export default class ActiveUsersChart extends Chart {
super(name, schema);
}
- @autobind
protected async tickMajor(): Promise>> {
return {};
}
- @autobind
protected async tickMinor(): Promise>> {
return {};
}
- @autobind
public async read(user: { id: User['id'], host: null, createdAt: User['createdAt'] }): Promise {
await this.commit({
'read': [user.id],
@@ -40,7 +36,6 @@ export default class ActiveUsersChart extends Chart {
});
}
- @autobind
public async write(user: { id: User['id'], host: null, createdAt: User['createdAt'] }): Promise {
await this.commit({
'write': [user.id],
diff --git a/packages/backend/src/services/chart/charts/ap-request.ts b/packages/backend/src/services/chart/charts/ap-request.ts
index ca763c884..e9e42ade7 100644
--- a/packages/backend/src/services/chart/charts/ap-request.ts
+++ b/packages/backend/src/services/chart/charts/ap-request.ts
@@ -1,6 +1,5 @@
-import autobind from 'autobind-decorator';
-import Chart, { KVs } from '../core';
-import { name, schema } from './entities/ap-request';
+import Chart, { KVs } from '../core.js';
+import { name, schema } from './entities/ap-request.js';
/**
* Chart about ActivityPub requests
@@ -11,31 +10,26 @@ export default class ApRequestChart extends Chart {
super(name, schema);
}
- @autobind
protected async tickMajor(): Promise>> {
return {};
}
- @autobind
protected async tickMinor(): Promise>> {
return {};
}
- @autobind
public async deliverSucc(): Promise {
await this.commit({
'deliverSucceeded': 1,
});
}
- @autobind
public async deliverFail(): Promise {
await this.commit({
'deliverFailed': 1,
});
}
- @autobind
public async inbox(): Promise {
await this.commit({
'inboxReceived': 1,
diff --git a/packages/backend/src/services/chart/charts/drive.ts b/packages/backend/src/services/chart/charts/drive.ts
index 288689784..0eeba90dd 100644
--- a/packages/backend/src/services/chart/charts/drive.ts
+++ b/packages/backend/src/services/chart/charts/drive.ts
@@ -1,9 +1,8 @@
-import autobind from 'autobind-decorator';
-import Chart, { KVs } from '../core';
-import { DriveFiles } from '@/models/index';
+import Chart, { KVs } from '../core.js';
+import { DriveFiles } from '@/models/index.js';
import { Not, IsNull } from 'typeorm';
-import { DriveFile } from '@/models/entities/drive-file';
-import { name, schema } from './entities/drive';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { name, schema } from './entities/drive.js';
/**
* ドライブに関するチャート
@@ -14,17 +13,14 @@ export default class DriveChart extends Chart {
super(name, schema);
}
- @autobind
protected async tickMajor(): Promise>> {
return {};
}
- @autobind
protected async tickMinor(): Promise>> {
return {};
}
- @autobind
public async update(file: DriveFile, isAdditional: boolean): Promise {
const fileSizeKb = file.size / 1000;
await this.commit(file.userHost === null ? {
diff --git a/packages/backend/src/services/chart/charts/entities/active-users.ts b/packages/backend/src/services/chart/charts/entities/active-users.ts
index 843843836..5767b76f8 100644
--- a/packages/backend/src/services/chart/charts/entities/active-users.ts
+++ b/packages/backend/src/services/chart/charts/entities/active-users.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'activeUsers';
diff --git a/packages/backend/src/services/chart/charts/entities/ap-request.ts b/packages/backend/src/services/chart/charts/entities/ap-request.ts
index 21fb40d13..3a9f3dacf 100644
--- a/packages/backend/src/services/chart/charts/entities/ap-request.ts
+++ b/packages/backend/src/services/chart/charts/entities/ap-request.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'apRequest';
diff --git a/packages/backend/src/services/chart/charts/entities/drive.ts b/packages/backend/src/services/chart/charts/entities/drive.ts
index c5cdfd85b..4bf5bb729 100644
--- a/packages/backend/src/services/chart/charts/entities/drive.ts
+++ b/packages/backend/src/services/chart/charts/entities/drive.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'drive';
diff --git a/packages/backend/src/services/chart/charts/entities/federation.ts b/packages/backend/src/services/chart/charts/entities/federation.ts
index 6b2089f0b..a8466b0b4 100644
--- a/packages/backend/src/services/chart/charts/entities/federation.ts
+++ b/packages/backend/src/services/chart/charts/entities/federation.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'federation';
@@ -8,6 +8,9 @@ export const schema = {
'stalled': { uniqueIncrement: true, range: 'small' },
'sub': { accumulate: true, range: 'small' },
'pub': { accumulate: true, range: 'small' },
+ 'pubsub': { accumulate: true, range: 'small' },
+ 'subActive': { accumulate: true, range: 'small' },
+ 'pubActive': { accumulate: true, range: 'small' },
} as const;
export const entity = Chart.schemaToEntity(name, schema);
diff --git a/packages/backend/src/services/chart/charts/entities/hashtag.ts b/packages/backend/src/services/chart/charts/entities/hashtag.ts
index bd2ae38a1..4d0403904 100644
--- a/packages/backend/src/services/chart/charts/entities/hashtag.ts
+++ b/packages/backend/src/services/chart/charts/entities/hashtag.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'hashtag';
diff --git a/packages/backend/src/services/chart/charts/entities/instance.ts b/packages/backend/src/services/chart/charts/entities/instance.ts
index b98e1640c..06962120e 100644
--- a/packages/backend/src/services/chart/charts/entities/instance.ts
+++ b/packages/backend/src/services/chart/charts/entities/instance.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'instance';
diff --git a/packages/backend/src/services/chart/charts/entities/notes.ts b/packages/backend/src/services/chart/charts/entities/notes.ts
index f9b9b20ee..9387dbfb2 100644
--- a/packages/backend/src/services/chart/charts/entities/notes.ts
+++ b/packages/backend/src/services/chart/charts/entities/notes.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'notes';
diff --git a/packages/backend/src/services/chart/charts/entities/per-user-drive.ts b/packages/backend/src/services/chart/charts/entities/per-user-drive.ts
index 00d85b162..6111640ea 100644
--- a/packages/backend/src/services/chart/charts/entities/per-user-drive.ts
+++ b/packages/backend/src/services/chart/charts/entities/per-user-drive.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'perUserDrive';
diff --git a/packages/backend/src/services/chart/charts/entities/per-user-following.ts b/packages/backend/src/services/chart/charts/entities/per-user-following.ts
index 1efd4977f..4118daa47 100644
--- a/packages/backend/src/services/chart/charts/entities/per-user-following.ts
+++ b/packages/backend/src/services/chart/charts/entities/per-user-following.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'perUserFollowing';
diff --git a/packages/backend/src/services/chart/charts/entities/per-user-notes.ts b/packages/backend/src/services/chart/charts/entities/per-user-notes.ts
index 562cde9b0..c1fa17445 100644
--- a/packages/backend/src/services/chart/charts/entities/per-user-notes.ts
+++ b/packages/backend/src/services/chart/charts/entities/per-user-notes.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'perUserNotes';
diff --git a/packages/backend/src/services/chart/charts/entities/per-user-reactions.ts b/packages/backend/src/services/chart/charts/entities/per-user-reactions.ts
index ab315d24c..5e1a6c7b3 100644
--- a/packages/backend/src/services/chart/charts/entities/per-user-reactions.ts
+++ b/packages/backend/src/services/chart/charts/entities/per-user-reactions.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'perUserReaction';
diff --git a/packages/backend/src/services/chart/charts/entities/test-grouped.ts b/packages/backend/src/services/chart/charts/entities/test-grouped.ts
index 78c2bbd54..66b6e8e86 100644
--- a/packages/backend/src/services/chart/charts/entities/test-grouped.ts
+++ b/packages/backend/src/services/chart/charts/entities/test-grouped.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'testGrouped';
diff --git a/packages/backend/src/services/chart/charts/entities/test-intersection.ts b/packages/backend/src/services/chart/charts/entities/test-intersection.ts
index dc56eb93f..a3bdcb367 100644
--- a/packages/backend/src/services/chart/charts/entities/test-intersection.ts
+++ b/packages/backend/src/services/chart/charts/entities/test-intersection.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'testIntersection';
diff --git a/packages/backend/src/services/chart/charts/entities/test-unique.ts b/packages/backend/src/services/chart/charts/entities/test-unique.ts
index dc7c1520e..b2cfb71b0 100644
--- a/packages/backend/src/services/chart/charts/entities/test-unique.ts
+++ b/packages/backend/src/services/chart/charts/entities/test-unique.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'testUnique';
diff --git a/packages/backend/src/services/chart/charts/entities/test.ts b/packages/backend/src/services/chart/charts/entities/test.ts
index edfa4c524..7cba21e16 100644
--- a/packages/backend/src/services/chart/charts/entities/test.ts
+++ b/packages/backend/src/services/chart/charts/entities/test.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'test';
diff --git a/packages/backend/src/services/chart/charts/entities/users.ts b/packages/backend/src/services/chart/charts/entities/users.ts
index d2cec7249..c0b83094a 100644
--- a/packages/backend/src/services/chart/charts/entities/users.ts
+++ b/packages/backend/src/services/chart/charts/entities/users.ts
@@ -1,4 +1,4 @@
-import Chart from '../../core';
+import Chart from '../../core.js';
export const name = 'users';
diff --git a/packages/backend/src/services/chart/charts/federation.ts b/packages/backend/src/services/chart/charts/federation.ts
index 211ba1deb..10221ee1e 100644
--- a/packages/backend/src/services/chart/charts/federation.ts
+++ b/packages/backend/src/services/chart/charts/federation.ts
@@ -1,7 +1,7 @@
-import autobind from 'autobind-decorator';
-import Chart, { KVs } from '../core';
-import { Followings } from '@/models/index';
-import { name, schema } from './entities/federation';
+import Chart, { KVs } from '../core.js';
+import { Followings, Instances } from '@/models/index.js';
+import { name, schema } from './entities/federation.js';
+import { fetchMeta } from '@/misc/fetch-meta.js';
/**
* フェデレーションに関するチャート
@@ -12,23 +12,68 @@ export default class FederationChart extends Chart {
super(name, schema);
}
- @autobind
protected async tickMajor(): Promise>> {
return {
};
}
- @autobind
protected async tickMinor(): Promise>> {
- const [sub, pub] = await Promise.all([
+ const meta = await fetchMeta();
+
+ const suspendedInstancesQuery = Instances.createQueryBuilder('instance')
+ .select('instance.host')
+ .where('instance.isSuspended = true');
+
+ const pubsubSubQuery = Followings.createQueryBuilder('f')
+ .select('f.followerHost')
+ .where('f.followerHost IS NOT NULL');
+
+ const subInstancesQuery = Followings.createQueryBuilder('f')
+ .select('f.followeeHost')
+ .where('f.followeeHost IS NOT NULL');
+
+ const pubInstancesQuery = Followings.createQueryBuilder('f')
+ .select('f.followerHost')
+ .where('f.followerHost IS NOT NULL');
+
+ const [sub, pub, pubsub, subActive, pubActive] = await Promise.all([
Followings.createQueryBuilder('following')
.select('COUNT(DISTINCT following.followeeHost)')
.where('following.followeeHost IS NOT NULL')
+ .andWhere(meta.blockedHosts.length === 0 ? '1=1' : `following.followeeHost NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
+ .andWhere(`following.followeeHost NOT IN (${ suspendedInstancesQuery.getQuery() })`)
.getRawOne()
.then(x => parseInt(x.count, 10)),
Followings.createQueryBuilder('following')
.select('COUNT(DISTINCT following.followerHost)')
.where('following.followerHost IS NOT NULL')
+ .andWhere(meta.blockedHosts.length === 0 ? '1=1' : `following.followerHost NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
+ .andWhere(`following.followerHost NOT IN (${ suspendedInstancesQuery.getQuery() })`)
+ .getRawOne()
+ .then(x => parseInt(x.count, 10)),
+ Followings.createQueryBuilder('following')
+ .select('COUNT(DISTINCT following.followeeHost)')
+ .where('following.followeeHost IS NOT NULL')
+ .andWhere(meta.blockedHosts.length === 0 ? '1=1' : `following.followeeHost NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
+ .andWhere(`following.followeeHost NOT IN (${ suspendedInstancesQuery.getQuery() })`)
+ .andWhere(`following.followeeHost IN (${ pubsubSubQuery.getQuery() })`)
+ .setParameters(pubsubSubQuery.getParameters())
+ .getRawOne()
+ .then(x => parseInt(x.count, 10)),
+ Instances.createQueryBuilder('instance')
+ .select('COUNT(instance.id)')
+ .where(`instance.host IN (${ subInstancesQuery.getQuery() })`)
+ .andWhere(meta.blockedHosts.length === 0 ? '1=1' : `instance.host NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
+ .andWhere(`instance.isSuspended = false`)
+ .andWhere(`instance.lastCommunicatedAt > :gt`, { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) })
+ .getRawOne()
+ .then(x => parseInt(x.count, 10)),
+ Instances.createQueryBuilder('instance')
+ .select('COUNT(instance.id)')
+ .where(`instance.host IN (${ pubInstancesQuery.getQuery() })`)
+ .andWhere(meta.blockedHosts.length === 0 ? '1=1' : `instance.host NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
+ .andWhere(`instance.isSuspended = false`)
+ .andWhere(`instance.lastCommunicatedAt > :gt`, { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) })
.getRawOne()
.then(x => parseInt(x.count, 10)),
]);
@@ -36,10 +81,12 @@ export default class FederationChart extends Chart {
return {
'sub': sub,
'pub': pub,
+ 'pubsub': pubsub,
+ 'subActive': subActive,
+ 'pubActive': pubActive,
};
}
- @autobind
public async deliverd(host: string, succeeded: boolean): Promise {
await this.commit(succeeded ? {
'deliveredInstances': [host],
@@ -48,7 +95,6 @@ export default class FederationChart extends Chart {
});
}
- @autobind
public async inbox(host: string): Promise {
await this.commit({
'inboxInstances': [host],
diff --git a/packages/backend/src/services/chart/charts/hashtag.ts b/packages/backend/src/services/chart/charts/hashtag.ts
index cbae68683..31f7fa95d 100644
--- a/packages/backend/src/services/chart/charts/hashtag.ts
+++ b/packages/backend/src/services/chart/charts/hashtag.ts
@@ -1,8 +1,7 @@
-import autobind from 'autobind-decorator';
-import Chart, { KVs } from '../core';
-import { User } from '@/models/entities/user';
-import { Users } from '@/models/index';
-import { name, schema } from './entities/hashtag';
+import Chart, { KVs } from '../core.js';
+import { User } from '@/models/entities/user.js';
+import { Users } from '@/models/index.js';
+import { name, schema } from './entities/hashtag.js';
/**
* ハッシュタグに関するチャート
@@ -13,17 +12,14 @@ export default class HashtagChart extends Chart {
super(name, schema, true);
}
- @autobind
protected async tickMajor(): Promise>> {
return {};
}
- @autobind
protected async tickMinor(): Promise>> {
return {};
}
- @autobind
public async update(hashtag: string, user: { id: User['id'], host: User['host'] }): Promise {
await this.commit({
'local.users': Users.isLocalUser(user) ? [user.id] : [],
diff --git a/packages/backend/src/services/chart/charts/instance.ts b/packages/backend/src/services/chart/charts/instance.ts
index 930ac4729..f1257fdf1 100644
--- a/packages/backend/src/services/chart/charts/instance.ts
+++ b/packages/backend/src/services/chart/charts/instance.ts
@@ -1,10 +1,9 @@
-import autobind from 'autobind-decorator';
-import Chart, { KVs } from '../core';
-import { DriveFiles, Followings, Users, Notes } from '@/models/index';
-import { DriveFile } from '@/models/entities/drive-file';
-import { Note } from '@/models/entities/note';
-import { toPuny } from '@/misc/convert-host';
-import { name, schema } from './entities/instance';
+import Chart, { KVs } from '../core.js';
+import { DriveFiles, Followings, Users, Notes } from '@/models/index.js';
+import { DriveFile } from '@/models/entities/drive-file.js';
+import { Note } from '@/models/entities/note.js';
+import { toPuny } from '@/misc/convert-host.js';
+import { name, schema } from './entities/instance.js';
/**
* インスタンスごとのチャート
@@ -15,7 +14,6 @@ export default class InstanceChart extends Chart