Find users with no posts

Hi,
is there a way, for cleaning proposals ad admin, to find users which have not written posts?
We have a lot of deactivated users and we would like to find a way to at least delete the ones which have not written posts…
Thanks,
Marco

Hi Marco,
unfortunately the only way would be to use database queries but it’s discouraged to alter the tables manually due to possible breakage.

Best regards,
Marco

Hi Marco,
could you suggest me the way to the database tables?
I am not trying to delete or update rows, I’m only looking to retrieve which users have not written posts in order to delete them by cli.
Thanks again.
Marco

Hey, sorry for the late response. You need to search through the posts table for posts from users who joined a team and channel. While joining Mattermost you probably join a team and a channel and this will send a post for both interactions e.g. “…joined the channel” by the corresponding user. A user who just logged in without any further postings will only have this (two) posts in the table. For users who logged in but didn’t join a team (and therefore no channel) only the user will be present but no posts in the table. As you can see this is a bit more complex than just a short query unfortunately. I can’t provide a complete query but hopefully this will help a bit.

Best regards,
Marco

Hi, @mbarbaro I would recommend querying the database user tables, and then retrieving the user ID’s of all current users and store them in a text (txt) file. Upon doing that, if you were to export the column in the Posts table that contains the user ID’s of the member who created each post, and then grep the contents for all not found ID’s, then you would be returned with a list of the ID’s of the users who have not made any posts in your server, which can then be used to delete the users.