Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Arch Linux
aurweb
Commits
50b726d7
Verified
Commit
50b726d7
authored
Feb 11, 2022
by
Kevin Morris
Browse files
fix: send notifications when users submit comments
Closes #278 Signed-off-by:
Kevin Morris
<
kevr@0cost.org
>
parent
a2e99311
Pipeline
#15820
passed with stages
in 3 minutes and 8 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
aurweb/routers/pkgbase.py
View file @
50b726d7
...
...
@@ -187,6 +187,9 @@ async def pkgbase_comments_post(
PackageBase
=
pkgbase
)
update_comment_render_fastapi
(
comment
)
notif
=
notify
.
CommentNotification
(
request
.
user
.
ID
,
pkgbase
.
ID
,
comment
.
ID
)
notif
.
send
()
# Redirect to the pkgbase page.
return
RedirectResponse
(
f
"/pkgbase/
{
pkgbase
.
Name
}
#comment-
{
comment
.
ID
}
"
,
status_code
=
HTTPStatus
.
SEE_OTHER
)
...
...
test/test_pkgbase_routes.py
View file @
50b726d7
...
...
@@ -370,6 +370,12 @@ def test_pkgbase_comments(client: TestClient, maintainer: User, user: User,
- GET /pkgbase/{name}/comments/{id}/form
- Tested against a comment created with the POST route
"""
with
db
.
begin
():
user
.
CommentNotify
=
1
db
.
create
(
PackageNotification
,
PackageBase
=
package
.
PackageBase
,
User
=
user
)
cookies
=
{
"AURSID"
:
maintainer
.
login
(
Request
(),
"testPassword"
)}
pkgbasename
=
package
.
PackageBase
.
Name
endpoint
=
f
"/pkgbase/
{
pkgbasename
}
/comments"
...
...
@@ -380,6 +386,9 @@ def test_pkgbase_comments(client: TestClient, maintainer: User, user: User,
},
cookies
=
cookies
)
assert
resp
.
status_code
==
int
(
HTTPStatus
.
SEE_OTHER
)
# user should've gotten a CommentNotification email.
assert
Email
.
count
()
==
1
expected_prefix
=
f
"/pkgbase/
{
pkgbasename
}
"
prefix_len
=
len
(
expected_prefix
)
assert
resp
.
headers
.
get
(
"location"
)[:
prefix_len
]
==
expected_prefix
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment