@@ -720,7 +720,9 @@ public static function insertMessageRequest(Message $message)
720
720
self ::insertChat ($ chat , $ date , $ migrate_to_chat_id );
721
721
722
722
//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
+ }
724
726
725
727
//Insert the forwarded message user in users table
726
728
if ($ forward_from instanceof User) {
@@ -769,7 +771,12 @@ public static function insertMessageRequest(Message $message)
769
771
' );
770
772
771
773
$ 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
+ }
773
780
774
781
$ reply_to_message = $ message ->getReplyToMessage ();
775
782
$ reply_to_message_id = null ;
@@ -871,7 +878,9 @@ public static function insertEditedMessageRequest(Message $edited_message)
871
878
self ::insertChat ($ chat , $ edit_date );
872
879
873
880
//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
+ }
875
884
876
885
try {
877
886
$ sth = self ::$ pdo ->prepare ('
@@ -882,7 +891,12 @@ public static function insertEditedMessageRequest(Message $edited_message)
882
891
' );
883
892
884
893
$ 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
+ }
886
900
887
901
$ text = $ edited_message ->getText ();
888
902
$ caption = $ edited_message ->getCaption ();
0 commit comments