Skip to content

Commit

Permalink
fix an issue where $client is null on some pages
Browse files Browse the repository at this point in the history
  • Loading branch information
WevrLabs committed Aug 21, 2021
1 parent 8f413ab commit a2bc3c3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions chatwoot/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,25 @@ function hook_chatwoot_output($vars)
$user_browser = getBrowser();

# Fetch labels
if (!is_null($client)) {
if (!is_null($user)) {
$chatwoot_label = $chatwoot_setlabelloggedin;
}

# Get client ID and set chat ID
if ($user && $user->isOwner(CurrentUser::client())) {
# Get client ID and set contact ID
if ($user && $client && $user->isOwner(CurrentUser::client())) {
$ClientID = $client->id; //$vars['clientsdetails']['id'];
} elseif ($user) {
$ownedClients = $user->ownedClients()->all();
$ClientID = $ownedClients[0]['id'];
}

if (!is_null($client)) {
if (!is_null($user)) {
$ClientChatID = hash_hmac("sha256", $ClientID, $signing_hash);
$identifier_hash = hash_hmac("sha256", $ClientChatID, $verification_hash);
}

# getting Client Info
if (!is_null($client)) {
# build contact info
if (!is_null($user)) {

$apiPostData = array('clientid' => $ClientID, 'stats' => true);
$apiResults = localAPI('GetClientsDetails', $apiPostData);
Expand Down Expand Up @@ -142,7 +142,7 @@ function hook_chatwoot_output($vars)

# Now let's prepare our code for final output

if (!is_null($client)) {
if (!is_null($user)) {

$chatwoot_output =
"$chatwoot_jscode
Expand Down

0 comments on commit a2bc3c3

Please sign in to comment.