From f81413713ef4969e8115fb073398e7731a3621f5 Mon Sep 17 00:00:00 2001
From: lukebarnard <luke.barnard99@gmail.com>
Date: Wed, 7 Feb 2018 17:53:10 +0000
Subject: [PATCH] Guard against no pushRules in getPushRuleById

so that clients that attempt to get push rules before they have
been fetched will receive `null` instead of an NPE.
---
 src/pushprocessor.js | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/pushprocessor.js b/src/pushprocessor.js
index 6ab7d1c87..ba8e90cc7 100644
--- a/src/pushprocessor.js
+++ b/src/pushprocessor.js
@@ -357,6 +357,7 @@ function PushProcessor(client) {
      * @return {object} The push rule, or null if no such rule was found
      */
     this.getPushRuleById = function(ruleId) {
+        if (!client.pushRules) return null;
         for (const scope of ['device', 'global']) {
             if (client.pushRules[scope] === undefined) continue;
 
-- 
GitLab