diff --git a/src/Commands/AdminCommands/CleanupCommand.php b/src/Commands/AdminCommands/CleanupCommand.php index 221ed932..00b13ea7 100644 --- a/src/Commands/AdminCommands/CleanupCommand.php +++ b/src/Commands/AdminCommands/CleanupCommand.php @@ -69,7 +69,7 @@ class CleanupCommand extends AdminCommand * * @var array */ - protected static $default_tables_to_clean = [ + protected static array $default_tables_to_clean = [ 'callback_query', 'chosen_inline_result', 'conversation', @@ -85,7 +85,7 @@ class CleanupCommand extends AdminCommand * * @var array */ - protected static $default_clean_older_than = [ + protected static array $default_clean_older_than = [ 'callback_query' => '30 days', 'chat' => '365 days', 'chosen_inline_result' => '30 days', @@ -108,7 +108,7 @@ class CleanupCommand extends AdminCommand * * @return array */ - private function getSettings($custom_time = ''): array + private function getSettings(string $custom_time = ''): array { $tables_to_clean = self::$default_tables_to_clean; $user_tables_to_clean = $this->getConfig('tables_to_clean'); @@ -179,6 +179,14 @@ private function getQueries($settings): array WHERE `date` < \'%2$s\' ) ) + OR ( + `channel_post_id` IS NOT NULL + AND `channel_post_id` IN ( + SELECT `id` + FROM `%5$s` + WHERE `date` < \'%2$s\' + ) + ) OR ( `edited_message_id` IS NOT NULL AND `edited_message_id` IN ( @@ -187,6 +195,14 @@ private function getQueries($settings): array WHERE `edit_date` < \'%2$s\' ) ) + OR ( + `edited_channel_post_id` IS NOT NULL + AND `edited_channel_post_id` IN ( + SELECT `id` + FROM `%6$s` + WHERE `edit_date` < \'%2$s\' + ) + ) OR ( `inline_query_id` IS NOT NULL AND `inline_query_id` IN ( @@ -369,7 +385,7 @@ public function execute(): ServerResponse $text = $message->getText(true); // Dry run? - $dry_run = strpos($text, 'dry') !== false; + $dry_run = str_contains($text, 'dry'); $text = trim(str_replace('dry', '', $text)); $settings = $this->getSettings($text); diff --git a/src/DB.php b/src/DB.php index dd10b870..ddb0581f 100644 --- a/src/DB.php +++ b/src/DB.php @@ -1293,8 +1293,8 @@ public static function insertMessageRequest(Message $message): bool } 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(); + self::insertChat($forward_origin->getSenderChat()); + $forward_from_chat = $forward_origin->getSenderChat()->getId(); $forward_signature = $forward_origin->getAuthorSignature(); } elseif ($forward_origin instanceof MessageOriginChannel) { self::insertChat($forward_origin->getChat()); diff --git a/src/Entities/MessageOrigin/MessageOriginChat.php b/src/Entities/MessageOrigin/MessageOriginChat.php index a0c2b398..21d17083 100644 --- a/src/Entities/MessageOrigin/MessageOriginChat.php +++ b/src/Entities/MessageOrigin/MessageOriginChat.php @@ -12,7 +12,7 @@ * * @method string getType() Type of the message origin, always “chat” * @method int getDate() Date the message was sent originally in Unix time - * @method Chat getChat() Chat that sent the message originally + * @method Chat getSenderChat() Chat that sent the message originally * @method string getAuthorSignature() Optional. For messages originally sent by an anonymous chat administrator, original message author signature */ class MessageOriginChat extends Entity implements MessageOrigin