Skip to content

Commit

Permalink
Updating domain check
Browse files Browse the repository at this point in the history
  • Loading branch information
willdoran committed Jun 24, 2017
1 parent 77f74e4 commit b1749bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function handle(EventInterface $event, $user = null)
"id" => $domain
];

if ($intercomAppToken) {
if ($intercomAppToken && empty($domain)) {

$client = new IntercomClient($intercomAppToken, null);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@ class Ushahidi_Listener_IntercomCompanyListener extends AbstractListener
public function handle(EventInterface $event, $data = null)
{
$intercomAppToken = getenv('INTERCOM_APP_TOKEN');
if ($intercomAppToken) {
$domain = service('site');

if ($intercomAppToken && empty($domain)) {

try {
$client = new IntercomClient($intercomAppToken, null);
$domain = service('site') ? service('site') : $_SERVER['HOST'];


$company = [
"company_id" => $domain,
"custom_attributes" => $data
];
// Update company
$client->companies->create($company);

$thing = $client->companies->create($company);
} catch(ClientException $e) {
Kohana::$log->add(Log::ERROR, print_r($e,true));
}
Expand Down

0 comments on commit b1749bc

Please sign in to comment.