From b96edad800498fe81116e4357e0a0878fc065232 Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 27 Jul 2021 02:35:19 +0900 Subject: [PATCH] Implement api sw/unregister --- src/server/api/endpoints/sw/unregister.ts | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/server/api/endpoints/sw/unregister.ts diff --git a/src/server/api/endpoints/sw/unregister.ts b/src/server/api/endpoints/sw/unregister.ts new file mode 100644 index 0000000000..e086357db8 --- /dev/null +++ b/src/server/api/endpoints/sw/unregister.ts @@ -0,0 +1,37 @@ +import $ from 'cafy'; +import define from '../../define'; +import { SwSubscriptions } from '../../../../models'; + +export const meta = { + tags: ['account'], + + requireCredential: true as const, + + desc: { + 'ja-JP': 'Push通知の登録を削除します。', + 'en-US': 'Remove push noticfication registration' + }, + + params: { + endpoint: { + validator: $.str + }, + + all: { + validator: $.optional.bool, + default: false, + desc: { + 'ja-JP': 'false(デフォルト)は、自分の登録のみが解除されます。trueを指定すると、指定したエンドポイントのすべての登録を解除します。' + } + } + } +}; + +export default define(meta, async (ps, user) => { + await SwSubscriptions.delete(ps.all ? { + endpoint: ps.endpoint, + } : { + userId: user.id, + endpoint: ps.endpoint, + }); +});