-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add setting for message retention #26
Comments
If the goal is for Not to overcomplicate it, but I could see someone wanting messages to immediately delete after successfully sent, and I could see people wanting to store the last n-messages for anyone who might send 1000s a day. |
Then in the # email_relay/management/commands/runrelay.py
...
send_all()
if app_settings.MESSAGES_RETENTION_SECONDS:
if app_settings.MESSAGES_RETENTION_SECONDS == 0:
Messages.objects.sent().delete()
else:
Messages.objects.sent_before(timezone.now() - app_settings.MESSAGES_RETENTION_SECONDS).delete() Then for the n messages, something like: # email_relay/conf.py
# keep all (default)
MESSAGES_SENT_MAX_KEEP = None
# keep the last 1000
MESSAGES_SENT_MAX_KEEP = 1000 Not in love with that setting name, but I don't hate it so it'll do for now, unless something better comes up. Then: # email_relay/runrelay.py
...
send_all()
...
if app_settings.MESSAGES_SENT_MAX_KEEP:
# do the slicing and dicing here |
Since we are saving the entire email, including any attachments, in a database table, there is potential for the space to grow and grow unless there is some sort of way to clear out old emails.
I think there should be a new setting, something like
MESSAGES_RETENTION_SECONDS
that takes anint
of the number of seconds to keep messages. Then somewhere in the relay loop, either within therunrelay
management command, thesend_all
function, or maybe a new function that is called from withinrunrelay
, that filter's all messages bycreated_at__lt=timezone.now() - app_settings.MESSAGES_RETENTION_SECONDS
and deletes any found.The text was updated successfully, but these errors were encountered: