From 7d750d23c22fc5fd7163377c3b0e509d95ee16c6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 21 Nov 2017 07:19:02 +0900 Subject: [PATCH] Fix bug --- src/api/common/push-sw.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/common/push-sw.ts b/src/api/common/push-sw.ts index 927dc5063..782a4a6a6 100644 --- a/src/api/common/push-sw.ts +++ b/src/api/common/push-sw.ts @@ -3,9 +3,13 @@ import * as mongo from 'mongodb'; import Subscription from '../models/sw-subscription'; import config from '../../conf'; -push.setGCMAPIKey(config.sw.gcm_api_key); +if (config.sw) { + push.setGCMAPIKey(config.sw.gcm_api_key); +} export default async function(userId: mongo.ObjectID | string, type, body?) { + if (!config.sw) return; + if (typeof userId === 'string') { userId = new mongo.ObjectID(userId); }