delete unnecessary notifications
This commit is contained in:
parent
26235fef49
commit
c721f25104
|
@ -1,7 +1,8 @@
|
|||
from datetime import datetime, timedelta, timezone
|
||||
from enum import IntEnum
|
||||
from typing import Optional, Tuple
|
||||
from flaschengeist.models import UtcDateTime
|
||||
from typing import Optional, Tuple, Union
|
||||
from flaschengeist.controller import userController
|
||||
from flaschengeist.models import Notification, UtcDateTime
|
||||
from flaschengeist.models.user import User
|
||||
|
||||
from werkzeug.exceptions import BadRequest, Conflict, NotFound
|
||||
|
@ -364,9 +365,21 @@ def get_invitations(user: User):
|
|||
).all()
|
||||
|
||||
|
||||
def cleanup_notifications(inv: Invitation):
|
||||
notifications = tuple(
|
||||
filter(
|
||||
lambda notification: notification.data.get("invitation") == inv.id, EventPlugin.getPlugin().notifications
|
||||
)
|
||||
)
|
||||
for notification in notifications:
|
||||
db.session.delete(notification)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def cancel_invitation(inv: Invitation):
|
||||
db.session.delete(inv)
|
||||
db.session.commit()
|
||||
cleanup_notifications(inv)
|
||||
|
||||
|
||||
def respond_invitation(invite: Invitation, accepted=True):
|
||||
|
|
Loading…
Reference in New Issue