mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 17:08:30 +01:00
bdb0c8bd08
* feat: alias audit log * feat: crontab to delete old alias_audit_log entries * Unified messages --------- Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
32 lines
813 B
Python
32 lines
813 B
Python
from enum import Enum
|
|
from typing import Optional
|
|
|
|
from app.models import Alias, AliasAuditLog
|
|
|
|
|
|
class AliasAuditLogAction(Enum):
|
|
CreateAlias = "create"
|
|
ChangeAliasStatus = "change_status"
|
|
DeleteAlias = "delete"
|
|
UpdateAlias = "update"
|
|
InitiateTransferAlias = "initiate_transfer_alias"
|
|
AcceptTransferAlias = "accept_transfer_alias"
|
|
TransferredAlias = "transferred_alias"
|
|
ChangedMailboxes = "changed_mailboxes"
|
|
|
|
|
|
def emit_alias_audit_log(
|
|
alias: Alias,
|
|
action: AliasAuditLogAction,
|
|
message: str,
|
|
user_id: Optional[int] = None,
|
|
commit: bool = False,
|
|
):
|
|
AliasAuditLog.create(
|
|
user_id=user_id or alias.user_id,
|
|
alias_id=alias.id,
|
|
alias_email=alias.email,
|
|
action=action.value,
|
|
message=message,
|
|
commit=commit,
|
|
)
|