modmail-dev / Modmail

A Discord bot that functions as a shared inbox between staff and members, similar to Reddit's Modmail.
https://docs.modmail.dev
GNU Affero General Public License v3.0
1.58k stars 4.59k forks source link

Add config to manage how long logs are stored #3257

Closed ghost closed 11 months ago

ghost commented 1 year ago

Closes #2942

This pr adds a config option called log_expiration which can be configured in the same way as thread_cooldown etc. According to the closed_at field this config option will delete logs which have passed the time specified in log_expiration.

This will work retrospectively.

ghost commented 1 year ago

I have tested this extensively but it would be better if someone could review this to make sure its efficient. Also since setting the config option will immediately start deleting old logs not sure if we should have some kind of safeguard?

StephenDaDev commented 1 year ago

I think a safeguard is probably a good measure just to make sure nobody does anything they'd rather not do

ghost commented 1 year ago

I think a safeguard is probably a good measure just to make sure nobody does anything they'd rather not do

Actually if you look at it, the config option is set after the bot is running, they will need to restart the bot for it to come into effect. In this time they can remove the config option to prevent logs from being deleted. However vise versa if the logs are being deleted and they remove the config option, the deletion will stop without needing a restart.

Maybe this is enough?

StephenDaDev commented 1 year ago

@lorenzo132 What do you think?

lorenzo132 commented 1 year ago

@lorenzo132 What do you think?

I'm a fan of the logs expiration config, specialy on a company wise level this is a very nice feature to have.

ghost commented 1 year ago

Used delete_many instead of looping delete_one based on recommendation by @khakers

ghost commented 1 year ago

All requested changes have been done and tested.

Jerrie-Aries commented 1 year ago

I did a couple of quick tests. Seems working fine for me.