File tree Expand file tree Collapse file tree 2 files changed +31
-11
lines changed
src/Commands/AdminCommands Expand file tree Collapse file tree 2 files changed +31
-11
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
1010- Botan.io service has been discontinued.
1111### Removed
1212### Fixed
13+ - Constraint errors in ` /cleanup ` command.
1314### Security
1415
1516## [ 0.55.1] - 2019-01-06
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ private function getQueries($settings)
164164 SELECT `id`
165165 FROM `%4$s`
166166 WHERE `chat_id` = `%4$s`.`id`
167+ AND `updated_at` < \'%1$s \'
167168 )
168169 AND (
169170 `message_id` IS NOT NULL
@@ -301,20 +302,38 @@ private function getQueries($settings)
301302 if (in_array ('message ' , $ tables_to_clean , true )) {
302303 $ queries [] = sprintf (
303304 'DELETE FROM `%1$s`
304- WHERE `date` < \'%2$s \'
305- AND `id` NOT IN (
306- SELECT `message_id`
307- FROM `%3$s`
308- WHERE `message_id` = `%1$s`.`id`
309- )
310- AND `id` NOT IN (
311- SELECT `message_id`
312- FROM `%4$s`
313- WHERE `message_id` = `%1$s`.`id`
314- )
305+ WHERE id IN (
306+ SELECT id
307+ FROM (
308+ SELECT id
309+ FROM `message`
310+ WHERE `date` < \'%2$s \'
311+ AND `id` NOT IN (
312+ SELECT `message_id`
313+ FROM `%3$s`
314+ WHERE `message_id` = `%1$s`.`id`
315+ )
316+ AND `id` NOT IN (
317+ SELECT `message_id`
318+ FROM `%4$s`
319+ WHERE `message_id` = `%1$s`.`id`
320+ )
321+ AND `id` NOT IN (
322+ SELECT `message_id`
323+ FROM `%5$s`
324+ WHERE `message_id` = `%1$s`.`id`
325+ )
326+ AND `id` NOT IN (
327+ SELECT a.`reply_to_message` FROM `%1$s` a
328+ INNER JOIN `%1$s` b ON b.`id` = a.`reply_to_message` AND b.`chat_id` = a.`reply_to_chat`
329+ )
330+ ORDER BY `id` DESC
331+ ) a
332+ )
315333 ' ,
316334 TB_MESSAGE ,
317335 $ clean_older_than ['message ' ],
336+ TB_EDITED_MESSAGE ,
318337 TB_TELEGRAM_UPDATE ,
319338 TB_CALLBACK_QUERY
320339 );
You can’t perform that action at this time.
0 commit comments