Skip to content

Commit

Permalink
Magic payload for facebook
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Sep 5, 2024
1 parent a58ffc7 commit 99895a3
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions lhc_web/lib/core/lhchat/lhchatwebhookincomming.php
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,13 @@ public static function processMessage($incomingWebhook, $payloadMessage, $payloa
// Send default message for unknown button click
$bot = erLhcoreClassModelGenericBotBot::fetch($chat->gbot_id);

$trigger = erLhcoreClassModelGenericBotTrigger::findOne(array('filterin' => array('bot_id' => $bot->getBotIds()), 'filter' => array('default_unknown_btn' => 1)));
if ($buttonPayload == 'GET_STARTED') {
$filterButtonEvent = array('default' => 1);
} else {
$filterButtonEvent = array('default_unknown_btn' => 1);
}

$trigger = erLhcoreClassModelGenericBotTrigger::findOne(array('filterin' => array('bot_id' => $bot->getBotIds()), 'filter' => $filterButtonEvent));

if ($trigger instanceof erLhcoreClassModelGenericBotTrigger) {
erLhcoreClassGenericBotWorkflow::processTrigger($chat, $trigger, true, array('args' => array('msg_text' => $buttonPayload)));
Expand Down Expand Up @@ -1871,7 +1877,15 @@ public static function processMessage($incomingWebhook, $payloadMessage, $payloa
if ($messageData['found'] == true && $messageData['value'] != '') {
$buttonPayload = $messageData['value'];
$payloadParts = explode('__',$buttonPayload);
$ignore_default = is_object(erLhcoreClassModelmsg::fetch($payloadParts[3]));
$ignore_default = isset($payloadParts[3]) && is_object(erLhcoreClassModelmsg::fetch($payloadParts[3]));
if ($buttonPayload == 'GET_STARTED') {
$msgNotice = new erLhcoreClassModelmsg();
$msgNotice->msg = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat','Chat started by') . ' "' . 'GET_STARTED' . '" ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat','payload!');
$msgNotice->chat_id = $chat->id;
$msgNotice->user_id = -1;
$msgNotice->time = time();
$msgNotice->saveThis();
}
}
}

Expand Down Expand Up @@ -1930,7 +1944,13 @@ public static function processMessage($incomingWebhook, $payloadMessage, $payloa
// Send default message for unknown button click
$bot = erLhcoreClassModelGenericBotBot::fetch($chat->gbot_id);

$trigger = erLhcoreClassModelGenericBotTrigger::findOne(array('filterin' => array('bot_id' => $bot->getBotIds()), 'filter' => array('default_unknown_btn' => 1)));
if ($buttonPayload == 'GET_STARTED') {
$filterButtonEvent = array('default' => 1);
} else {
$filterButtonEvent = array('default_unknown_btn' => 1);
}

$trigger = erLhcoreClassModelGenericBotTrigger::findOne(array('filterin' => array('bot_id' => $bot->getBotIds()), 'filter' => $filterButtonEvent));

if ($trigger instanceof erLhcoreClassModelGenericBotTrigger) {
erLhcoreClassGenericBotWorkflow::processTrigger($chat, $trigger, true, array('args' => array('msg_text' => $buttonPayload)));
Expand Down

0 comments on commit 99895a3

Please sign in to comment.