Merge branch 'develop' into re-ed25519
This commit is contained in:
commit
61d5371073
233 changed files with 3595 additions and 951 deletions
|
|
@ -377,6 +377,10 @@ export const meta = {
|
|||
type: 'number',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
enableReactionsBuffering: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
notesPerOneAd: {
|
||||
type: 'number',
|
||||
optional: false, nullable: false,
|
||||
|
|
@ -617,6 +621,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
perRemoteUserUserTimelineCacheMax: instance.perRemoteUserUserTimelineCacheMax,
|
||||
perUserHomeTimelineCacheMax: instance.perUserHomeTimelineCacheMax,
|
||||
perUserListTimelineCacheMax: instance.perUserListTimelineCacheMax,
|
||||
enableReactionsBuffering: instance.enableReactionsBuffering,
|
||||
notesPerOneAd: instance.notesPerOneAd,
|
||||
summalyProxy: instance.urlPreviewSummaryProxyUrl,
|
||||
urlPreviewEnabled: instance.urlPreviewEnabled,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import ms from 'ms';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { WebhookTestService } from '@/core/WebhookTestService.js';
|
||||
import { ApiError } from '@/server/api/error.js';
|
||||
import { systemWebhookEventTypes } from '@/models/SystemWebhook.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['webhooks'],
|
||||
|
||||
requireCredential: true,
|
||||
requireModerator: true,
|
||||
secure: true,
|
||||
kind: 'read:admin:system-webhook',
|
||||
|
||||
limit: {
|
||||
duration: ms('15min'),
|
||||
max: 60,
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchWebhook: {
|
||||
message: 'No such webhook.',
|
||||
code: 'NO_SUCH_WEBHOOK',
|
||||
id: '0c52149c-e913-18f8-5dc7-74870bfe0cf9',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
webhookId: {
|
||||
type: 'string',
|
||||
format: 'misskey:id',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
enum: systemWebhookEventTypes,
|
||||
},
|
||||
override: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
url: { type: 'string', nullable: false },
|
||||
secret: { type: 'string', nullable: false },
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['webhookId', 'type'],
|
||||
} as const;
|
||||
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||
constructor(
|
||||
private webhookTestService: WebhookTestService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps) => {
|
||||
try {
|
||||
await this.webhookTestService.testSystemWebhook({
|
||||
webhookId: ps.webhookId,
|
||||
type: ps.type,
|
||||
override: ps.override,
|
||||
});
|
||||
} catch (e) {
|
||||
if (e instanceof WebhookTestService.NoSuchWebhookError) {
|
||||
throw new ApiError(meta.errors.noSuchWebhook);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -142,6 +142,7 @@ export const paramDef = {
|
|||
perRemoteUserUserTimelineCacheMax: { type: 'integer' },
|
||||
perUserHomeTimelineCacheMax: { type: 'integer' },
|
||||
perUserListTimelineCacheMax: { type: 'integer' },
|
||||
enableReactionsBuffering: { type: 'boolean' },
|
||||
notesPerOneAd: { type: 'integer' },
|
||||
silencedHosts: {
|
||||
type: 'array',
|
||||
|
|
@ -598,6 +599,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
set.perUserListTimelineCacheMax = ps.perUserListTimelineCacheMax;
|
||||
}
|
||||
|
||||
if (ps.enableReactionsBuffering !== undefined) {
|
||||
set.enableReactionsBuffering = ps.enableReactionsBuffering;
|
||||
}
|
||||
|
||||
if (ps.notesPerOneAd !== undefined) {
|
||||
set.notesPerOneAd = ps.notesPerOneAd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@ export const meta = {
|
|||
code: 'TOO_MANY_ANTENNAS',
|
||||
id: 'faf47050-e8b5-438c-913c-db2b1576fde4',
|
||||
},
|
||||
|
||||
emptyKeyword: {
|
||||
message: 'Either keywords or excludeKeywords is required.',
|
||||
code: 'EMPTY_KEYWORD',
|
||||
id: '53ee222e-1ddd-4f9a-92e5-9fb82ddb463a',
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
|
|
@ -87,7 +93,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) {
|
||||
throw new Error('either keywords or excludeKeywords is required.');
|
||||
throw new ApiError(meta.errors.emptyKeyword);
|
||||
}
|
||||
|
||||
const currentAntennasCount = await this.antennasRepository.countBy({
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@ export const meta = {
|
|||
code: 'NO_SUCH_USER_LIST',
|
||||
id: '1c6b35c9-943e-48c2-81e4-2844989407f7',
|
||||
},
|
||||
|
||||
emptyKeyword: {
|
||||
message: 'Either keywords or excludeKeywords is required.',
|
||||
code: 'EMPTY_KEYWORD',
|
||||
id: '721aaff6-4e1b-4d88-8de6-877fae9f68c4',
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
|
|
@ -85,7 +91,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
super(meta, paramDef, async (ps, me) => {
|
||||
if (ps.keywords && ps.excludeKeywords) {
|
||||
if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) {
|
||||
throw new Error('either keywords or excludeKeywords is required.');
|
||||
throw new ApiError(meta.errors.emptyKeyword);
|
||||
}
|
||||
}
|
||||
// Fetch the antenna
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import { ApiError } from '../../error.js';
|
|||
export const meta = {
|
||||
secure: true,
|
||||
requireCredential: true,
|
||||
requireRolePolicy: 'canImportAntennas',
|
||||
prohibitMoved: true,
|
||||
|
||||
limit: {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { ApiError } from '../../error.js';
|
|||
export const meta = {
|
||||
secure: true,
|
||||
requireCredential: true,
|
||||
requireRolePolicy: 'canImportBlocking',
|
||||
prohibitMoved: true,
|
||||
|
||||
limit: {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { ApiError } from '../../error.js';
|
|||
export const meta = {
|
||||
secure: true,
|
||||
requireCredential: true,
|
||||
requireRolePolicy: 'canImportFollowing',
|
||||
prohibitMoved: true,
|
||||
limit: {
|
||||
duration: ms('1hour'),
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { ApiError } from '../../error.js';
|
|||
export const meta = {
|
||||
secure: true,
|
||||
requireCredential: true,
|
||||
requireRolePolicy: 'canImportMuting',
|
||||
prohibitMoved: true,
|
||||
|
||||
limit: {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { ApiError } from '../../error.js';
|
|||
export const meta = {
|
||||
secure: true,
|
||||
requireCredential: true,
|
||||
requireRolePolicy: 'canImportUserLists',
|
||||
prohibitMoved: true,
|
||||
limit: {
|
||||
duration: ms('1hour'),
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { DI } from '@/di-symbols.js';
|
|||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { ApiError } from '@/server/api/error.js';
|
||||
|
||||
// TODO: UserWebhook schemaの適用
|
||||
export const meta = {
|
||||
tags: ['webhooks'],
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { webhookEventTypes } from '@/models/Webhook.js';
|
|||
import type { WebhooksRepository } from '@/models/_.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
|
||||
// TODO: UserWebhook schemaの適用
|
||||
export const meta = {
|
||||
tags: ['webhooks', 'account'],
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import type { WebhooksRepository } from '@/models/_.js';
|
|||
import { DI } from '@/di-symbols.js';
|
||||
import { ApiError } from '../../../error.js';
|
||||
|
||||
// TODO: UserWebhook schemaの適用
|
||||
export const meta = {
|
||||
tags: ['webhooks'],
|
||||
|
||||
|
|
|
|||
76
packages/backend/src/server/api/endpoints/i/webhooks/test.ts
Normal file
76
packages/backend/src/server/api/endpoints/i/webhooks/test.ts
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import ms from 'ms';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { webhookEventTypes } from '@/models/Webhook.js';
|
||||
import { WebhookTestService } from '@/core/WebhookTestService.js';
|
||||
import { ApiError } from '@/server/api/error.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['webhooks'],
|
||||
|
||||
requireCredential: true,
|
||||
secure: true,
|
||||
kind: 'read:account',
|
||||
|
||||
limit: {
|
||||
duration: ms('15min'),
|
||||
max: 60,
|
||||
},
|
||||
|
||||
errors: {
|
||||
noSuchWebhook: {
|
||||
message: 'No such webhook.',
|
||||
code: 'NO_SUCH_WEBHOOK',
|
||||
id: '0c52149c-e913-18f8-5dc7-74870bfe0cf9',
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
webhookId: {
|
||||
type: 'string',
|
||||
format: 'misskey:id',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
enum: webhookEventTypes,
|
||||
},
|
||||
override: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
url: { type: 'string' },
|
||||
secret: { type: 'string' },
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['webhookId', 'type'],
|
||||
} as const;
|
||||
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||
constructor(
|
||||
private webhookTestService: WebhookTestService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
try {
|
||||
await this.webhookTestService.testUserWebhook({
|
||||
webhookId: ps.webhookId,
|
||||
type: ps.type,
|
||||
override: ps.override,
|
||||
}, me);
|
||||
} catch (e) {
|
||||
if (e instanceof WebhookTestService.NoSuchWebhookError) {
|
||||
throw new ApiError(meta.errors.noSuchWebhook);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue