From 83f44cb149c1e640d3e6bceea989ffebb875fb7e Mon Sep 17 00:00:00 2001 From: Dana Date: Tue, 12 Apr 2016 13:59:22 +0000 Subject: [PATCH] Soft block throwaway emails on signup --- node_modules/c9/skip-analytics.js | 9 ++++----- node_modules/c9/skip-analytics_test.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/node_modules/c9/skip-analytics.js b/node_modules/c9/skip-analytics.js index 30be5d51..10aadae7 100644 --- a/node_modules/c9/skip-analytics.js +++ b/node_modules/c9/skip-analytics.js @@ -10,17 +10,16 @@ define(function(require, exports, module) { var hasInternalDomain = require("c9/has-internal-domain"); var hasInternalTestName = require("c9/has-internal-test-name"); - function skipAnalytics(userId, name, email, allowUnauthorized) { - + function skipAnalytics(userId, name, email, blocked, allowUnauthorized) { if (!userId) return true; // users without an id should never reach the Segment library if (typeof userId == "object") { var user = userId; - return skipAnalytics(user.id, user.name || user.username, user.email, name); // make it backwards compatible for the client + return skipAnalytics(user.id, user.name || user.username, user.email, user.blocked, name); // make it backwards compatible for the client } - if (!allowUnauthorized && userId === -1) return true; - + + if (blocked) return true; if (hasInternalTestName(name)) return true; if (hasInternalDomain(email)) return true; return false; diff --git a/node_modules/c9/skip-analytics_test.js b/node_modules/c9/skip-analytics_test.js index 70c6a55a..b732a771 100644 --- a/node_modules/c9/skip-analytics_test.js +++ b/node_modules/c9/skip-analytics_test.js @@ -68,6 +68,16 @@ describe("skip-analytics", function() { user.email = "test@cloud9beta.com"; assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user has internal beta email"); }); + + it("returns true when user is marked as blocked", function() { + var user = { + id: faker.random.uuid(), + email: faker.internet.email(), + blocked: "soft ban foo" + }; + + assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user is marked as blocked"); + }); it("returns false when user is authorized and does not have intermal email", function() { var user = {