Delete messages from a channel to clean it
Hello,
in the case a channel is used to receive notifications in a defined interval, messages are bound to multiply and to be too numerous.
So i think it should be interesting to delete the messages from a channel by the creator of this channel or by a webhook.
-
showersd commented
To delete posts in a channel older than XX days I did this because the timestamps are in milliseconds:
delete from Posts where ChannelId='laskjdflasjkfas78f7asf73uh' AND CreateAt < (1000 * UNIX_TIMESTAMP(DATE_SUB(NOW(),INTERVAL 30 DAY))) ;
-
Kulis commented
The channel id can be fetched using the "About" entry in the dropdown menu.
At the SQL query level, list the posts posted by a given incoming webhook
(psql) # \x on
# SELECT p.*
FROM Posts p
JOIN Channels c ON p.channelid=c.id
JOIN Teams t ON p.teamid=t.id
WHERE t.displayname='teamname_at_topleft'
AND c.displayname='channelname_at_topmiddle'
AND props LIKE '%"from_webhook":"true"%'
AND props LIKE '%"override_username":"lowercasehookname"%';After checking what it yielded, you can use that as a subquery:
DELETE FROM Posts WHERE id IN (SELECT p.id FROM .....)
you may tweak the query if you want to target a given userid.
It doesn't handle/fix posts whose parentid point to one of the deleted posts.and thread membership
-
Jurgen commented
An update:
mysql>
DELETE FROM mattermost.Posts WHERE Posts.ChannelId = 'nkx56xy6xpbrjx98p1ggpyug3o';
You should change the 'ChannelId' ofcouse.
-
The Torch commented
Hello, a simple SQL query can be used. However be careful it will delete all posts from specific channel
DELETE
FROM PUBLIC.POSTS
WHERE CHANNELID = '<enter channel id here>' -
Joaquim Homrighausen commented
Specially when a channel is used only for notifications from other places.
-
Anonymous commented
Clean Channel, yes. Good idea !
-
Arihant commented
A simple button for the admin of the channel to clean complete history of the channel would really be cool.