mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-01 03:41:59 +01:00
This commit is contained in:
parent
bffb9a5c45
commit
4c6fb60dd2
1 changed files with 10 additions and 3 deletions
|
@ -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
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue