fix: send up to date flag notifications

These were being produced with the db state before the flag was set,
which is not what should be done for flag notifications, as the
notification contains data about the comment and the current flagger.

Closes #292

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2022-02-17 15:30:32 -08:00
parent 640630faff
commit 040c9bc3e6
No known key found for this signature in database
GPG key ID: F7E46DED420788F3

View file

@ -150,13 +150,13 @@ async def pkgbase_flag_post(request: Request, name: str,
has_cred = request.user.has_credential(creds.PKGBASE_FLAG) has_cred = request.user.has_credential(creds.PKGBASE_FLAG)
if has_cred and not pkgbase.OutOfDateTS: if has_cred and not pkgbase.OutOfDateTS:
notif = notify.FlagNotification(request.user.ID, pkgbase.ID)
now = time.utcnow() now = time.utcnow()
with db.begin(): with db.begin():
pkgbase.OutOfDateTS = now pkgbase.OutOfDateTS = now
pkgbase.Flagger = request.user pkgbase.Flagger = request.user
pkgbase.FlaggerComment = comments pkgbase.FlaggerComment = comments
notif.send()
notify.FlagNotification(request.user.ID, pkgbase.ID).send()
return RedirectResponse(f"/pkgbase/{name}", return RedirectResponse(f"/pkgbase/{name}",
status_code=HTTPStatus.SEE_OTHER) status_code=HTTPStatus.SEE_OTHER)