View user's sent messages

We are running the MM Team Edition v5.25.1 and just had a requirement to review one of the employee’s sent messages.

Is there a way to do that either through the interface, CLI, or database queries?

Hi NorthGuard and welcome to the Mattermost forums!

There are several ways to do that.

Option A)
Reset the password for this account and login to it, if necessary, also reset the MFA. All of that can be done directly via system console, in the database or via mmctl.

Option B)
Pull the data out of the database, a query like this can be a good starting point to show the most recent 100 messages of the user named ‘bob’ (PostgreSQL syntax):

select CONCAT(c.name, ' (', c.displayname, ')'),p.message from posts as p, users as u, channels as c where p.channelid=c.id AND p.userid=u.id AND p.userid= (SELECT id FROM users WHERE username='bob') ORDER BY p.createat DESC limit 100;

The direct message channels will have no displayname, so this would need to be resolved too then by a bit more sophisticated query, but you can always modify it to suite your needs.

Let me know if one of these solutions would work for you and we can go deeper then if you require additional assistance.

Disclaimer:
You should not do that without the users permission, of course, and make sure to comply with your local dataprotection rules and all other regulations that might apply to situations like these.

Best,
Alex