mirror of
https://github.com/Mailu/Mailu.git
synced 2025-01-18 03:21:36 +02:00
Implement event lister to keep updated_at unchanged on quota_bytes_used updates
This commit is contained in:
parent
48e1e91a2c
commit
102d96bc7d
@ -25,6 +25,7 @@ from flask import current_app as app
|
||||
from sqlalchemy.ext import declarative
|
||||
from sqlalchemy.ext.hybrid import hybrid_property
|
||||
from sqlalchemy.inspection import inspect
|
||||
from sqlalchemy.orm.attributes import flag_modified
|
||||
from werkzeug.utils import cached_property
|
||||
|
||||
from mailu import dkim, utils
|
||||
@ -982,3 +983,13 @@ class MailuConfig:
|
||||
alias = MailuCollection(Alias)
|
||||
relay = MailuCollection(Relay)
|
||||
config = MailuCollection(Config)
|
||||
|
||||
|
||||
@db.event.listens_for(User, 'before_update')
|
||||
def receive_before_update(mapper, connection, target):
|
||||
""" Mark updated_at as modified, but keep the old date when updating the quota_bytes_used
|
||||
"""
|
||||
insp = db.inspect(target)
|
||||
quota_bytes_used_changed, _, _ = insp.attrs.quota_bytes_used.history
|
||||
if quota_bytes_used_changed:
|
||||
flag_modified(target, 'updated_at')
|
||||
|
Loading…
Reference in New Issue
Block a user