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

PHPDoc comment in MessageOriginChat mislead to wrong getter getChat(). #1472

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
24 changes: 20 additions & 4 deletions src/Commands/AdminCommands/CleanupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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');
Expand Down Expand Up @@ -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 (
Expand All @@ -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 (
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/MessageOrigin/MessageOriginChat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading