mirror of
https://github.com/simple-login/app.git
synced 2026-04-07 19:27:34 +00:00
a70baad478
* wip: start implementing alias trash * Added alias trash dashboard page * test: delete_alias changes * Format html * fix: mailbox deletion * feat: add delete_alias_action setting in dashboard settings * chore: disable alias when trashing it * Add restore tests * Move tras/restore to alias_actions * rename alias_actions to alias_delete * Remove alias_actions * Send events and alias audit log on alias restore * feat: adapt queries to trashed alias * chore: add metrics on alias trash actions * fix: missing empty arg * Add rate limit for restore and restore all * fix: mailbox alias count * feat: properly handle alias deletion for custom domain deletion * chore: add error logs * chore: update alias trash copy + change Trash location * feat: make can_create_new_alias not take trashed aliases into account * chore: update mailbox deletion dialog copy --------- Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
22 lines
599 B
Python
22 lines
599 B
Python
import arrow
|
|
from sqlalchemy import and_
|
|
|
|
from app.db import Session
|
|
from app.log import LOG
|
|
from app.models import Alias
|
|
from app.alias_delete import perform_alias_deletion
|
|
|
|
|
|
def cleanup_alias(oldest_allowed: arrow.Arrow):
|
|
LOG.i(f"Deleting alias with delete_on older than {oldest_allowed}")
|
|
for alias in (
|
|
Alias.filter(
|
|
and_(Alias.delete_on.isnot(None), Alias.delete_on <= oldest_allowed)
|
|
)
|
|
.yield_per(500)
|
|
.all()
|
|
):
|
|
alias: Alias = alias
|
|
perform_alias_deletion(alias, alias.user, alias.delete_reason)
|
|
Session.commit()
|