Inboxen / Inboxen

Main repo for Inboxen.org

Home Page:https://inboxen.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

User quota might not be working right when delete email is selected

moggers87 opened this issue · comments

Inboxen/inboxen/tasks.py

Lines 304 to 310 in 914364c

if profile.quota_options == profile.DELETE_MAIL and email_count > settings.PER_USER_EMAIL_QUOTA:
chain(
batch_mark_as_deleted.si("email", kwargs={"important": False, "inbox__user_id": user_id},
skip_items=settings.PER_USER_EMAIL_QUOTA),
batch_set_new_flags.si(user_id=user_id, kwargs={"email__deleted": True}),
batch_delete_items.si("email", kwargs={"deleted": True, "inbox__user_id": user_id}),
).apply_async()

I think this will only reduce to the number of present emails to be at the quota, not below. Also it doesn't account for important flagged emails that will not be deleted i.e. the logic here is too simple

Also the tests for this are perfunctory at best and need refactoring.