mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: send out a FlagNotification when a package is flagged
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
2d6c09bec5
commit
e777b7052e
2 changed files with 5 additions and 0 deletions
|
@ -145,11 +145,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()
|
||||||
|
|
||||||
return RedirectResponse(f"/pkgbase/{name}",
|
return RedirectResponse(f"/pkgbase/{name}",
|
||||||
status_code=HTTPStatus.SEE_OTHER)
|
status_code=HTTPStatus.SEE_OTHER)
|
||||||
|
|
|
@ -836,6 +836,9 @@ def test_pkgbase_flag(client: TestClient, user: User, maintainer: User,
|
||||||
assert pkgbase.Flagger == user
|
assert pkgbase.Flagger == user
|
||||||
assert pkgbase.FlaggerComment == "Test"
|
assert pkgbase.FlaggerComment == "Test"
|
||||||
|
|
||||||
|
# Should've gotten a FlagNotification.
|
||||||
|
assert Email.count() == 1
|
||||||
|
|
||||||
# Now, let's check the /pkgbase/{name}/flag-comment route.
|
# Now, let's check the /pkgbase/{name}/flag-comment route.
|
||||||
flag_comment_endpoint = f"/pkgbase/{pkgbase.Name}/flag-comment"
|
flag_comment_endpoint = f"/pkgbase/{pkgbase.Name}/flag-comment"
|
||||||
with client as request:
|
with client as request:
|
||||||
|
|
Loading…
Add table
Reference in a new issue