refactor
This commit is contained in:
parent
98e07c3bd1
commit
87d09f255d
|
@ -65,6 +65,7 @@ import {
|
||||||
packedMetaDetailedSchema,
|
packedMetaDetailedSchema,
|
||||||
packedMetaLiteSchema,
|
packedMetaLiteSchema,
|
||||||
} from '@/models/json-schema/meta.js';
|
} 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 { packedSystemWebhookSchema } from '@/models/json-schema/system-webhook.js';
|
||||||
import { packedAbuseReportNotificationRecipientSchema } from '@/models/json-schema/abuse-report-notification-recipient.js';
|
import { packedAbuseReportNotificationRecipientSchema } from '@/models/json-schema/abuse-report-notification-recipient.js';
|
||||||
import { packedChatMessageSchema, packedChatMessageLiteSchema, packedChatMessageLiteForRoomSchema, packedChatMessageLiteFor1on1Schema } from '@/models/json-schema/chat-message.js';
|
import { packedChatMessageSchema, packedChatMessageLiteSchema, packedChatMessageLiteForRoomSchema, packedChatMessageLiteFor1on1Schema } from '@/models/json-schema/chat-message.js';
|
||||||
|
@ -134,6 +135,7 @@ export const refs = {
|
||||||
MetaLite: packedMetaLiteSchema,
|
MetaLite: packedMetaLiteSchema,
|
||||||
MetaDetailedOnly: packedMetaDetailedOnlySchema,
|
MetaDetailedOnly: packedMetaDetailedOnlySchema,
|
||||||
MetaDetailed: packedMetaDetailedSchema,
|
MetaDetailed: packedMetaDetailedSchema,
|
||||||
|
UserWebhook: packedUserWebhookSchema,
|
||||||
SystemWebhook: packedSystemWebhookSchema,
|
SystemWebhook: packedSystemWebhookSchema,
|
||||||
AbuseReportNotificationRecipient: packedAbuseReportNotificationRecipientSchema,
|
AbuseReportNotificationRecipient: packedAbuseReportNotificationRecipientSchema,
|
||||||
ChatMessage: packedChatMessageSchema,
|
ChatMessage: packedChatMessageSchema,
|
||||||
|
|
|
@ -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;
|
|
@ -21,29 +21,7 @@ export const meta = {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: {
|
items: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
ref: 'UserWebhook',
|
||||||
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 },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -65,19 +43,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
userId: me.id,
|
userId: me.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
return webhooks.map(webhook => (
|
return webhooks.map(webhook => ({
|
||||||
{
|
id: webhook.id,
|
||||||
id: webhook.id,
|
userId: webhook.userId,
|
||||||
userId: webhook.userId,
|
name: webhook.name,
|
||||||
name: webhook.name,
|
on: webhook.on,
|
||||||
on: webhook.on,
|
url: webhook.url,
|
||||||
url: webhook.url,
|
secret: webhook.secret,
|
||||||
secret: webhook.secret,
|
active: webhook.active,
|
||||||
active: webhook.active,
|
latestSentAt: webhook.latestSentAt ? webhook.latestSentAt.toISOString() : null,
|
||||||
latestSentAt: webhook.latestSentAt ? webhook.latestSentAt.toISOString() : null,
|
latestStatus: webhook.latestStatus,
|
||||||
latestStatus: webhook.latestStatus,
|
}));
|
||||||
}
|
|
||||||
));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,29 +28,7 @@ export const meta = {
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
ref: 'UserWebhook',
|
||||||
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 },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ async function addItem() {
|
||||||
value: '-', text: i18n.ts.divider,
|
value: '-', text: i18n.ts.divider,
|
||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
if (canceled) return;
|
if (canceled || item == null) return;
|
||||||
items.value = [...items.value, {
|
items.value = [...items.value, {
|
||||||
id: genId(),
|
id: genId(),
|
||||||
type: item,
|
type: item,
|
||||||
|
|
Loading…
Reference in New Issue