Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastFix to Critical Error. #1467

Merged
merged 2 commits into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions src/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
use Longman\TelegramBot\Entities\ChosenInlineResult;
use Longman\TelegramBot\Entities\InlineQuery;
use Longman\TelegramBot\Entities\Message;
use Longman\TelegramBot\Entities\MessageOrigin\MessageOriginChannel;
use Longman\TelegramBot\Entities\MessageOrigin\MessageOriginChat;
use Longman\TelegramBot\Entities\MessageOrigin\MessageOriginHiddenUser;
use Longman\TelegramBot\Entities\MessageOrigin\MessageOriginUser;
use Longman\TelegramBot\Entities\MessageReactionCountUpdated;
use Longman\TelegramBot\Entities\MessageReactionUpdated;
use Longman\TelegramBot\Entities\Payments\PreCheckoutQuery;
Expand Down Expand Up @@ -1273,15 +1277,31 @@ public static function insertMessageRequest(Message $message): bool
}

// Insert the forwarded message user in users table
$forward_date = $message->getForwardDate() ? self::getTimestamp($message->getForwardDate()) : null;

if ($forward_from = $message->getForwardFrom()) {
self::insertUser($forward_from);
$forward_from = $forward_from->getId();
}
if ($forward_from_chat = $message->getForwardFromChat()) {
self::insertChat($forward_from_chat);
$forward_from_chat = $forward_from_chat->getId();
$forward_from = null;
$forward_from_chat = null;
$forward_from_message_id = null;
$forward_signature = null;
$forward_sender_name = null;
$forward_date = null;

if ($forward_origin = $message->getForwardOrigin()) {
$forward_date = self::getTimestamp($forward_origin->getDate());

if ($forward_origin instanceof MessageOriginUser) {
self::insertUser($forward_origin->getSenderUser());
$forward_from = $forward_origin->getSenderUser()->getId();
} elseif ($forward_origin instanceof MessageOriginHiddenUser) {
$forward_sender_name = $forward_origin->getSenderUserName();
} elseif ($forward_origin instanceof MessageOriginChat) {
self::insertChat($forward_origin->getChat());
$forward_from_chat = $forward_origin->getChat()->getId();
$forward_signature = $forward_origin->getAuthorSignature();
} elseif ($forward_origin instanceof MessageOriginChannel) {
self::insertChat($forward_origin->getChat());
$forward_from_chat = $forward_origin->getChat()->getId();
$forward_from_message_id = $forward_origin->getMessageId();
$forward_signature = $forward_origin->getAuthorSignature();
}
}

$via_bot_id = null;
Expand Down Expand Up @@ -1359,9 +1379,9 @@ public static function insertMessageRequest(Message $message): bool
$sth->bindValue(':date', $date);
$sth->bindValue(':forward_from', $forward_from);
$sth->bindValue(':forward_from_chat', $forward_from_chat);
$sth->bindValue(':forward_from_message_id', $message->getForwardFromMessageId());
$sth->bindValue(':forward_signature', $message->getForwardSignature());
$sth->bindValue(':forward_sender_name', $message->getForwardSenderName());
$sth->bindValue(':forward_from_message_id', $forward_from_message_id);
$sth->bindValue(':forward_signature', $forward_signature);
$sth->bindValue(':forward_sender_name', $forward_sender_name);
$sth->bindValue(':forward_date', $forward_date);
$sth->bindValue(':is_topic_message', $message->getIsTopicMessage());

Expand Down
Loading