Skip to content

Commit e101cdf

Browse files
authored
Merge pull request #333 from jacklul/fixes
Fixes for #331 and #332
2 parents 8745eec + 785b6b2 commit e101cdf

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/DB.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,9 @@ public static function insertMessageRequest(Message $message)
720720
self::insertChat($chat, $date, $migrate_to_chat_id);
721721

722722
//Insert user and the relation with the chat
723-
self::insertUser($from, $date, $chat);
723+
if (is_object($from)) {
724+
self::insertUser($from, $date, $chat);
725+
}
724726

725727
//Insert the forwarded message user in users table
726728
if ($forward_from instanceof User) {
@@ -769,7 +771,12 @@ public static function insertMessageRequest(Message $message)
769771
');
770772

771773
$message_id = $message->getMessageId();
772-
$from_id = $from->getId();
774+
775+
if (is_object($from)) {
776+
$from_id = $from->getId();
777+
} else {
778+
$from_id = null;
779+
}
773780

774781
$reply_to_message = $message->getReplyToMessage();
775782
$reply_to_message_id = null;
@@ -871,7 +878,9 @@ public static function insertEditedMessageRequest(Message $edited_message)
871878
self::insertChat($chat, $edit_date);
872879

873880
//Insert user and the relation with the chat
874-
self::insertUser($from, $edit_date, $chat);
881+
if (is_object($from)) {
882+
self::insertUser($from, $edit_date, $chat);
883+
}
875884

876885
try {
877886
$sth = self::$pdo->prepare('
@@ -882,7 +891,12 @@ public static function insertEditedMessageRequest(Message $edited_message)
882891
');
883892

884893
$message_id = $edited_message->getMessageId();
885-
$from_id = $from->getId();
894+
895+
if (is_object($from)) {
896+
$from_id = $from->getId();
897+
} else {
898+
$from_id = null;
899+
}
886900

887901
$text = $edited_message->getText();
888902
$caption = $edited_message->getCaption();

src/Entities/ServerResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ private function createResultObject($result, $bot_name)
101101
$result_object_types = [
102102
'total_count' => 'UserProfilePhotos', //Response from getUserProfilePhotos
103103
'file_id' => 'File', //Response from getFile
104+
'title' => 'Chat', //Response from getChat
104105
'username' => 'User', //Response from getMe
105-
'id' => 'Chat', //Response from getChat
106106
'user' => 'ChatMember', //Response from getChatMember
107107
'url' => 'WebhookInfo', //Response from getWebhookInfo
108108
];

0 commit comments

Comments
 (0)