-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deleting Chat Room Logs +30 day crontab #7228
Comments
You could possibly use this api: https://rocket.chat/docs/developer-guides/rest-api/channels/cleanhistory |
@graywolf336 that was the API I was referencing in the post. However, what is not clear is on the parameters. For example, where do you get the |
@waveyuk Take a look at how to authenticate: https://rocket.chat/docs/developer-guides/rest-api/authentication |
@graywolf336 ok- seen that... unfortunately, I am not a whizz with linux and curl, so don't know how to build a script that could pass the authentication results into the command line to accomplish this. If anyone can help, would appreciate it. |
Here's a sample script to get you started. You probably want to iterate through ALL rooms, though, right? |
Hi @geesper |
powershell_remove_old_messages.txt We can definitely get a list of the public rooms and then go through them all, though. I could spend a few minutes and put this into powershell, if that makes more sense to you than a shell script. edit: I've added a powershell script that iterates through all channels and deletes messages older than X days. Please test this before using in production! |
Actually, looks like there may be a way to get a list of all direct messages? https://rocket.chat/docs/developer-guides/rest-api/im/list-everyone I'll take a closer look at that. |
@geesper I meant to respond earlier and say there was, but it is disabled by default due to security and privacy purposes. |
@geesper ... Thanks for the powershell script. I'll give that a go as soon as my internet connection returns to being stable (having issues with Virgin Media broadband at the moment). @graywolf336 is there any way to get around the disabled function to delete direct messages? Obviously as server admin I would like to keep my server as clean as possible and dispose of old, out of date direct messages that consume database space but are no longer being used. Thanks guys |
@geesper |
rocketchat_delete_old_messages.txt OK, here's an updated bash script that will iterate through all channels. Unfortunately, while the api allows you to grab a list of the direct message rooms, the api doesn't allow you to clean their history. The script should be easy to update later if/when that functionality is added. IMPORTANT NOTE: You will need to install jq on the linux machine you're running this from. This is used to parse the json response that the api gives back. Let me know if you run into any problems! Please be sure to run this on a test server before using it in production! |
@geesper if you really wanted to, you could get a list of the messages in a direct room and call |
Yeah, I don't really want to do that because of how inefficient it would be. We'd have to:
Considering there may be thousands or tens of thousands of messages, that could take a long long time. My hope is that the channels.cleanHistory allows DM's, or that maybe the ims api gets its own cleanHistory call. |
Closes #6749 Closes #8321 Closes #9374 Closes #2700 Closes #2639 Closes #2355 Closes #1861 Closes #8757 Closes #7228 Closes #10870 Closes #6193 Closes #11299 Closes #11468 Closes #9317 Closes #11300 (will incorporate a fix to this PR's issue) Closes #11046 (will incorporate a fix to this PR's issue) Contributes to #5944 Contributes to #11475 _...and possibly more!_ This PR makes deleting messages (automatically and manually) a lot easier on Rocket.Chat. - [X] Implement a bulk message deletion notification, to quickly push large message deletions to users without reload - [X] Use it in `rooms.cleanHistory` - [X] Use it in user deletions - [X] Completely remove cleanChannelHistory as required by v0.67 - [X] Remove server method `cleanChannelHistory` - [X] Remove REST API `channels.cleanHistory` - [x] Implement a sidebar option to clean history - [x] Basic implementation - [x] Allow excluding pinned messages - [x] Allow attachment-only mode - [x] Allow specifying user(s) to narrow down to - [x] Also update REST API - [x] Also update docs - [x] Break the deletion into multiple different requests, so the client can keep track of progress - [x] Clear animation / progress bar for deleting - [x] Retention policy - [X] Global, set by admin - [X] Global timer that runs every second and deletes messages over the set limit - [X] Can change its timer's resolution to prevent insane CPU overhead - [X] Admin can decide what room types to target (channels, groups and/or DMs) - [X] Allow excluding pinned messages - [X] Allow attachment-only mode - [x] Per-channel, set by those with a new permission - [x] Disabled when master switch off - [x] Set in channel info - [x] Can override global policy with a switch that requires `edit-privileged-setting` - [x] Allow excluding pinned messages - [x] Allow attachment-only mode - [x] Uses same global timer for cleanup - [X] Message at start of channel history / in channel info if there is a retention policy set - [x] Message in channel info if there is a retention policy set on that channel specifically - [X] Make cleaning history also delete files (completely!) - [X] Manual purging - [X] Automatic purging - [x] Make other deletions also delete files - [x] User deletion - [X] Own messages - [x] DMs with them's partner messages - [x] Room deletion - [x] Cleanup - [x] Finish related [docs](https://github.com/RocketChat/docs/pull/815) - [x] Link to the docs in the settings Please suggest any cool changes/additions! Any support is greatly appreciated. **Breaking change:** This PR removes REST API endpoint `channels.cleanHistory` and Meteor callable `cleanChannelHistory` as per the protocol specified for them. ![bzzzzzzzz](https://user-images.githubusercontent.com/39674991/41799087-56d1dea0-7670-11e8-94c0-bc534b1f832d.png)
Guys any news about this? |
I've looked to see if anyone has come up with a solution for this.
I would like to be able to run a crontab job which deletes any messages from any room which are older than 30 days. Is this at all possible? My concern is that the Mongo database will quickly fill with messages and cause the server to run out of disk space on active channels. I've seen posts about using the API but it isn't clearly explained how to achieve this. Our Rocket Chat is running in a Snap environment.
Thanks
Rocket.Chat Version: 0.56.0
Running Instances: 1
DB Replicaset OpLog: Enabled
Node Version: 4.8.1
The text was updated successfully, but these errors were encountered: