Make hubspot contact creation configurable

This commit is contained in:
Teemu Patja 2017-11-01 16:26:26 +02:00
parent c81ec65bc6
commit 69f2a7380c
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
1 changed files with 4 additions and 1 deletions

View File

@ -12,6 +12,8 @@
[clojure.string :as str])) [clojure.string :as str]))
(defn hubspot-contact-create-enabled []
(env :hubspot-contact-create-enabled false))
(defn- create-user [token user] (defn- create-user [token user]
(let [{name :name (let [{name :name
@ -47,7 +49,8 @@
new-user? (nil? (users/get-user (:id gh-user 0))) new-user? (nil? (users/get-user (:id gh-user 0)))
user (assoc (get-or-create-user access-token) user (assoc (get-or-create-user access-token)
token-key access-token)] token-key access-token)]
(when new-user? (when (and (hubspot-contact-create-enabled)
new-user?)
(try (try
(hubspot/create-hubspot-contact (:email user) (hubspot/create-hubspot-contact (:email user)
(:name user "") (:name user "")