Unverified Commit 6837bb92 authored by Armando Lüscher's avatar Armando Lüscher Committed by GitHub

Merge branch 'develop' into 920-new_system_commands

parents 268d3bab 663acfcf
......@@ -12,6 +12,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
- Most built-in System Commands will be handled by GenericmessageCommand by default in a future release and will require a custom implementation.
### Removed
### Fixed
- Constraint errors in `/cleanup` command.
### Security
## [0.55.1] - 2019-01-06
......
......@@ -164,6 +164,7 @@ class CleanupCommand extends AdminCommand
SELECT `id`
FROM `%4$s`
WHERE `chat_id` = `%4$s`.`id`
AND `updated_at` < \'%1$s\'
)
AND (
`message_id` IS NOT NULL
......@@ -301,6 +302,11 @@ class CleanupCommand extends AdminCommand
if (in_array('message', $tables_to_clean, true)) {
$queries[] = sprintf(
'DELETE FROM `%1$s`
WHERE id IN (
SELECT id
FROM (
SELECT id
FROM `message`
WHERE `date` < \'%2$s\'
AND `id` NOT IN (
SELECT `message_id`
......@@ -312,9 +318,22 @@ class CleanupCommand extends AdminCommand
FROM `%4$s`
WHERE `message_id` = `%1$s`.`id`
)
AND `id` NOT IN (
SELECT `message_id`
FROM `%5$s`
WHERE `message_id` = `%1$s`.`id`
)
AND `id` NOT IN (
SELECT a.`reply_to_message` FROM `%1$s` a
INNER JOIN `%1$s` b ON b.`id` = a.`reply_to_message` AND b.`chat_id` = a.`reply_to_chat`
)
ORDER BY `id` DESC
) a
)
',
TB_MESSAGE,
$clean_older_than['message'],
TB_EDITED_MESSAGE,
TB_TELEGRAM_UPDATE,
TB_CALLBACK_QUERY
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment