From cd6428715e6780d51e8f6edf93fe7e32bd8f937b Mon Sep 17 00:00:00 2001 From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:31:50 +0900 Subject: feat: テスト通知を送信できるようにする (#11810) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * (add) Notification test * Update Changelog * (add) backend, frontend impl * globalEventの名前を明確にする * Run API Extractor --- packages/frontend/src/scripts/test-notification.ts | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 packages/frontend/src/scripts/test-notification.ts (limited to 'packages/frontend/src/scripts') diff --git a/packages/frontend/src/scripts/test-notification.ts b/packages/frontend/src/scripts/test-notification.ts new file mode 100644 index 0000000000..0e8289e19e --- /dev/null +++ b/packages/frontend/src/scripts/test-notification.ts @@ -0,0 +1,34 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import * as Misskey from 'misskey-js'; +import * as os from '@/os'; +import { globalEvents } from '@/events'; + +/** + * テスト通知を送信 + * + * - `client` … 通知ポップアップのみを表示 + * - `server` … サーバー側から通知を送信 + * + * @param type 通知タイプを指定 + */ +export function testNotification(type: 'client' | 'server'): void { + const notification: Misskey.entities.Notification = { + id: Math.random().toString(), + createdAt: new Date().toUTCString(), + isRead: false, + type: 'test', + }; + + switch (type) { + case 'server': + os.api('notifications/test-notification'); + break; + case 'client': + globalEvents.emit('clientNotification', notification); + break; + } +} -- cgit v1.2.3-freya