This commit is contained in:
syuilo
2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View File

@ -112,7 +112,7 @@ export function verifyLogin({
clientDataJSON,
clientData,
signature,
challenge
challenge,
}: {
publicKey: Buffer,
authenticatorData: Buffer,

View File

@ -19,8 +19,8 @@ export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise((res) => {
code: y!.code,
id: y!.id,
kind: y!.kind,
...(y!.info ? { info: y!.info } : {})
}
...(y!.info ? { info: y!.info } : {}),
},
};
} else {
// 文字列を返す場合は、JSON.stringify通さないとJSONと認識されない
@ -42,7 +42,7 @@ export default (endpoint: IEndpoint, ctx: Koa.Context) => new Promise((res) => {
reply(403, new ApiError({
message: 'Authentication failed. Please ensure your token is correct.',
code: 'AUTHENTICATION_FAILED',
id: 'b0a7f5f8-dc2f-4171-b91f-de88ad238e14'
id: 'b0a7f5f8-dc2f-4171-b91f-de88ad238e14',
}));
} else {
reply(500, new ApiError());

View File

@ -28,9 +28,9 @@ export default async (token: string): Promise<[User | null | undefined, App | nu
} else {
const accessToken = await AccessTokens.findOne({
where: [{
hash: token.toLowerCase() // app
hash: token.toLowerCase(), // app
}, {
token: token // miauth
token: token, // miauth
}],
});
@ -44,7 +44,7 @@ export default async (token: string): Promise<[User | null | undefined, App | nu
const user = await Users
.findOne({
id: accessToken.userId // findOne(accessToken.userId) のように書かないのは後方互換性のため
id: accessToken.userId, // findOne(accessToken.userId) のように書かないのは後方互換性のため
});
if (accessToken.appId) {
@ -53,7 +53,7 @@ export default async (token: string): Promise<[User | null | undefined, App | nu
return [user, {
id: accessToken.id,
permission: app.permission
permission: app.permission,
} as AccessToken];
} else {
return [user, accessToken];

View File

@ -9,7 +9,7 @@ import { AccessToken } from '@/models/entities/access-token';
const accessDenied = {
message: 'Access denied.',
code: 'ACCESS_DENIED',
id: '56f35758-7dd5-468b-8439-5d6fb8ec9b8e'
id: '56f35758-7dd5-468b-8439-5d6fb8ec9b8e',
};
export default async (endpoint: string, user: User | null | undefined, token: AccessToken | null | undefined, data: any, file?: any) => {
@ -22,7 +22,7 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
message: 'No such endpoint.',
code: 'NO_SUCH_ENDPOINT',
id: 'f8080b67-5f9c-4eb7-8c18-7f1eeae8f709',
httpStatusCode: 404
httpStatusCode: 404,
});
}
@ -35,7 +35,7 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
message: 'Credential required.',
code: 'CREDENTIAL_REQUIRED',
id: '1384574d-a912-4b81-8601-c7b1c4085df1',
httpStatusCode: 401
httpStatusCode: 401,
});
}
@ -44,7 +44,7 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
message: 'Your account has been suspended.',
code: 'YOUR_ACCOUNT_SUSPENDED',
id: 'a8c724b3-6e9c-4b46-b1a8-bc3ed6258370',
httpStatusCode: 403
httpStatusCode: 403,
});
}
@ -71,7 +71,7 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
message: 'Rate limit exceeded. Please try again later.',
code: 'RATE_LIMIT_EXCEEDED',
id: 'd5826d14-3982-4d2e-8011-b9e9f02499ef',
httpStatusCode: 429
httpStatusCode: 429,
});
});
}
@ -88,15 +88,15 @@ export default async (endpoint: string, user: User | null | undefined, token: Ac
e: {
message: e?.message,
code: e?.name,
stack: e?.stack
}
stack: e?.stack,
},
});
throw new ApiError(null, {
e: {
message: e?.message,
code: e?.name,
stack: e?.stack
}
stack: e?.stack,
},
});
}
}).finally(() => {

View File

@ -9,7 +9,7 @@ export async function injectPromo(timeline: Note[], user?: User | null) {
// TODO: readやexpireフィルタはクエリ側でやる
const reads = user ? await PromoReads.find({
userId: user.id
userId: user.id,
}) : [];
let promos = await PromoNotes.find();

View File

@ -24,7 +24,7 @@ export async function readUserMessagingMessage(
if (messageIds.length === 0) return;
const messages = await MessagingMessages.find({
id: In(messageIds)
id: In(messageIds),
});
for (const message of messages) {
@ -38,9 +38,9 @@ export async function readUserMessagingMessage(
id: In(messageIds),
userId: otherpartyId,
recipientId: userId,
isRead: false
isRead: false,
}, {
isRead: true
isRead: true,
});
// Publish event
@ -66,7 +66,7 @@ export async function readGroupMessagingMessage(
// check joined
const joining = await UserGroupJoinings.findOne({
userId: userId,
userGroupId: groupId
userGroupId: groupId,
});
if (joining == null) {
@ -74,7 +74,7 @@ export async function readGroupMessagingMessage(
}
const messages = await MessagingMessages.find({
id: In(messageIds)
id: In(messageIds),
});
const reads: MessagingMessage['id'][] = [];
@ -86,7 +86,7 @@ export async function readGroupMessagingMessage(
// Update document
await MessagingMessages.createQueryBuilder().update()
.set({
reads: (() => `array_append("reads", '${joining.userId}')`) as any
reads: (() => `array_append("reads", '${joining.userId}')`) as any,
})
.where('id = :id', { id: message.id })
.execute();
@ -97,7 +97,7 @@ export async function readGroupMessagingMessage(
// Publish event
publishGroupMessagingStream(groupId, 'read', {
ids: reads,
userId: userId
userId: userId,
});
publishMessagingIndexStream(userId, 'read', reads);

View File

@ -11,9 +11,9 @@ export async function readNotification(
// Update documents
await Notifications.update({
id: In(notificationIds),
isRead: false
isRead: false,
}, {
isRead: true
isRead: true,
});
post(userId);
@ -27,9 +27,9 @@ export async function readNotificationByQuery(
await Notifications.update({
...query,
notifieeId: userId,
isRead: false
isRead: false,
}, {
isRead: true
isRead: true,
});
post(userId);

View File

@ -14,7 +14,7 @@ export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
// SEE: https://github.com/koajs/koa/issues/974
// When using a SSL proxy it should be configured to add the "X-Forwarded-Proto: https" header
secure: config.url.startsWith('https'),
httpOnly: false
httpOnly: false,
});
//#endregion
@ -22,7 +22,7 @@ export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
} else {
ctx.body = {
id: user.id,
i: user.token
i: user.token,
};
ctx.status = 200;
}
@ -35,7 +35,7 @@ export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
userId: user.id,
ip: ctx.ip,
headers: ctx.headers,
success: true
success: true,
});
// Publish signin event

View File

@ -54,14 +54,14 @@ export async function signup(opts: {
modulusLength: 4096,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
format: 'pem',
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
cipher: undefined,
passphrase: undefined
}
passphrase: undefined,
},
} as any, (err, publicKey, privateKey) =>
err ? rej(err) : res([publicKey, privateKey])
));
@ -72,7 +72,7 @@ export async function signup(opts: {
await getConnection().transaction(async transactionalEntityManager => {
const exist = await transactionalEntityManager.findOne(User, {
usernameLower: username.toLowerCase(),
host: null
host: null,
});
if (exist) throw new Error(' the username is already used');
@ -92,7 +92,7 @@ export async function signup(opts: {
await transactionalEntityManager.save(new UserKeypair({
publicKey: keyPair[0],
privateKey: keyPair[1],
userId: account.id
userId: account.id,
}));
await transactionalEntityManager.save(new UserProfile({

View File

@ -70,7 +70,7 @@ function getParams<T extends IEndpointMeta>(defs: T, params: any): [Params<T>, A
id: '3d81ceae-475f-4600-b2a8-2bc116157532',
}, {
param: k,
reason: e.message
reason: e.message,
});
return true;
} else {

View File

@ -108,7 +108,7 @@ export interface IEndpoint {
}
const files = glob.sync('**/*.js', {
cwd: path.resolve(_dirname + '/endpoints/')
cwd: path.resolve(_dirname + '/endpoints/'),
});
const endpoints: IEndpoint[] = files.map(f => {
@ -117,7 +117,7 @@ const endpoints: IEndpoint[] = files.map(f => {
return {
name: f.replace('.js', ''),
exec: ep.default,
meta: ep.meta || {}
meta: ep.meta || {},
};
});

View File

@ -13,7 +13,7 @@ export const meta = {
params: {
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
sinceId: {
@ -35,7 +35,7 @@ export const meta = {
'local',
'remote',
]),
default: 'combined'
default: 'combined',
},
targetUserOrigin: {
@ -44,7 +44,7 @@ export const meta = {
'local',
'remote',
]),
default: 'combined'
default: 'combined',
},
},
@ -73,7 +73,7 @@ export const meta = {
resolved: {
type: 'boolean' as const,
nullable: false as const, optional: false as const,
example: false
example: false,
},
reporterId: {
type: 'string' as const,
@ -93,21 +93,21 @@ export const meta = {
reporter: {
type: 'object' as const,
nullable: false as const, optional: false as const,
ref: 'User'
ref: 'User',
},
targetUser: {
type: 'object' as const,
nullable: false as const, optional: false as const,
ref: 'User'
ref: 'User',
},
assignee: {
type: 'object' as const,
nullable: true as const, optional: true as const,
ref: 'User'
}
}
}
}
ref: 'User',
},
},
},
},
};
export default define(meta, async (ps) => {

View File

@ -12,7 +12,7 @@ export const meta = {
password: {
validator: Users.validatePassword,
}
},
},
res: {
@ -23,9 +23,9 @@ export const meta = {
token: {
type: 'string' as const,
optional: false as const, nullable: false as const,
}
}
}
},
},
},
};
export default define(meta, async (ps, _me) => {
@ -42,7 +42,7 @@ export default define(meta, async (ps, _me) => {
const res = await Users.pack(account, account, {
detail: true,
includeSecrets: true
includeSecrets: true,
});
(res as any).token = secret;

View File

@ -16,7 +16,7 @@ export const meta = {
userId: {
validator: $.type(ID),
},
}
},
};
export default define(meta, async (ps, me) => {
@ -39,11 +39,11 @@ export default define(meta, async (ps, me) => {
await doPostSuspend(user).catch(e => {});
createDeleteAccountJob(user, {
soft: false
soft: false,
});
} else {
createDeleteAccountJob(user, {
soft: true // リモートユーザーの削除は、完全にDBから物理削除してしまうと再度連合してきてアカウントが復活する可能性があるため、soft指定する
soft: true, // リモートユーザーの削除は、完全にDBから物理削除してしまうと再度連合してきてアカウントが復活する可能性があるため、soft指定する
});
}

View File

@ -11,26 +11,26 @@ export const meta = {
params: {
url: {
validator: $.str.min(1)
validator: $.str.min(1),
},
memo: {
validator: $.str
validator: $.str,
},
place: {
validator: $.str
validator: $.str,
},
priority: {
validator: $.str
validator: $.str,
},
ratio: {
validator: $.num.int().min(0)
validator: $.num.int().min(0),
},
expiresAt: {
validator: $.num.int()
validator: $.num.int(),
},
imageUrl: {
validator: $.str.min(1)
}
validator: $.str.min(1),
},
},
};

View File

@ -12,17 +12,17 @@ export const meta = {
params: {
id: {
validator: $.type(ID)
}
validator: $.type(ID),
},
},
errors: {
noSuchAd: {
message: 'No such ad.',
code: 'NO_SUCH_AD',
id: 'ccac9863-3a03-416e-b899-8a64041118b1'
}
}
id: 'ccac9863-3a03-416e-b899-8a64041118b1',
},
},
};
export default define(meta, async (ps, me) => {

View File

@ -13,7 +13,7 @@ export const meta = {
params: {
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
sinceId: {

View File

@ -12,28 +12,28 @@ export const meta = {
params: {
id: {
validator: $.type(ID)
validator: $.type(ID),
},
memo: {
validator: $.str
validator: $.str,
},
url: {
validator: $.str.min(1)
validator: $.str.min(1),
},
imageUrl: {
validator: $.str.min(1)
validator: $.str.min(1),
},
place: {
validator: $.str
validator: $.str,
},
priority: {
validator: $.str
validator: $.str,
},
ratio: {
validator: $.num.int().min(0)
validator: $.num.int().min(0),
},
expiresAt: {
validator: $.num.int()
validator: $.num.int(),
},
},
@ -41,9 +41,9 @@ export const meta = {
noSuchAd: {
message: 'No such ad.',
code: 'NO_SUCH_AD',
id: 'b7aa1727-1354-47bc-a182-3a9c3973d300'
}
}
id: 'b7aa1727-1354-47bc-a182-3a9c3973d300',
},
},
};
export default define(meta, async (ps, me) => {

View File

@ -11,14 +11,14 @@ export const meta = {
params: {
title: {
validator: $.str.min(1)
validator: $.str.min(1),
},
text: {
validator: $.str.min(1)
validator: $.str.min(1),
},
imageUrl: {
validator: $.nullable.str.min(1)
}
validator: $.nullable.str.min(1),
},
},
res: {
@ -52,9 +52,9 @@ export const meta = {
imageUrl: {
type: 'string' as const,
optional: false as const, nullable: true as const,
}
}
}
},
},
},
};
export default define(meta, async (ps) => {

View File

@ -12,17 +12,17 @@ export const meta = {
params: {
id: {
validator: $.type(ID)
}
validator: $.type(ID),
},
},
errors: {
noSuchAnnouncement: {
message: 'No such announcement.',
code: 'NO_SUCH_ANNOUNCEMENT',
id: 'ecad8040-a276-4e85-bda9-015a708d291e'
}
}
id: 'ecad8040-a276-4e85-bda9-015a708d291e',
},
},
};
export default define(meta, async (ps, me) => {

View File

@ -13,7 +13,7 @@ export const meta = {
params: {
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
sinceId: {
@ -63,10 +63,10 @@ export const meta = {
reads: {
type: 'number' as const,
optional: false as const, nullable: false as const,
}
}
}
}
},
},
},
},
};
export default define(meta, async (ps) => {
@ -76,7 +76,7 @@ export default define(meta, async (ps) => {
for (const announcement of announcements) {
(announcement as any).reads = await AnnouncementReads.count({
announcementId: announcement.id
announcementId: announcement.id,
});
}

View File

@ -12,26 +12,26 @@ export const meta = {
params: {
id: {
validator: $.type(ID)
validator: $.type(ID),
},
title: {
validator: $.str.min(1)
validator: $.str.min(1),
},
text: {
validator: $.str.min(1)
validator: $.str.min(1),
},
imageUrl: {
validator: $.nullable.str.min(1)
}
validator: $.nullable.str.min(1),
},
},
errors: {
noSuchAnnouncement: {
message: 'No such announcement.',
code: 'NO_SUCH_ANNOUNCEMENT',
id: 'd3aae5a7-6372-4cb4-b61c-f511ffc2d7cc'
}
}
id: 'd3aae5a7-6372-4cb4-b61c-f511ffc2d7cc',
},
},
};
export default define(meta, async (ps, me) => {

View File

@ -14,12 +14,12 @@ export const meta = {
userId: {
validator: $.type(ID),
},
}
},
};
export default define(meta, async (ps, me) => {
const files = await DriveFiles.find({
userId: ps.userId
userId: ps.userId,
});
for (const file of files) {

View File

@ -12,7 +12,7 @@ export const meta = {
export default define(meta, async (ps, me) => {
const files = await DriveFiles.find({
userId: IsNull()
userId: IsNull(),
});
for (const file of files) {

View File

@ -13,7 +13,7 @@ export const meta = {
params: {
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
sinceId: {
@ -25,7 +25,7 @@ export const meta = {
},
type: {
validator: $.optional.nullable.str.match(/^[a-zA-Z0-9\/\-*]+$/)
validator: $.optional.nullable.str.match(/^[a-zA-Z0-9\/\-*]+$/),
},
origin: {
@ -34,12 +34,12 @@ export const meta = {
'local',
'remote',
]),
default: 'local'
default: 'local',
},
hostname: {
validator: $.optional.nullable.str,
default: null
default: null,
},
},
@ -49,9 +49,9 @@ export const meta = {
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'DriveFile'
}
}
ref: 'DriveFile',
},
},
};
export default define(meta, async (ps, me) => {

View File

@ -24,8 +24,8 @@ export const meta = {
noSuchFile: {
message: 'No such file.',
code: 'NO_SUCH_FILE',
id: 'caf3ca38-c6e5-472e-a30c-b05377dcc240'
}
id: 'caf3ca38-c6e5-472e-a30c-b05377dcc240',
},
},
res: {
@ -51,36 +51,36 @@ export const meta = {
},
userHost: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
md5: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'md5',
example: '15eca7fba0480996e2245f5185bf39f2'
example: '15eca7fba0480996e2245f5185bf39f2',
},
name: {
type: 'string' as const,
optional: false as const, nullable: false as const,
example: 'lenna.jpg'
example: 'lenna.jpg',
},
type: {
type: 'string' as const,
optional: false as const, nullable: false as const,
example: 'image/jpeg'
example: 'image/jpeg',
},
size: {
type: 'number' as const,
optional: false as const, nullable: false as const,
example: 51469
example: 51469,
},
comment: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
blurhash: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
properties: {
type: 'object' as const,
@ -89,24 +89,24 @@ export const meta = {
width: {
type: 'number' as const,
optional: false as const, nullable: false as const,
example: 1280
example: 1280,
},
height: {
type: 'number' as const,
optional: false as const, nullable: false as const,
example: 720
example: 720,
},
avgColor: {
type: 'string' as const,
optional: true as const, nullable: false as const,
example: 'rgb(40,65,87)'
}
}
example: 'rgb(40,65,87)',
},
},
},
storedInternal: {
type: 'boolean' as const,
optional: false as const, nullable: true as const,
example: true
example: true,
},
url: {
type: 'string' as const,
@ -137,11 +137,11 @@ export const meta = {
},
uri: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
src: {
type: 'string' as const,
optional: false as const, nullable: true as const
optional: false as const, nullable: true as const,
},
folderId: {
type: 'string' as const,
@ -155,21 +155,21 @@ export const meta = {
},
isLink: {
type: 'boolean' as const,
optional: false as const, nullable: false as const
}
}
}
optional: false as const, nullable: false as const,
},
},
},
};
export default define(meta, async (ps, me) => {
const file = ps.fileId ? await DriveFiles.findOne(ps.fileId) : await DriveFiles.findOne({
where: [{
url: ps.url
url: ps.url,
}, {
thumbnailUrl: ps.url
thumbnailUrl: ps.url,
}, {
webpublicUrl: ps.url
}]
webpublicUrl: ps.url,
}],
});
if (file == null) {

View File

@ -17,7 +17,7 @@ export const meta = {
params: {
fileId: {
validator: $.type(ID)
validator: $.type(ID),
},
},
@ -25,9 +25,9 @@ export const meta = {
noSuchFile: {
message: 'No such file.',
code: 'MO_SUCH_FILE',
id: 'fc46b5a4-6b92-4c33-ac66-b806659bb5cf'
}
}
id: 'fc46b5a4-6b92-4c33-ac66-b806659bb5cf',
},
},
};
export default define(meta, async (ps, me) => {
@ -51,14 +51,14 @@ export default define(meta, async (ps, me) => {
await getConnection().queryResultCache!.remove(['meta_emojis']);
publishBroadcastStream('emojiAdded', {
emoji: await Emojis.pack(emoji.id)
emoji: await Emojis.pack(emoji.id),
});
insertModerationLog(me, 'addEmoji', {
emojiId: emoji.id
emojiId: emoji.id,
});
return {
id: emoji.id
id: emoji.id,
};
});

View File

@ -17,7 +17,7 @@ export const meta = {
params: {
emojiId: {
validator: $.type(ID)
validator: $.type(ID),
},
},
@ -25,8 +25,8 @@ export const meta = {
noSuchEmoji: {
message: 'No such emoji.',
code: 'NO_SUCH_EMOJI',
id: 'e2785b66-dca3-4087-9cac-b93c541cc425'
}
id: 'e2785b66-dca3-4087-9cac-b93c541cc425',
},
},
res: {
@ -37,9 +37,9 @@ export const meta = {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id',
}
}
}
},
},
},
};
export default define(meta, async (ps, me) => {
@ -72,10 +72,10 @@ export default define(meta, async (ps, me) => {
await getConnection().queryResultCache!.remove(['meta_emojis']);
publishBroadcastStream('emojiAdded', {
emoji: await Emojis.pack(copied.id)
emoji: await Emojis.pack(copied.id),
});
return {
id: copied.id
id: copied.id,
};
});

View File

@ -14,17 +14,17 @@ export const meta = {
params: {
query: {
validator: $.optional.nullable.str,
default: null
default: null,
},
host: {
validator: $.optional.nullable.str,
default: null
default: null,
},
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
sinceId: {
@ -33,7 +33,7 @@ export const meta = {
untilId: {
validator: $.optional.type(ID),
}
},
},
res: {
@ -53,8 +53,8 @@ export const meta = {
optional: false as const, nullable: false as const,
items: {
type: 'string' as const,
optional: false as const, nullable: false as const
}
optional: false as const, nullable: false as const,
},
},
name: {
type: 'string' as const,
@ -71,10 +71,10 @@ export const meta = {
url: {
type: 'string' as const,
optional: false as const, nullable: false as const,
}
}
}
}
},
},
},
},
};
export default define(meta, async (ps) => {

View File

@ -14,12 +14,12 @@ export const meta = {
params: {
query: {
validator: $.optional.nullable.str,
default: null
default: null,
},
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
sinceId: {
@ -28,7 +28,7 @@ export const meta = {
untilId: {
validator: $.optional.type(ID),
}
},
},
res: {
@ -48,8 +48,8 @@ export const meta = {
optional: false as const, nullable: false as const,
items: {
type: 'string' as const,
optional: false as const, nullable: false as const
}
optional: false as const, nullable: false as const,
},
},
name: {
type: 'string' as const,
@ -66,10 +66,10 @@ export const meta = {
url: {
type: 'string' as const,
optional: false as const, nullable: false as const,
}
}
}
}
},
},
},
},
};
export default define(meta, async (ps) => {

View File

@ -14,17 +14,17 @@ export const meta = {
params: {
id: {
validator: $.type(ID)
}
validator: $.type(ID),
},
},
errors: {
noSuchEmoji: {
message: 'No such emoji.',
code: 'NO_SUCH_EMOJI',
id: 'be83669b-773a-44b7-b1f8-e5e5170ac3c2'
}
}
id: 'be83669b-773a-44b7-b1f8-e5e5170ac3c2',
},
},
};
export default define(meta, async (ps, me) => {
@ -37,6 +37,6 @@ export default define(meta, async (ps, me) => {
await getConnection().queryResultCache!.remove(['meta_emojis']);
insertModerationLog(me, 'removeEmoji', {
emoji: emoji
emoji: emoji,
});
});

View File

@ -13,29 +13,29 @@ export const meta = {
params: {
id: {
validator: $.type(ID)
validator: $.type(ID),
},
name: {
validator: $.str
validator: $.str,
},
category: {
validator: $.optional.nullable.str
validator: $.optional.nullable.str,
},
aliases: {
validator: $.arr($.str)
}
validator: $.arr($.str),
},
},
errors: {
noSuchEmoji: {
message: 'No such emoji.',
code: 'NO_SUCH_EMOJI',
id: '684dec9d-a8c2-4364-9aa8-456c49cb1dc8'
}
}
id: '684dec9d-a8c2-4364-9aa8-456c49cb1dc8',
},
},
};
export default define(meta, async (ps) => {

View File

@ -11,14 +11,14 @@ export const meta = {
params: {
host: {
validator: $.str
}
}
validator: $.str,
},
},
};
export default define(meta, async (ps, me) => {
const files = await DriveFiles.find({
userHost: ps.host
userHost: ps.host,
});
for (const file of files) {

View File

@ -12,9 +12,9 @@ export const meta = {
params: {
host: {
validator: $.str
validator: $.str,
},
}
},
};
export default define(meta, async (ps, me) => {

View File

@ -11,19 +11,19 @@ export const meta = {
params: {
host: {
validator: $.str
}
}
validator: $.str,
},
},
};
export default define(meta, async (ps, me) => {
const followings = await Followings.find({
followerHost: ps.host
followerHost: ps.host,
});
const pairs = await Promise.all(followings.map(f => Promise.all([
Users.findOneOrFail(f.followerId),
Users.findOneOrFail(f.followeeId)
Users.findOneOrFail(f.followeeId),
])));
for (const pair of pairs) {

View File

@ -11,13 +11,13 @@ export const meta = {
params: {
host: {
validator: $.str
validator: $.str,
},
isSuspended: {
validator: $.bool
validator: $.bool,
},
}
},
};
export default define(meta, async (ps, me) => {
@ -28,6 +28,6 @@ export default define(meta, async (ps, me) => {
}
Instances.update({ host: toPuny(ps.host) }, {
isSuspended: ps.isSuspended
isSuspended: ps.isSuspended,
});
});

View File

@ -16,10 +16,10 @@ export const meta = {
example: {
migrations: {
count: 66,
size: 32768
size: 32768,
},
}
}
},
},
};
export default define(meta, async () => {

View File

@ -20,10 +20,10 @@ export const meta = {
optional: false as const, nullable: false as const,
example: '2ERUA5VR',
maxLength: 8,
minLength: 8
}
}
}
minLength: 8,
},
},
},
};
export default define(meta, async () => {

View File

@ -13,7 +13,7 @@ export const meta = {
userId: {
validator: $.type(ID),
},
}
},
};
export default define(meta, async (ps) => {
@ -28,6 +28,6 @@ export default define(meta, async (ps) => {
}
await Users.update(user.id, {
isModerator: true
isModerator: true,
});
});

View File

@ -13,7 +13,7 @@ export const meta = {
userId: {
validator: $.type(ID),
},
}
},
};
export default define(meta, async (ps) => {
@ -24,6 +24,6 @@ export default define(meta, async (ps) => {
}
await Users.update(user.id, {
isModerator: false
isModerator: false,
});
});

View File

@ -17,7 +17,7 @@ export const meta = {
},
expiresAt: {
validator: $.num.int()
validator: $.num.int(),
},
},
@ -25,15 +25,15 @@ export const meta = {
noSuchNote: {
message: 'No such note.',
code: 'NO_SUCH_NOTE',
id: 'ee449fbe-af2a-453b-9cae-cf2fe7c895fc'
id: 'ee449fbe-af2a-453b-9cae-cf2fe7c895fc',
},
alreadyPromoted: {
message: 'The note has already promoted.',
code: 'ALREADY_PROMOTED',
id: 'ae427aa2-7a41-484f-a18c-2c1104051604'
id: 'ae427aa2-7a41-484f-a18c-2c1104051604',
},
}
},
};
export default define(meta, async (ps, user) => {

View File

@ -8,7 +8,7 @@ export const meta = {
requireCredential: true as const,
requireModerator: true,
params: {}
params: {},
};
export default define(meta, async (ps, me) => {

View File

@ -24,15 +24,15 @@ export const meta = {
},
{
type: 'number' as const,
}
]
}
},
],
},
},
example: [[
'example.com',
12
]]
}
12,
]],
},
};
export default define(meta, async (ps) => {

View File

@ -24,15 +24,15 @@ export const meta = {
},
{
type: 'number' as const,
}
]
}
},
],
},
},
example: [[
'example.com',
12
]]
}
12,
]],
},
};
export default define(meta, async (ps) => {

View File

@ -19,7 +19,7 @@ export const meta = {
limit: {
validator: $.optional.num,
default: 50
default: 50,
},
},
@ -33,27 +33,27 @@ export const meta = {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
format: 'id',
},
data: {
type: 'object' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
attempts: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
maxAttempts: {
type: 'number' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
timestamp: {
type: 'number' as const,
optional: false as const, nullable: false as const
}
}
}
}
optional: false as const, nullable: false as const,
},
},
},
},
};
export default define(meta, async (ps) => {

View File

@ -14,19 +14,19 @@ export const meta = {
optional: false as const, nullable: false as const,
properties: {
deliver: {
ref: 'QueueCount'
ref: 'QueueCount',
},
inbox: {
ref: 'QueueCount'
ref: 'QueueCount',
},
db: {
ref: 'QueueCount'
ref: 'QueueCount',
},
objectStorage: {
ref: 'QueueCount'
}
}
}
ref: 'QueueCount',
},
},
},
};
export default define(meta, async (ps) => {

View File

@ -12,7 +12,7 @@ export const meta = {
params: {
inbox: {
validator: $.str
validator: $.str,
},
},
@ -20,7 +20,7 @@ export const meta = {
invalidUrl: {
message: 'Invalid URL',
code: 'INVALID_URL',
id: 'fb8c92d3-d4e5-44e7-b3d4-800d5cef8b2c'
id: 'fb8c92d3-d4e5-44e7-b3d4-800d5cef8b2c',
},
},
@ -31,12 +31,12 @@ export const meta = {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
format: 'id',
},
inbox: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'url'
format: 'url',
},
status: {
type: 'string' as const,
@ -45,11 +45,11 @@ export const meta = {
enum: [
'requesting',
'accepted',
'rejected'
]
}
}
}
'rejected',
],
},
},
},
};
export default define(meta, async (ps, user) => {

View File

@ -20,12 +20,12 @@ export const meta = {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
format: 'id',
},
inbox: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'url'
format: 'url',
},
status: {
type: 'string' as const,
@ -34,12 +34,12 @@ export const meta = {
enum: [
'requesting',
'accepted',
'rejected'
]
}
}
}
}
'rejected',
],
},
},
},
},
};
export default define(meta, async (ps, user) => {

View File

@ -10,7 +10,7 @@ export const meta = {
params: {
inbox: {
validator: $.str
validator: $.str,
},
},
};

View File

@ -25,10 +25,10 @@ export const meta = {
type: 'string' as const,
optional: false as const, nullable: false as const,
minLength: 8,
maxLength: 8
}
}
}
maxLength: 8,
},
},
},
};
export default define(meta, async (ps) => {
@ -48,12 +48,12 @@ export default define(meta, async (ps) => {
const hash = bcrypt.hashSync(passwd);
await UserProfiles.update({
userId: user.id
userId: user.id,
}, {
password: hash
password: hash,
});
return {
password: passwd
password: passwd,
};
});

View File

@ -13,7 +13,7 @@ export const meta = {
reportId: {
validator: $.type(ID),
},
}
},
};
export default define(meta, async (ps, me) => {

View File

@ -18,7 +18,7 @@ export const meta = {
text: {
validator: $.str,
},
}
},
};
export default define(meta, async (ps) => {

View File

@ -24,7 +24,7 @@ export const meta = {
os: {
type: 'string' as const,
optional: false as const, nullable: false as const,
example: 'linux'
example: 'linux',
},
node: {
type: 'string' as const,
@ -45,8 +45,8 @@ export const meta = {
cores: {
type: 'number' as const,
optional: false as const, nullable: false as const,
}
}
},
},
},
mem: {
type: 'object' as const,
@ -56,8 +56,8 @@ export const meta = {
type: 'number' as const,
optional: false as const, nullable: false as const,
format: 'bytes',
}
}
},
},
},
fs: {
type: 'object' as const,
@ -72,8 +72,8 @@ export const meta = {
type: 'number' as const,
optional: false as const, nullable: false as const,
format: 'bytes',
}
}
},
},
},
net: {
type: 'object' as const,
@ -82,12 +82,12 @@ export const meta = {
interface: {
type: 'string' as const,
optional: false as const, nullable: false as const,
example: 'eth0'
}
}
}
}
}
example: 'eth0',
},
},
},
},
},
};
export default define(meta, async () => {
@ -103,17 +103,17 @@ export default define(meta, async () => {
redis: redisClient.server_info.redis_version,
cpu: {
model: os.cpus()[0].model,
cores: os.cpus().length
cores: os.cpus().length,
},
mem: {
total: memStats.total
total: memStats.total,
},
fs: {
total: fsStats[0].size,
used: fsStats[0].used,
},
net: {
interface: netInterface
}
interface: netInterface,
},
};
});

View File

@ -13,7 +13,7 @@ export const meta = {
params: {
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
sinceId: {
@ -35,34 +35,34 @@ export const meta = {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
format: 'id',
},
createdAt: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'date-time'
format: 'date-time',
},
type: {
type: 'string' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
info: {
type: 'object' as const,
optional: false as const, nullable: false as const
optional: false as const, nullable: false as const,
},
userId: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
format: 'id',
},
user: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'User'
}
}
}
}
ref: 'User',
},
},
},
},
};
export default define(meta, async (ps) => {

View File

@ -22,85 +22,85 @@ export const meta = {
id: {
type: 'string' as const,
nullable: false as const, optional: false as const,
format: 'id'
format: 'id',
},
createdAt: {
type: 'string' as const,
nullable: false as const, optional: false as const,
format: 'date-time'
format: 'date-time',
},
updatedAt: {
type: 'string' as const,
nullable: true as const, optional: false as const,
format: 'date-time'
format: 'date-time',
},
lastFetchedAt: {
type: 'string' as const,
nullable: true as const, optional: false as const
nullable: true as const, optional: false as const,
},
username: {
type: 'string' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
name: {
type: 'string' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
folowersCount: {
type: 'number' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
followingCount: {
type: 'number' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
notesCount: {
type: 'number' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
avatarId: {
type: 'string' as const,
nullable: true as const, optional: false as const
nullable: true as const, optional: false as const,
},
bannerId: {
type: 'string' as const,
nullable: true as const, optional: false as const
nullable: true as const, optional: false as const,
},
tags: {
type: 'array' as const,
nullable: false as const, optional: false as const,
items: {
type: 'string' as const,
nullable: false as const, optional: false as const
}
nullable: false as const, optional: false as const,
},
},
avatarUrl: {
type: 'string' as const,
nullable: true as const, optional: false as const,
format: 'url'
format: 'url',
},
bannerUrl: {
type: 'string' as const,
nullable: true as const, optional: false as const,
format: 'url'
format: 'url',
},
avatarBlurhash: {
type: 'any' as const,
nullable: true as const, optional: false as const,
default: null
default: null,
},
bannerBlurhash: {
type: 'any' as const,
nullable: true as const, optional: false as const,
default: null
default: null,
},
isSuspended: {
type: 'boolean' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
isSilenced: {
type: 'boolean' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
isLocked: {
type: 'boolean' as const,
@ -108,55 +108,55 @@ export const meta = {
},
isBot: {
type: 'boolean' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
isCat: {
type: 'boolean' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
isAdmin: {
type: 'boolean' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
isModerator: {
type: 'boolean' as const,
nullable: false as const, optional: false as const
nullable: false as const, optional: false as const,
},
emojis: {
type: 'array' as const,
nullable: false as const, optional: false as const,
items: {
type: 'string' as const,
nullable: false as const, optional: false as const
}
nullable: false as const, optional: false as const,
},
},
host: {
type: 'string' as const,
nullable: true as const, optional: false as const
nullable: true as const, optional: false as const,
},
inbox: {
type: 'string' as const,
nullable: true as const, optional: false as const
nullable: true as const, optional: false as const,
},
sharedInbox: {
type: 'string' as const,
nullable: true as const, optional: false as const
nullable: true as const, optional: false as const,
},
featured: {
type: 'string' as const,
nullable: true as const, optional: false as const
nullable: true as const, optional: false as const,
},
uri: {
type: 'string' as const,
nullable: true as const, optional: false as const
nullable: true as const, optional: false as const,
},
token: {
type: 'string' as const,
nullable: false as const, optional: false as const,
default: '<MASKED>'
}
}
}
default: '<MASKED>',
},
},
},
};
export default define(meta, async (ps, me) => {

View File

@ -11,12 +11,12 @@ export const meta = {
params: {
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
offset: {
validator: $.optional.num.min(0),
default: 0
default: 0,
},
sort: {
@ -40,7 +40,7 @@ export const meta = {
'silenced',
'suspended',
]),
default: 'all'
default: 'all',
},
origin: {
@ -49,18 +49,18 @@ export const meta = {
'local',
'remote',
]),
default: 'local'
default: 'local',
},
username: {
validator: $.optional.str,
default: null
default: null,
},
hostname: {
validator: $.optional.str,
default: null
}
default: null,
},
},
res: {
@ -69,9 +69,9 @@ export const meta = {
items: {
type: 'object' as const,
nullable: false as const, optional: false as const,
ref: 'User'
}
}
ref: 'User',
},
},
};
export default define(meta, async (ps, me) => {

View File

@ -14,7 +14,7 @@ export const meta = {
userId: {
validator: $.type(ID),
},
}
},
};
export default define(meta, async (ps, me) => {
@ -29,7 +29,7 @@ export default define(meta, async (ps, me) => {
}
await Users.update(user.id, {
isSilenced: true
isSilenced: true,
});
insertModerationLog(me, 'silence', {

View File

@ -18,7 +18,7 @@ export const meta = {
userId: {
validator: $.type(ID),
},
}
},
};
export default define(meta, async (ps, me) => {
@ -37,7 +37,7 @@ export default define(meta, async (ps, me) => {
}
await Users.update(user.id, {
isSuspended: true
isSuspended: true,
});
insertModerationLog(me, 'suspend', {
@ -58,12 +58,12 @@ export default define(meta, async (ps, me) => {
async function unFollowAll(follower: User) {
const followings = await Followings.find({
followerId: follower.id
followerId: follower.id,
});
for (const following of followings) {
const followee = await Users.findOne({
id: following.followeeId
id: following.followeeId,
});
if (followee == null) {
@ -79,6 +79,6 @@ async function readAllNotify(notifier: User) {
notifierId: notifier.id,
isRead: false,
}, {
isRead: true
isRead: true,
});
}

View File

@ -14,7 +14,7 @@ export const meta = {
userId: {
validator: $.type(ID),
},
}
},
};
export default define(meta, async (ps, me) => {
@ -25,7 +25,7 @@ export default define(meta, async (ps, me) => {
}
await Users.update(user.id, {
isSilenced: false
isSilenced: false,
});
insertModerationLog(me, 'unsilence', {

View File

@ -15,7 +15,7 @@ export const meta = {
userId: {
validator: $.type(ID),
},
}
},
};
export default define(meta, async (ps, me) => {
@ -26,7 +26,7 @@ export default define(meta, async (ps, me) => {
}
await Users.update(user.id, {
isSuspended: false
isSuspended: false,
});
insertModerationLog(me, 'unsuspend', {

View File

@ -246,57 +246,57 @@ export const meta = {
},
useObjectStorage: {
validator: $.optional.bool
validator: $.optional.bool,
},
objectStorageBaseUrl: {
validator: $.optional.nullable.str
validator: $.optional.nullable.str,
},
objectStorageBucket: {
validator: $.optional.nullable.str
validator: $.optional.nullable.str,
},
objectStoragePrefix: {
validator: $.optional.nullable.str
validator: $.optional.nullable.str,
},
objectStorageEndpoint: {
validator: $.optional.nullable.str
validator: $.optional.nullable.str,
},
objectStorageRegion: {
validator: $.optional.nullable.str
validator: $.optional.nullable.str,
},
objectStoragePort: {
validator: $.optional.nullable.num
validator: $.optional.nullable.num,
},
objectStorageAccessKey: {
validator: $.optional.nullable.str
validator: $.optional.nullable.str,
},
objectStorageSecretKey: {
validator: $.optional.nullable.str
validator: $.optional.nullable.str,
},
objectStorageUseSSL: {
validator: $.optional.bool
validator: $.optional.bool,
},
objectStorageUseProxy: {
validator: $.optional.bool
validator: $.optional.bool,
},
objectStorageSetPublicRead: {
validator: $.optional.bool
validator: $.optional.bool,
},
objectStorageS3ForcePathStyle: {
validator: $.optional.bool
validator: $.optional.bool,
},
}
},
};
export default define(meta, async (ps, me) => {
@ -593,8 +593,8 @@ export default define(meta, async (ps, me) => {
await getConnection().transaction(async transactionalEntityManager => {
const meta = await transactionalEntityManager.findOne(Meta, {
order: {
id: 'DESC'
}
id: 'DESC',
},
});
if (meta) {

View File

@ -16,7 +16,7 @@ export const meta = {
analyze: {
validator: $.bool,
},
}
},
};
export default define(meta, async (ps, me) => {

View File

@ -12,12 +12,12 @@ export const meta = {
params: {
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
withUnreads: {
validator: $.optional.boolean,
default: false
default: false,
},
sinceId: {
@ -67,10 +67,10 @@ export const meta = {
isRead: {
type: 'boolean' as const,
optional: false as const, nullable: false as const,
}
}
}
}
},
},
},
},
};
export default define(meta, async (ps, user) => {
@ -80,7 +80,7 @@ export default define(meta, async (ps, user) => {
if (user) {
const reads = (await AnnouncementReads.find({
userId: user.id
userId: user.id,
})).map(x => x.announcementId);
for (const announcement of announcements) {

View File

@ -15,11 +15,11 @@ export const meta = {
params: {
name: {
validator: $.str.range(1, 100)
validator: $.str.range(1, 100),
},
src: {
validator: $.str.or(['home', 'all', 'users', 'list', 'group'])
validator: $.str.or(['home', 'all', 'users', 'list', 'group']),
},
userListId: {
@ -31,53 +31,53 @@ export const meta = {
},
keywords: {
validator: $.arr($.arr($.str))
validator: $.arr($.arr($.str)),
},
excludeKeywords: {
validator: $.arr($.arr($.str))
validator: $.arr($.arr($.str)),
},
users: {
validator: $.arr($.str)
validator: $.arr($.str),
},
caseSensitive: {
validator: $.bool
validator: $.bool,
},
withReplies: {
validator: $.bool
validator: $.bool,
},
withFile: {
validator: $.bool
validator: $.bool,
},
notify: {
validator: $.bool
}
validator: $.bool,
},
},
errors: {
noSuchUserList: {
message: 'No such user list.',
code: 'NO_SUCH_USER_LIST',
id: '95063e93-a283-4b8b-9aa5-bcdb8df69a7f'
id: '95063e93-a283-4b8b-9aa5-bcdb8df69a7f',
},
noSuchUserGroup: {
message: 'No such user group.',
code: 'NO_SUCH_USER_GROUP',
id: 'aa3c0b9a-8cae-47c0-92ac-202ce5906682'
}
id: 'aa3c0b9a-8cae-47c0-92ac-202ce5906682',
},
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Antenna'
}
ref: 'Antenna',
},
};
export default define(meta, async (ps, user) => {

View File

@ -15,22 +15,22 @@ export const meta = {
params: {
antennaId: {
validator: $.type(ID),
}
},
},
errors: {
noSuchAntenna: {
message: 'No such antenna.',
code: 'NO_SUCH_ANTENNA',
id: 'b34dcf9d-348f-44bb-99d0-6c9314cfe2df'
}
}
id: 'b34dcf9d-348f-44bb-99d0-6c9314cfe2df',
},
},
};
export default define(meta, async (ps, user) => {
const antenna = await Antennas.findOne({
id: ps.antennaId,
userId: user.id
userId: user.id,
});
if (antenna == null) {

View File

@ -14,9 +14,9 @@ export const meta = {
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Antenna'
}
}
ref: 'Antenna',
},
},
};
export default define(meta, async (ps, me) => {

View File

@ -23,7 +23,7 @@ export const meta = {
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
sinceId: {
@ -47,8 +47,8 @@ export const meta = {
noSuchAntenna: {
message: 'No such antenna.',
code: 'NO_SUCH_ANTENNA',
id: '850926e0-fd3b-49b6-b69a-b28a5dbd82fe'
}
id: '850926e0-fd3b-49b6-b69a-b28a5dbd82fe',
},
},
res: {
@ -57,15 +57,15 @@ export const meta = {
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Note'
}
}
ref: 'Note',
},
},
};
export default define(meta, async (ps, user) => {
const antenna = await Antennas.findOne({
id: ps.antennaId,
userId: user.id
userId: user.id,
});
if (antenna == null) {

View File

@ -21,15 +21,15 @@ export const meta = {
noSuchAntenna: {
message: 'No such antenna.',
code: 'NO_SUCH_ANTENNA',
id: 'c06569fb-b025-4f23-b22d-1fcd20d2816b'
id: 'c06569fb-b025-4f23-b22d-1fcd20d2816b',
},
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Antenna'
}
ref: 'Antenna',
},
};
export default define(meta, async (ps, me) => {

View File

@ -18,11 +18,11 @@ export const meta = {
},
name: {
validator: $.str.range(1, 100)
validator: $.str.range(1, 100),
},
src: {
validator: $.str.or(['home', 'all', 'users', 'list', 'group'])
validator: $.str.or(['home', 'all', 'users', 'list', 'group']),
},
userListId: {
@ -34,66 +34,66 @@ export const meta = {
},
keywords: {
validator: $.arr($.arr($.str))
validator: $.arr($.arr($.str)),
},
excludeKeywords: {
validator: $.arr($.arr($.str))
validator: $.arr($.arr($.str)),
},
users: {
validator: $.arr($.str)
validator: $.arr($.str),
},
caseSensitive: {
validator: $.bool
validator: $.bool,
},
withReplies: {
validator: $.bool
validator: $.bool,
},
withFile: {
validator: $.bool
validator: $.bool,
},
notify: {
validator: $.bool
}
validator: $.bool,
},
},
errors: {
noSuchAntenna: {
message: 'No such antenna.',
code: 'NO_SUCH_ANTENNA',
id: '10c673ac-8852-48eb-aa1f-f5b67f069290'
id: '10c673ac-8852-48eb-aa1f-f5b67f069290',
},
noSuchUserList: {
message: 'No such user list.',
code: 'NO_SUCH_USER_LIST',
id: '1c6b35c9-943e-48c2-81e4-2844989407f7'
id: '1c6b35c9-943e-48c2-81e4-2844989407f7',
},
noSuchUserGroup: {
message: 'No such user group.',
code: 'NO_SUCH_USER_GROUP',
id: '109ed789-b6eb-456e-b8a9-6059d567d385'
}
id: '109ed789-b6eb-456e-b8a9-6059d567d385',
},
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Antenna'
}
ref: 'Antenna',
},
};
export default define(meta, async (ps, user) => {
// Fetch the antenna
const antenna = await Antennas.findOne({
id: ps.antennaId,
userId: user.id
userId: user.id,
});
if (antenna == null) {

View File

@ -11,7 +11,7 @@ export const meta = {
limit: {
duration: ms('1hour'),
max: 30
max: 30,
},
params: {
@ -26,7 +26,7 @@ export const meta = {
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
}
},
};
export default define(meta, async (ps) => {

View File

@ -20,7 +20,7 @@ export const meta = {
limit: {
duration: ms('1hour'),
max: 30
max: 30,
},
params: {
@ -33,8 +33,8 @@ export const meta = {
noSuchObject: {
message: 'No such object.',
code: 'NO_SUCH_OBJECT',
id: 'dc94d745-1262-4e63-a17d-fecaa57efc82'
}
id: 'dc94d745-1262-4e63-a17d-fecaa57efc82',
},
},
res: {
@ -44,14 +44,14 @@ export const meta = {
type: {
type: 'string' as const,
optional: false as const, nullable: false as const,
enum: ['User', 'Note']
enum: ['User', 'Note'],
},
object: {
type: 'object' as const,
optional: false as const, nullable: false as const
}
}
}
optional: false as const, nullable: false as const,
},
},
},
};
export default define(meta, async (ps) => {
@ -79,7 +79,7 @@ async function fetchAny(uri: string) {
if (note) {
return {
type: 'Note',
object: await Notes.pack(note, null, { detail: true })
object: await Notes.pack(note, null, { detail: true }),
};
}
} else if (type === 'users') {
@ -88,7 +88,7 @@ async function fetchAny(uri: string) {
if (user) {
return {
type: 'User',
object: await Users.pack(user, null, { detail: true })
object: await Users.pack(user, null, { detail: true }),
};
}
}
@ -102,7 +102,7 @@ async function fetchAny(uri: string) {
{
const [user, note] = await Promise.all([
Users.findOne({ uri: uri }),
Notes.findOne({ uri: uri })
Notes.findOne({ uri: uri }),
]);
const packed = await mergePack(user, note);
@ -127,7 +127,7 @@ async function fetchAny(uri: string) {
if (note) {
return {
type: 'Note',
object: await Notes.pack(note, null, { detail: true })
object: await Notes.pack(note, null, { detail: true }),
};
}
} else if (type === 'users') {
@ -136,7 +136,7 @@ async function fetchAny(uri: string) {
if (user) {
return {
type: 'User',
object: await Users.pack(user, null, { detail: true })
object: await Users.pack(user, null, { detail: true }),
};
}
}
@ -144,7 +144,7 @@ async function fetchAny(uri: string) {
const [user, note] = await Promise.all([
Users.findOne({ uri: object.id }),
Notes.findOne({ uri: object.id })
Notes.findOne({ uri: object.id }),
]);
const packed = await mergePack(user, note);
@ -156,7 +156,7 @@ async function fetchAny(uri: string) {
const user = await createPerson(getApId(object));
return {
type: 'User',
object: await Users.pack(user, null, { detail: true })
object: await Users.pack(user, null, { detail: true }),
};
}
@ -164,7 +164,7 @@ async function fetchAny(uri: string) {
const note = await createNote(getApId(object), undefined, true);
return {
type: 'Note',
object: await Notes.pack(note!, null, { detail: true })
object: await Notes.pack(note!, null, { detail: true }),
};
}
@ -175,14 +175,14 @@ async function mergePack(user: User | null | undefined, note: Note | null | unde
if (user != null) {
return {
type: 'User',
object: await Users.pack(user, null, { detail: true })
object: await Users.pack(user, null, { detail: true }),
};
}
if (note != null) {
return {
type: 'Note',
object: await Notes.pack(note, null, { detail: true })
object: await Notes.pack(note, null, { detail: true }),
};
}

View File

@ -53,11 +53,11 @@ export default define(meta, async (ps, user) => {
description: ps.description,
permission,
callbackUrl: ps.callbackUrl,
secret: secret
secret: secret,
});
return await Apps.pack(app, null, {
detail: true,
includeSecret: true
includeSecret: true,
});
});

View File

@ -23,15 +23,15 @@ export const meta = {
noSuchApp: {
message: 'No such app.',
code: 'NO_SUCH_APP',
id: 'dce83913-2dc6-4093-8a7b-71dbb11718a3'
}
id: 'dce83913-2dc6-4093-8a7b-71dbb11718a3',
},
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'App'
}
ref: 'App',
},
};
export default define(meta, async (ps, user, token) => {
@ -46,6 +46,6 @@ export default define(meta, async (ps, user, token) => {
return await Apps.pack(ap, user, {
detail: true,
includeSecret: isSecure && (ap.userId === user!.id)
includeSecret: isSecure && (ap.userId === user!.id),
});
});

View File

@ -15,17 +15,17 @@ export const meta = {
params: {
token: {
validator: $.str
}
validator: $.str,
},
},
errors: {
noSuchSession: {
message: 'No such session.',
code: 'NO_SUCH_SESSION',
id: '9c72d8de-391a-43c1-9d06-08d29efde8df'
id: '9c72d8de-391a-43c1-9d06-08d29efde8df',
},
}
},
};
export default define(meta, async (ps, user) => {
@ -65,12 +65,12 @@ export default define(meta, async (ps, user) => {
appId: session.appId,
userId: user.id,
token: accessToken,
hash: hash
hash: hash,
});
}
// Update session
await AuthSessions.update(session.id, {
userId: user.id
userId: user.id,
});
});

View File

@ -14,7 +14,7 @@ export const meta = {
params: {
appSecret: {
validator: $.str,
}
},
},
res: {
@ -30,22 +30,22 @@ export const meta = {
optional: false as const, nullable: false as const,
format: 'url',
},
}
},
},
errors: {
noSuchApp: {
message: 'No such app.',
code: 'NO_SUCH_APP',
id: '92f93e63-428e-4f2f-a5a4-39e1407fe998'
}
}
id: '92f93e63-428e-4f2f-a5a4-39e1407fe998',
},
},
};
export default define(meta, async (ps) => {
// Lookup app
const app = await Apps.findOne({
secret: ps.appSecret
secret: ps.appSecret,
});
if (app == null) {
@ -60,11 +60,11 @@ export default define(meta, async (ps) => {
id: genId(),
createdAt: new Date(),
appId: app.id,
token: token
token: token,
});
return {
token: doc.token,
url: `${config.authUrl}/${doc.token}`
url: `${config.authUrl}/${doc.token}`,
};
});

View File

@ -11,15 +11,15 @@ export const meta = {
params: {
token: {
validator: $.str,
}
},
},
errors: {
noSuchSession: {
message: 'No such session.',
code: 'NO_SUCH_SESSION',
id: 'bd72c97d-eba7-4adb-a467-f171b8847250'
}
id: 'bd72c97d-eba7-4adb-a467-f171b8847250',
},
},
res: {
@ -29,25 +29,25 @@ export const meta = {
id: {
type: 'string' as const,
optional: false as const, nullable: false as const,
format: 'id'
format: 'id',
},
app: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'App'
ref: 'App',
},
token: {
type: 'string' as const,
optional: false as const, nullable: false as const
}
}
}
optional: false as const, nullable: false as const,
},
},
},
};
export default define(meta, async (ps, user) => {
// Lookup session
const session = await AuthSessions.findOne({
token: ps.token
token: ps.token,
});
if (session == null) {

View File

@ -15,7 +15,7 @@ export const meta = {
token: {
validator: $.str,
}
},
},
res: {
@ -32,34 +32,34 @@ export const meta = {
optional: false as const, nullable: false as const,
ref: 'User',
},
}
},
},
errors: {
noSuchApp: {
message: 'No such app.',
code: 'NO_SUCH_APP',
id: 'fcab192a-2c5a-43b7-8ad8-9b7054d8d40d'
id: 'fcab192a-2c5a-43b7-8ad8-9b7054d8d40d',
},
noSuchSession: {
message: 'No such session.',
code: 'NO_SUCH_SESSION',
id: '5b5a1503-8bc8-4bd0-8054-dc189e8cdcb3'
id: '5b5a1503-8bc8-4bd0-8054-dc189e8cdcb3',
},
pendingSession: {
message: 'This session is not completed yet.',
code: 'PENDING_SESSION',
id: '8c8a4145-02cc-4cca-8e66-29ba60445a8e'
}
}
id: '8c8a4145-02cc-4cca-8e66-29ba60445a8e',
},
},
};
export default define(meta, async (ps) => {
// Lookup app
const app = await Apps.findOne({
secret: ps.appSecret
secret: ps.appSecret,
});
if (app == null) {
@ -69,7 +69,7 @@ export default define(meta, async (ps) => {
// Fetch token
const session = await AuthSessions.findOne({
token: ps.token,
appId: app.id
appId: app.id,
});
if (session == null) {
@ -83,7 +83,7 @@ export default define(meta, async (ps) => {
// Lookup access token
const accessToken = await AccessTokens.findOneOrFail({
appId: app.id,
userId: session.userId
userId: session.userId,
});
// Delete session
@ -92,7 +92,7 @@ export default define(meta, async (ps) => {
return {
accessToken: accessToken.token,
user: await Users.pack(session.userId, null, {
detail: true
})
detail: true,
}),
};
});

View File

@ -12,7 +12,7 @@ export const meta = {
limit: {
duration: ms('1hour'),
max: 100
max: 100,
},
requireCredential: true as const,
@ -22,34 +22,34 @@ export const meta = {
params: {
userId: {
validator: $.type(ID),
}
},
},
errors: {
noSuchUser: {
message: 'No such user.',
code: 'NO_SUCH_USER',
id: '7cc4f851-e2f1-4621-9633-ec9e1d00c01e'
id: '7cc4f851-e2f1-4621-9633-ec9e1d00c01e',
},
blockeeIsYourself: {
message: 'Blockee is yourself.',
code: 'BLOCKEE_IS_YOURSELF',
id: '88b19138-f28d-42c0-8499-6a31bbd0fdc6'
id: '88b19138-f28d-42c0-8499-6a31bbd0fdc6',
},
alreadyBlocking: {
message: 'You are already blocking that user.',
code: 'ALREADY_BLOCKING',
id: '787fed64-acb9-464a-82eb-afbd745b9614'
id: '787fed64-acb9-464a-82eb-afbd745b9614',
},
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'User'
}
ref: 'User',
},
};
export default define(meta, async (ps, user) => {
@ -69,7 +69,7 @@ export default define(meta, async (ps, user) => {
// Check if already blocking
const exist = await Blockings.findOne({
blockerId: blocker.id,
blockeeId: blockee.id
blockeeId: blockee.id,
});
if (exist != null) {
@ -80,10 +80,10 @@ export default define(meta, async (ps, user) => {
NoteWatchings.delete({
userId: blocker.id,
noteUserId: blockee.id
noteUserId: blockee.id,
});
return await Users.pack(blockee.id, blocker, {
detail: true
detail: true,
});
});

View File

@ -12,7 +12,7 @@ export const meta = {
limit: {
duration: ms('1hour'),
max: 100
max: 100,
},
requireCredential: true as const,
@ -22,26 +22,26 @@ export const meta = {
params: {
userId: {
validator: $.type(ID),
}
},
},
errors: {
noSuchUser: {
message: 'No such user.',
code: 'NO_SUCH_USER',
id: '8621d8bf-c358-4303-a066-5ea78610eb3f'
id: '8621d8bf-c358-4303-a066-5ea78610eb3f',
},
blockeeIsYourself: {
message: 'Blockee is yourself.',
code: 'BLOCKEE_IS_YOURSELF',
id: '06f6fac6-524b-473c-a354-e97a40ae6eac'
id: '06f6fac6-524b-473c-a354-e97a40ae6eac',
},
notBlocking: {
message: 'You are not blocking that user.',
code: 'NOT_BLOCKING',
id: '291b2efa-60c6-45c0-9f6a-045c8f9b02cd'
id: '291b2efa-60c6-45c0-9f6a-045c8f9b02cd',
},
},
@ -69,7 +69,7 @@ export default define(meta, async (ps, user) => {
// Check not blocking
const exist = await Blockings.findOne({
blockerId: blocker.id,
blockeeId: blockee.id
blockeeId: blockee.id,
});
if (exist == null) {
@ -80,6 +80,6 @@ export default define(meta, async (ps, user) => {
await deleteBlocking(blocker, blockee);
return await Users.pack(blockee.id, blocker, {
detail: true
detail: true,
});
});

View File

@ -14,7 +14,7 @@ export const meta = {
params: {
limit: {
validator: $.optional.num.range(1, 100),
default: 30
default: 30,
},
sinceId: {
@ -33,7 +33,7 @@ export const meta = {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Blocking',
}
},
},
};

View File

@ -15,16 +15,16 @@ export const meta = {
params: {
name: {
validator: $.str.range(1, 128)
validator: $.str.range(1, 128),
},
description: {
validator: $.nullable.optional.str.range(1, 2048)
validator: $.nullable.optional.str.range(1, 2048),
},
bannerId: {
validator: $.nullable.optional.type(ID),
}
},
},
res: {
@ -37,9 +37,9 @@ export const meta = {
noSuchFile: {
message: 'No such file.',
code: 'NO_SUCH_FILE',
id: 'cd1e9f3e-5a12-4ab4-96f6-5d0a2cc32050'
id: 'cd1e9f3e-5a12-4ab4-96f6-5d0a2cc32050',
},
}
},
};
export default define(meta, async (ps, user) => {
@ -47,7 +47,7 @@ export default define(meta, async (ps, user) => {
if (ps.bannerId != null) {
banner = await DriveFiles.findOne({
id: ps.bannerId,
userId: user.id
userId: user.id,
});
if (banner == null) {

View File

@ -13,7 +13,7 @@ export const meta = {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Channel',
}
},
},
};

View File

@ -23,9 +23,9 @@ export const meta = {
noSuchChannel: {
message: 'No such channel.',
code: 'NO_SUCH_CHANNEL',
id: 'c0031718-d573-4e85-928e-10039f1fbb68'
id: 'c0031718-d573-4e85-928e-10039f1fbb68',
},
}
},
};
export default define(meta, async (ps, user) => {

View File

@ -22,7 +22,7 @@ export const meta = {
limit: {
validator: $.optional.num.range(1, 100),
default: 5
default: 5,
},
},
@ -33,7 +33,7 @@ export const meta = {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Channel',
}
},
},
};

View File

@ -22,7 +22,7 @@ export const meta = {
limit: {
validator: $.optional.num.range(1, 100),
default: 5
default: 5,
},
},
@ -33,7 +33,7 @@ export const meta = {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Channel',
}
},
},
};

View File

@ -25,9 +25,9 @@ export const meta = {
noSuchChannel: {
message: 'No such channel.',
code: 'NO_SUCH_CHANNEL',
id: '6f6c314b-7486-4897-8966-c04a66a02923'
id: '6f6c314b-7486-4897-8966-c04a66a02923',
},
}
},
};
export default define(meta, async (ps, me) => {

View File

@ -45,16 +45,16 @@ export const meta = {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Note',
}
},
},
errors: {
noSuchChannel: {
message: 'No such channel.',
code: 'NO_SUCH_CHANNEL',
id: '4d0eeeba-a02c-4c3c-9966-ef60d38d2e7f'
}
}
id: '4d0eeeba-a02c-4c3c-9966-ef60d38d2e7f',
},
},
};
export default define(meta, async (ps, user) => {

View File

@ -22,9 +22,9 @@ export const meta = {
noSuchChannel: {
message: 'No such channel.',
code: 'NO_SUCH_CHANNEL',
id: '19959ee9-0153-4c51-bbd9-a98c49dc59d6'
id: '19959ee9-0153-4c51-bbd9-a98c49dc59d6',
},
}
},
};
export default define(meta, async (ps, user) => {

View File

@ -17,16 +17,16 @@ export const meta = {
},
name: {
validator: $.optional.str.range(1, 128)
validator: $.optional.str.range(1, 128),
},
description: {
validator: $.nullable.optional.str.range(1, 2048)
validator: $.nullable.optional.str.range(1, 2048),
},
bannerId: {
validator: $.nullable.optional.type(ID),
}
},
},
res: {
@ -39,21 +39,21 @@ export const meta = {
noSuchChannel: {
message: 'No such channel.',
code: 'NO_SUCH_CHANNEL',
id: 'f9c5467f-d492-4c3c-9a8d-a70dacc86512'
id: 'f9c5467f-d492-4c3c-9a8d-a70dacc86512',
},
accessDenied: {
message: 'You do not have edit privilege of the channel.',
code: 'ACCESS_DENIED',
id: '1fb7cb09-d46a-4fdf-b8df-057788cce513'
id: '1fb7cb09-d46a-4fdf-b8df-057788cce513',
},
noSuchFile: {
message: 'No such file.',
code: 'NO_SUCH_FILE',
id: 'e86c14a4-0da2-4032-8df3-e737a04c7f3b'
id: 'e86c14a4-0da2-4032-8df3-e737a04c7f3b',
},
}
},
};
export default define(meta, async (ps, me) => {
@ -74,7 +74,7 @@ export default define(meta, async (ps, me) => {
if (ps.bannerId != null) {
banner = await DriveFiles.findOne({
id: ps.bannerId,
userId: me.id
userId: me.id,
});
if (banner == null) {

View File

@ -23,7 +23,7 @@ export const meta = {
host: {
validator: $.str,
}
},
},
res: convertLog(instanceChart.schema),

View File

@ -24,7 +24,7 @@ export const meta = {
userId: {
validator: $.type(ID),
}
},
},
res: convertLog(perUserDriveChart.schema),

View File

@ -24,7 +24,7 @@ export const meta = {
userId: {
validator: $.type(ID),
}
},
},
res: convertLog(perUserFollowingChart.schema),

View File

@ -24,7 +24,7 @@ export const meta = {
userId: {
validator: $.type(ID),
}
},
},
res: convertLog(perUserNotesChart.schema),

View File

@ -24,7 +24,7 @@ export const meta = {
userId: {
validator: $.type(ID),
}
},
},
res: convertLog(perUserReactionsChart.schema),

View File

@ -27,27 +27,27 @@ export const meta = {
noSuchClip: {
message: 'No such clip.',
code: 'NO_SUCH_CLIP',
id: 'd6e76cc0-a1b5-4c7c-a287-73fa9c716dcf'
id: 'd6e76cc0-a1b5-4c7c-a287-73fa9c716dcf',
},
noSuchNote: {
message: 'No such note.',
code: 'NO_SUCH_NOTE',
id: 'fc8c0b49-c7a3-4664-a0a6-b418d386bb8b'
id: 'fc8c0b49-c7a3-4664-a0a6-b418d386bb8b',
},
alreadyClipped: {
message: 'The note has already been clipped.',
code: 'ALREADY_CLIPPED',
id: '734806c4-542c-463a-9311-15c512803965'
id: '734806c4-542c-463a-9311-15c512803965',
},
}
},
};
export default define(meta, async (ps, user) => {
const clip = await Clips.findOne({
id: ps.clipId,
userId: user.id
userId: user.id,
});
if (clip == null) {
@ -61,7 +61,7 @@ export default define(meta, async (ps, user) => {
const exist = await ClipNotes.findOne({
noteId: note.id,
clipId: clip.id
clipId: clip.id,
});
if (exist != null) {
@ -71,6 +71,6 @@ export default define(meta, async (ps, user) => {
await ClipNotes.insert({
id: genId(),
noteId: note.id,
clipId: clip.id
clipId: clip.id,
});
});

View File

@ -12,23 +12,23 @@ export const meta = {
params: {
name: {
validator: $.str.range(1, 100)
validator: $.str.range(1, 100),
},
isPublic: {
validator: $.optional.bool
validator: $.optional.bool,
},
description: {
validator: $.optional.nullable.str.range(1, 2048)
}
validator: $.optional.nullable.str.range(1, 2048),
},
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Clip'
}
ref: 'Clip',
},
};
export default define(meta, async (ps, user) => {

View File

@ -14,22 +14,22 @@ export const meta = {
params: {
clipId: {
validator: $.type(ID),
}
},
},
errors: {
noSuchClip: {
message: 'No such clip.',
code: 'NO_SUCH_CLIP',
id: '70ca08ba-6865-4630-b6fb-8494759aa754'
}
}
id: '70ca08ba-6865-4630-b6fb-8494759aa754',
},
},
};
export default define(meta, async (ps, user) => {
const clip = await Clips.findOne({
id: ps.clipId,
userId: user.id
userId: user.id,
});
if (clip == null) {

View File

@ -14,9 +14,9 @@ export const meta = {
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Clip'
}
}
ref: 'Clip',
},
},
};
export default define(meta, async (ps, me) => {

View File

@ -22,7 +22,7 @@ export const meta = {
limit: {
validator: $.optional.num.range(1, 100),
default: 10
default: 10,
},
sinceId: {
@ -38,8 +38,8 @@ export const meta = {
noSuchClip: {
message: 'No such clip.',
code: 'NO_SUCH_CLIP',
id: '1d7645e6-2b6d-4635-b0fe-fe22b0e72e00'
}
id: '1d7645e6-2b6d-4635-b0fe-fe22b0e72e00',
},
},
res: {
@ -48,9 +48,9 @@ export const meta = {
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Note'
}
}
ref: 'Note',
},
},
};
export default define(meta, async (ps, user) => {

View File

@ -21,15 +21,15 @@ export const meta = {
noSuchClip: {
message: 'No such clip.',
code: 'NO_SUCH_CLIP',
id: 'c3c5fe33-d62c-44d2-9ea5-d997703f5c20'
id: 'c3c5fe33-d62c-44d2-9ea5-d997703f5c20',
},
},
res: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'Clip'
}
ref: 'Clip',
},
};
export default define(meta, async (ps, me) => {

Some files were not shown because too many files have changed in this diff Show More