Skip to content

Commit

Permalink
Save message only if chat was not started
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed May 22, 2023
1 parent fefa0b3 commit 3a517b2
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bootstrap/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ public static function incommingChatStarted($params)
$params['chat']->dep_id = $messageBird->dep_id;
$params['chat']->updateThis(['update' => ['dep_id']]);

// Save template message first before saving initial response in the lhc core
$msg = new erLhcoreClassModelmsg();
$msg->msg = $messageBird->message;
$msg->chat_id = $params['chat']->id;
$msg->user_id = $messageBird->user_id;
$msg->time = $messageBird->created_at;
erLhcoreClassChat::getSession()->save($msg);
// Save template only if it was not assigned to any chat yet
if ($messageBird->chat_id == 0) {
// Save template message first before saving initial response in the lhc core
$msg = new erLhcoreClassModelmsg();
$msg->msg = $messageBird->message;
$msg->chat_id = $params['chat']->id;
$msg->user_id = $messageBird->user_id;
$msg->time = $messageBird->created_at;
erLhcoreClassChat::getSession()->save($msg);
}

// Update message bird
$messageBird->chat_id = $params['chat']->id;
Expand Down

0 comments on commit 3a517b2

Please sign in to comment.