mizzkey/src/server/api/endpoints/sw/unregister.ts
2021-07-27 02:35:19 +09:00

37 lines
818 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,
});
});