Compare commits

...

2 Commits

Author SHA1 Message Date
osaajani eef74f1e9c version 2021-04-27 00:23:54 +02:00
osaajani b833d76380 update reception code to split sms every 1000 chars 2021-04-27 00:23:40 +02:00
2 changed files with 28 additions and 23 deletions

View File

@ -1 +1 @@
v3.1.1 v3.1.2

View File

@ -306,32 +306,37 @@ namespace controllers\internals;
} }
} }
$received_id = $this->create($id_user, $id_phone, $at, $text, $origin, $status, $is_command, $mms, $media_ids); //Cut received messages by 1000 chars max
if (!$received_id) $text_parts = mb_str_split($text, 1000);
foreach ($text_parts as $text)
{ {
$return['error'] = true; $received_id = $this->create($id_user, $id_phone, $at, $text, $origin, $status, $is_command, $mms, $media_ids);
$return['error_message'] = 'Impossible to insert the sms in database.'; if (!$received_id)
{
$return['error'] = true;
$return['error_message'] = 'Impossible to insert the sms in database.';
return $return; return $return;
}
$received = [
'id' => $received_id,
'at' => $at,
'text' => $text,
'destination' => $id_phone,
'origin' => $origin,
'command' => $is_command,
'mms' => $mms,
'medias' => $internal_media->gets_in_for_user($id_user, $media_ids),
];
$internal_webhook = new Webhook($this->bdd);
$internal_webhook->trigger($id_user, \models\Webhook::TYPE_RECEIVE_SMS, $received);
$internal_user = new User($this->bdd);
$internal_user->transfer_received($id_user, $received);
} }
$received = [
'id' => $received_id,
'at' => $at,
'text' => $text,
'destination' => $id_phone,
'origin' => $origin,
'command' => $is_command,
'mms' => $mms,
'medias' => $internal_media->gets_in_for_user($id_user, $media_ids),
];
$internal_webhook = new Webhook($this->bdd);
$internal_webhook->trigger($id_user, \models\Webhook::TYPE_RECEIVE_SMS, $received);
$internal_user = new User($this->bdd);
$internal_user->transfer_received($id_user, $received);
return $return; return $return;
} }