diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-09-01 08:13:18 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-09-01 08:13:18 +0900 |
| commit | 4c6fb60dd25d7e2865fc7c4d97728593ffc3c902 (patch) | |
| tree | 690c90e07cd97ec22ac89759bfe203232a0c1e54 /src/server | |
| parent | #2447 #1958 (diff) | |
| download | sharkey-4c6fb60dd25d7e2865fc7c4d97728593ffc3c902.tar.gz sharkey-4c6fb60dd25d7e2865fc7c4d97728593ffc3c902.tar.bz2 sharkey-4c6fb60dd25d7e2865fc7c4d97728593ffc3c902.zip | |
#2541
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/api/endpoints/sw/register.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/server/api/endpoints/sw/register.ts b/src/server/api/endpoints/sw/register.ts index 3414600048..503fc94654 100644 --- a/src/server/api/endpoints/sw/register.ts +++ b/src/server/api/endpoints/sw/register.ts @@ -1,6 +1,7 @@ import $ from 'cafy'; import Subscription from '../../../../models/sw-subscription'; import { ILocalUser } from '../../../../models/user'; +import config from '../../../../config'; export const meta = { requireCredential: true @@ -31,8 +32,11 @@ export default async (params: any, user: ILocalUser) => new Promise(async (res, deletedAt: { $exists: false } }); - if (exist !== null) { - return res(); + if (exist != null) { + return res({ + state: 'already-subscribed', + key: config.sw.public_key + }); } await Subscription.insert({ @@ -42,5 +46,8 @@ export default async (params: any, user: ILocalUser) => new Promise(async (res, publickey: publickey }); - res(); + res({ + state: 'subscribed', + key: config.sw.public_key + }); }); |