From b1123433d035247aa4d1f551add22dd1862abae7 Mon Sep 17 00:00:00 2001 From: Mark Hahnenberg Date: Thu, 13 Apr 2017 16:06:48 -0700 Subject: [PATCH] [client-sync] Fix contact ranking error Summary: This was showing up in Sentry. Check to see if the recipient has an email before calling toLowerCase. Test Plan: yolo Reviewers: halla, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D4423 --- packages/client-sync/src/local-api/routes/contacts.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/client-sync/src/local-api/routes/contacts.js b/packages/client-sync/src/local-api/routes/contacts.js index 45c861ceb..cc6d2f995 100644 --- a/packages/client-sync/src/local-api/routes/contacts.js +++ b/packages/client-sync/src/local-api/routes/contacts.js @@ -16,6 +16,9 @@ const calculateContactScores = (messages, result) => { for (const message of messages) { const weight = getMessageWeight(message, now); for (const recipient of message.getRecipients()) { + if (!recipient.email) { + continue; + } const email = recipient.email.toLowerCase(); result[email] = result[email] ? (result[email] + weight) : weight; }