diff --git a/packages/api/src/utils/sendNotification.ts b/packages/api/src/utils/sendNotification.ts index edbd86365..0421b5688 100644 --- a/packages/api/src/utils/sendNotification.ts +++ b/packages/api/src/utils/sendNotification.ts @@ -1,4 +1,4 @@ -import { initializeApp } from 'firebase-admin/app' +import { applicationDefault, initializeApp } from 'firebase-admin/app' import { BatchResponse, getMessaging, @@ -11,7 +11,9 @@ import { analytics } from './analytics' export type PushNotificationType = 'newsletter' | 'reminder' | 'rule' // getting credentials from App Engine -initializeApp() +initializeApp({ + credential: applicationDefault(), +}) export const sendPushNotification = async ( userId: string, diff --git a/packages/rule-handler/src/index.ts b/packages/rule-handler/src/index.ts index 16e800d2f..bdfffe4ae 100644 --- a/packages/rule-handler/src/index.ts +++ b/packages/rule-handler/src/index.ts @@ -107,6 +107,11 @@ export const ruleHandler = Sentry.GCPFunction.wrapHttpFunction( // get rules by calling api const rules = await getEnabledRules(userId, apiEndpoint, jwtSecret) + if (!rules || rules.length === 0) { + console.log('No rules found') + res.status(200).send('No Rules') + return + } await triggerActions(userId, rules, data, apiEndpoint, jwtSecret)