summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-08-27 15:59:39 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2025-08-27 15:59:39 +0900
commit87d09f255dd702627bbc6fa58692eebba3830889 (patch)
treeb5defcefd421adcc24c56708ea3393b91c788c93 /packages
parentperf(frontend): use WeakMap (diff)
downloadmisskey-87d09f255dd702627bbc6fa58692eebba3830889.tar.gz
misskey-87d09f255dd702627bbc6fa58692eebba3830889.tar.bz2
misskey-87d09f255dd702627bbc6fa58692eebba3830889.zip
refactor
Diffstat (limited to 'packages')
-rw-r--r--packages/backend/src/misc/json-schema.ts2
-rw-r--r--packages/backend/src/models/json-schema/user-webhook.ts55
-rw-r--r--packages/backend/src/server/api/endpoints/i/webhooks/list.ts48
-rw-r--r--packages/backend/src/server/api/endpoints/i/webhooks/show.ts24
-rw-r--r--packages/frontend/src/pages/settings/navbar.vue2
5 files changed, 71 insertions, 60 deletions
diff --git a/packages/backend/src/misc/json-schema.ts b/packages/backend/src/misc/json-schema.ts
index dca92e1037..ed7d5bfc3a 100644
--- a/packages/backend/src/misc/json-schema.ts
+++ b/packages/backend/src/misc/json-schema.ts
@@ -65,6 +65,7 @@ import {
packedMetaDetailedSchema,
packedMetaLiteSchema,
} from '@/models/json-schema/meta.js';
+import { packedUserWebhookSchema } from '@/models/json-schema/user-webhook.js';
import { packedSystemWebhookSchema } from '@/models/json-schema/system-webhook.js';
import { packedAbuseReportNotificationRecipientSchema } from '@/models/json-schema/abuse-report-notification-recipient.js';
import { packedChatMessageSchema, packedChatMessageLiteSchema, packedChatMessageLiteForRoomSchema, packedChatMessageLiteFor1on1Schema } from '@/models/json-schema/chat-message.js';
@@ -134,6 +135,7 @@ export const refs = {
MetaLite: packedMetaLiteSchema,
MetaDetailedOnly: packedMetaDetailedOnlySchema,
MetaDetailed: packedMetaDetailedSchema,
+ UserWebhook: packedUserWebhookSchema,
SystemWebhook: packedSystemWebhookSchema,
AbuseReportNotificationRecipient: packedAbuseReportNotificationRecipientSchema,
ChatMessage: packedChatMessageSchema,
diff --git a/packages/backend/src/models/json-schema/user-webhook.ts b/packages/backend/src/models/json-schema/user-webhook.ts
new file mode 100644
index 0000000000..8ea0991716
--- /dev/null
+++ b/packages/backend/src/models/json-schema/user-webhook.ts
@@ -0,0 +1,55 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+import { webhookEventTypes } from '@/models/Webhook.js';
+
+export const packedUserWebhookSchema = {
+ type: 'object',
+ properties: {
+ id: {
+ type: 'string',
+ format: 'id',
+ optional: false, nullable: false,
+ },
+ userId: {
+ type: 'string',
+ format: 'id',
+ optional: false, nullable: false,
+ },
+ name: {
+ type: 'string',
+ optional: false, nullable: false,
+ },
+ on: {
+ type: 'array',
+ items: {
+ type: 'string',
+ optional: false, nullable: false,
+ enum: webhookEventTypes,
+ },
+ },
+ url: {
+ type: 'string',
+ optional: false, nullable: false,
+ },
+ secret: {
+ type: 'string',
+ optional: false, nullable: false,
+ },
+ active: {
+ type: 'boolean',
+ optional: false, nullable: false,
+ },
+ latestSentAt: {
+ type: 'string',
+ format: 'date-time',
+ optional: false, nullable: true,
+ },
+ latestStatus: {
+ type: 'integer',
+ optional: false, nullable: true,
+ },
+ },
+} as const;
diff --git a/packages/backend/src/server/api/endpoints/i/webhooks/list.ts b/packages/backend/src/server/api/endpoints/i/webhooks/list.ts
index 394c178f2a..8a3ba9e026 100644
--- a/packages/backend/src/server/api/endpoints/i/webhooks/list.ts
+++ b/packages/backend/src/server/api/endpoints/i/webhooks/list.ts
@@ -21,29 +21,7 @@ export const meta = {
type: 'array',
items: {
type: 'object',
- properties: {
- id: {
- type: 'string',
- format: 'misskey:id',
- },
- userId: {
- type: 'string',
- format: 'misskey:id',
- },
- name: { type: 'string' },
- on: {
- type: 'array',
- items: {
- type: 'string',
- enum: webhookEventTypes,
- },
- },
- url: { type: 'string' },
- secret: { type: 'string' },
- active: { type: 'boolean' },
- latestSentAt: { type: 'string', format: 'date-time', nullable: true },
- latestStatus: { type: 'integer', nullable: true },
- },
+ ref: 'UserWebhook',
},
},
} as const;
@@ -65,19 +43,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
userId: me.id,
});
- return webhooks.map(webhook => (
- {
- id: webhook.id,
- userId: webhook.userId,
- name: webhook.name,
- on: webhook.on,
- url: webhook.url,
- secret: webhook.secret,
- active: webhook.active,
- latestSentAt: webhook.latestSentAt ? webhook.latestSentAt.toISOString() : null,
- latestStatus: webhook.latestStatus,
- }
- ));
+ return webhooks.map(webhook => ({
+ id: webhook.id,
+ userId: webhook.userId,
+ name: webhook.name,
+ on: webhook.on,
+ url: webhook.url,
+ secret: webhook.secret,
+ active: webhook.active,
+ latestSentAt: webhook.latestSentAt ? webhook.latestSentAt.toISOString() : null,
+ latestStatus: webhook.latestStatus,
+ }));
});
}
}
diff --git a/packages/backend/src/server/api/endpoints/i/webhooks/show.ts b/packages/backend/src/server/api/endpoints/i/webhooks/show.ts
index 4a0c09ff0c..1c19081c98 100644
--- a/packages/backend/src/server/api/endpoints/i/webhooks/show.ts
+++ b/packages/backend/src/server/api/endpoints/i/webhooks/show.ts
@@ -28,29 +28,7 @@ export const meta = {
res: {
type: 'object',
- properties: {
- id: {
- type: 'string',
- format: 'misskey:id',
- },
- userId: {
- type: 'string',
- format: 'misskey:id',
- },
- name: { type: 'string' },
- on: {
- type: 'array',
- items: {
- type: 'string',
- enum: webhookEventTypes,
- },
- },
- url: { type: 'string' },
- secret: { type: 'string' },
- active: { type: 'boolean' },
- latestSentAt: { type: 'string', format: 'date-time', nullable: true },
- latestStatus: { type: 'integer', nullable: true },
- },
+ ref: 'UserWebhook',
},
} as const;
diff --git a/packages/frontend/src/pages/settings/navbar.vue b/packages/frontend/src/pages/settings/navbar.vue
index 09c1199d0c..f7c634b42e 100644
--- a/packages/frontend/src/pages/settings/navbar.vue
+++ b/packages/frontend/src/pages/settings/navbar.vue
@@ -91,7 +91,7 @@ async function addItem() {
value: '-', text: i18n.ts.divider,
}],
});
- if (canceled) return;
+ if (canceled || item == null) return;
items.value = [...items.value, {
id: genId(),
type: item,