File tree Expand file tree Collapse file tree 1 file changed +26
-11
lines changed
src/Commands/AdminCommands Expand file tree Collapse file tree 1 file changed +26
-11
lines changed 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,17 +302,31 @@ 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+ (
307+ SELECT id
308+ FROM
309+ (
310+ SELECT id
311+ FROM `message`
312+ WHERE `date` < \'%2$s \'
313+ AND `id` NOT IN (
314+ SELECT `message_id`
315+ FROM `%3$s`
316+ WHERE `message_id` = `%1$s`.`id`
317+ )
318+ AND `id` NOT IN (
319+ SELECT `message_id`
320+ FROM `%4$s`
321+ WHERE `message_id` = `%1$s`.`id`
322+ )
323+ AND `id` NOT IN (
324+ SELECT a.`reply_to_message` FROM `%1$s` a
325+ INNER JOIN `%1$s` b ON b.`id` = a.`reply_to_message` AND b.`chat_id` = a.`reply_to_chat`
326+ )
327+ ORDER BY `id` DESC
328+ ) a
329+ )
315330 ' ,
316331 TB_MESSAGE ,
317332 $ clean_older_than ['message ' ],
You can’t perform that action at this time.
0 commit comments