2024-06-08 08:34:19 +02:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { defineAsyncComponent } from 'vue';
|
|
|
|
import * as os from '@/os.js';
|
|
|
|
|
|
|
|
export type SystemWebhookEventType = 'abuseReport' | 'abuseReportResolved';
|
|
|
|
|
|
|
|
export type MkSystemWebhookEditorProps = {
|
|
|
|
mode: 'create' | 'edit';
|
|
|
|
id?: string;
|
|
|
|
requiredEvents?: SystemWebhookEventType[];
|
|
|
|
};
|
|
|
|
|
|
|
|
export type MkSystemWebhookResult = {
|
|
|
|
id?: string;
|
|
|
|
isActive: boolean;
|
|
|
|
name: string;
|
|
|
|
on: SystemWebhookEventType[];
|
|
|
|
url: string;
|
|
|
|
secret: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
export async function showSystemWebhookEditorDialog(props: MkSystemWebhookEditorProps): Promise<MkSystemWebhookResult | null> {
|
|
|
|
const { dispose, result } = await new Promise<{ dispose: () => void, result: MkSystemWebhookResult | null }>(async resolve => {
|
2024-07-04 06:14:49 +02:00
|
|
|
const { dispose: _dispose } = os.popup(
|
2024-06-08 08:34:19 +02:00
|
|
|
defineAsyncComponent(() => import('@/components/MkSystemWebhookEditor.vue')),
|
|
|
|
props,
|
|
|
|
{
|
|
|
|
submitted: (ev: MkSystemWebhookResult) => {
|
2024-07-04 06:14:49 +02:00
|
|
|
resolve({ dispose: _dispose, result: ev });
|
2024-06-08 08:34:19 +02:00
|
|
|
},
|
|
|
|
closed: () => {
|
2024-07-04 06:14:49 +02:00
|
|
|
resolve({ dispose: _dispose, result: null });
|
2024-06-08 08:34:19 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
dispose();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|