From 2d6c09bec536dc40aa47ac834d1ac191242889e4 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Sat, 5 Feb 2022 04:28:50 -0800 Subject: [PATCH 1/2] fix: handling of user registration HideEmail Signed-off-by: Kevin Morris --- aurweb/routers/accounts.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aurweb/routers/accounts.py b/aurweb/routers/accounts.py index 7cd25c49..d1b9d428 100644 --- a/aurweb/routers/accounts.py +++ b/aurweb/routers/accounts.py @@ -276,6 +276,9 @@ async def account_register_post(request: Request, args["K"] = args.get("K", str()).replace(" ", "") K = args.get("K") + # Force "H" into a boolean. + args["H"] = H = (args.get("H", str()) == "on") + context = make_account_form_context(context, request, None, args) ok, errors = process_account_form(request, request.user, args) if not ok: From e777b7052e3648467f1185cf4782ed8b7d672ad5 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Sat, 5 Feb 2022 04:40:25 -0800 Subject: [PATCH 2/2] fix: send out a FlagNotification when a package is flagged Signed-off-by: Kevin Morris --- aurweb/routers/pkgbase.py | 2 ++ test/test_pkgbase_routes.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/aurweb/routers/pkgbase.py b/aurweb/routers/pkgbase.py index b014ddc5..3ec009e5 100644 --- a/aurweb/routers/pkgbase.py +++ b/aurweb/routers/pkgbase.py @@ -145,11 +145,13 @@ async def pkgbase_flag_post(request: Request, name: str, has_cred = request.user.has_credential(creds.PKGBASE_FLAG) if has_cred and not pkgbase.OutOfDateTS: + notif = notify.FlagNotification(request.user.ID, pkgbase.ID) now = time.utcnow() with db.begin(): pkgbase.OutOfDateTS = now pkgbase.Flagger = request.user pkgbase.FlaggerComment = comments + notif.send() return RedirectResponse(f"/pkgbase/{name}", status_code=HTTPStatus.SEE_OTHER) diff --git a/test/test_pkgbase_routes.py b/test/test_pkgbase_routes.py index 0287a026..1bd3e524 100644 --- a/test/test_pkgbase_routes.py +++ b/test/test_pkgbase_routes.py @@ -836,6 +836,9 @@ def test_pkgbase_flag(client: TestClient, user: User, maintainer: User, assert pkgbase.Flagger == user assert pkgbase.FlaggerComment == "Test" + # Should've gotten a FlagNotification. + assert Email.count() == 1 + # Now, let's check the /pkgbase/{name}/flag-comment route. flag_comment_endpoint = f"/pkgbase/{pkgbase.Name}/flag-comment" with client as request: