XF 1.5 Bulk delete private conversations

Wildcat Media

Well-known member
Had a spamming incident. I need to delete the spam without killing a member's complete backlog of private conversations.

I'm thinking this:

Use the following query to get a list of all the appropriate messages:
SELECT cmaster.conversation_id FROM xf_conversation_master AS cmaster WHERE user_id = 5555 AND title = 'Spam!');

Then, that query is used to populate a list of conversation IDs to delete, as follows.

SQL:
DELETE FROM xf_conversation_user AS cuser
WHERE cuser.conversation_id IN
(SELECT cmaster.conversation_id FROM xf_conversation_master AS cmaster WHERE user_id = 5555 AND title = 'Unique Spam!');

DELETE FROM xf_conversation_recipient AS crecip
WHERE crecip.conversation_id IN
(SELECT cmaster.conversation_id FROM xf_conversation_master AS cmaster WHERE user_id = 5555 AND title = 'Unique Spam!');

DELETE FROM xf_conversation_message AS cmess
WHERE cmess.conversation_id IN
(SELECT cmaster.conversation_id FROM xf_conversation_master AS cmaster WHERE user_id = 5555 AND title = 'Unique Spam!');

Then, the following wipes it from the master conversation table:

SQL:
DELETE FROM xf_conversation_master WHERE user_id = 5555 AND title = 'Unique Spam!';

Final steps--rebuild conversations, then rebuild search index (conversations only--we have an add-on which indexes them).

Any idea why this wouldn't work? I've tested all the queries as SELECT statements and they all work as expected. But I don't know if anything else in the forum needs to be tended to.
 
Last edited:
Back
Top Bottom