diff --git a/src/app.ts b/src/app.ts index 9d1c813..da77372 100644 --- a/src/app.ts +++ b/src/app.ts @@ -4,7 +4,6 @@ import admin from 'firebase-admin'; import Express from 'express'; import { buildSchema } from 'type-graphql'; - import { ApolloServer } from 'apollo-server-express'; import ArticleResolver from './resolvers/ArticleResolver'; import ArticleRepo from './repos/ArticleRepo'; diff --git a/src/repos/NotificationRepo.ts b/src/repos/NotificationRepo.ts index 6aa92d1..d595fc6 100644 --- a/src/repos/NotificationRepo.ts +++ b/src/repos/NotificationRepo.ts @@ -59,15 +59,17 @@ const sendNotif = async ( }; // Send notification to FCM servers - admin - .messaging() - .sendToDevice(deviceToken, message, options) - .then((response) => { - console.log(response); - }) - .catch((error) => { - console.log(error); - }); + if (deviceToken !== '') { + admin + .messaging() + .sendToDevice(deviceToken, message, options) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.log(error); + }); + } }; const sendNewArticleNotification = async ( diff --git a/src/repos/UserRepo.ts b/src/repos/UserRepo.ts index 467602e..f687ede 100644 --- a/src/repos/UserRepo.ts +++ b/src/repos/UserRepo.ts @@ -131,9 +131,9 @@ const appendReadArticle = async (uuid: string, articleID: string): Promise const article = await ArticleRepo.getArticleByID(articleID); const checkDuplicates = (prev: boolean, cur: Article) => prev || cur.id === articleID; - if (article && !user.readArticles.reduce(checkDuplicates, false)) { - user.readArticles.push(article); - } + if (article && !user.readArticles.reduce(checkDuplicates, false)) { + user.readArticles.push(article); + } user.save(); }