Search and export messages

AI-generated summary

In a support discussion titled “Search and export messages,” MentalNomad asks whether self-hosted Discourse admins can assist law enforcement by exporting private messages between specific users, particularly when one user has left the conversation. Canapin clarifies that admins can view a user’s private messages via their profile, but if a user has left a conversation, those messages are no longer visible through the UI — requiring SQL queries via Data Explorer. MentalNomad confirms that reviewing all messages from one user won’t reveal which ones originally included the departed user, affirming the need for SQL. Canapin agrees and suggests searching for action_code = 'user_left' in the posts table to retrieve the relevant topic_id, noting that Data Explorer conveniently links to profiles and topics in results. A helpful reference is provided: Users removed themselves from Private Messages (PM) and then the mods can’t see their PM history - #10 by Canapin. The focus is on thorough, privacy-respecting search methods, with format being secondary.

If the owners/admins of a self-hosted Discourse are asked to cooperate with an investigation by LEOs and provide copies of personal messages between particular users, is there a guide anywhere on how to do this?

Also, if the private conversation is originally between users A and B, but user B decides not to be part of it and leaves the conversation, will the message(s) still be found in searches for messages where both A and B are participants? Is it possible to identify such messages without producing all messages from A?

Hello Mental Nomad,

In which format do you need to provide these copies? PDF? Screenshots? Other?

As an admin, you can check users’ personal messages by navigating to their profile and clicking :envelope: Messages. You’ll have access to the list of their personal discussions.

If they have been removed from personal discussions, you’ll probably need data explorer and a SQL query to find these topics. All messages will be preserved even if a user left.

Here’s a bit of additional information: Users removed themselves from Private Messages (PM) and then the mods can't see their PM history - #10 by Canapin

Format isn’t an issue. The focus is thorough search while respecting privacy.

Presumably this will work if we want to have someone review all of A’s messages, but it won’t necessarily be clear which messages originally included B, since B has left.

I think we’ll need to do some SQL work to identify the right sets of messages.

Useful; thanks.

I understand the issue and yes, some SQL work will do the job.
Looking for action_code = 'user_left' in the posts table contains the corresponding topic_id. Data explorer is convenient because it automatically creates links to profiles and topics or posts in the results: