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 @@ -12,6 +12,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
12
12
- Most built-in System Commands will be handled by GenericmessageCommand by default in a future release and will require a custom implementation.
13
13
### Removed
14
14
### Fixed
15
+ - Constraint errors in ` /cleanup ` command.
15
16
### Security
16
17
17
18
## [ 0.55.1] - 2019-01-06
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ private function getQueries($settings)
164
164
SELECT `id`
165
165
FROM `%4$s`
166
166
WHERE `chat_id` = `%4$s`.`id`
167
+ AND `updated_at` < \'%1$s \'
167
168
)
168
169
AND (
169
170
`message_id` IS NOT NULL
@@ -301,20 +302,38 @@ private function getQueries($settings)
301
302
if (in_array ('message ' , $ tables_to_clean , true )) {
302
303
$ queries [] = sprintf (
303
304
'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
+ )
315
333
' ,
316
334
TB_MESSAGE ,
317
335
$ clean_older_than ['message ' ],
336
+ TB_EDITED_MESSAGE ,
318
337
TB_TELEGRAM_UPDATE ,
319
338
TB_CALLBACK_QUERY
320
339
);
You can’t perform that action at this time.
0 commit comments