fix: save notification state for unchanged comments

When we edit a comment we can enable notifications (if not yet enabled).

We should also do this when the comment text is not changed.

Signed-off-by: moson-mo <mo-son@mailbox.org>
This commit is contained in:
moson-mo 2023-01-22 16:32:39 +01:00
parent 36fd58d7a6
commit ff0123b54a
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
2 changed files with 24 additions and 1 deletions

View file

@ -312,11 +312,14 @@ async def pkgbase_comment_post(
db_comment.Editor = request.user
db_comment.EditedTS = now
if enable_notifications:
with db.begin():
db_notif = request.user.notifications.filter(
PackageNotification.PackageBaseID == pkgbase.ID
).first()
if enable_notifications and not db_notif:
if not db_notif:
db.create(PackageNotification, User=request.user, PackageBase=pkgbase)
update_comment_render_fastapi(db_comment)
if not next: