Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Mareš
Postal Owl
Commits
2b2ded40
Commit
2b2ded40
authored
Sep 28, 2021
by
Martin Mareš
Browse files
Mail notifications have a Reply-To to course teachers
Closes
#38
.
parent
a7b870a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
owl.py
View file @
2b2ded40
...
...
@@ -1682,14 +1682,24 @@ def send_notify_post(post):
"""
,
(
topic
.
cid
,
post
.
target_uid
,
post
.
target_uid
,
topic
.
tid
))
dests
=
db
.
fetchall
()
db_query
(
"""
SELECT u.email, u.first_name, u.last_name
FROM owl_enroll e
JOIN owl_users u ON u.uid = e.uid
WHERE e.cid=%s
AND e.is_teacher
AND u.email IS NOT NULL
"""
,
(
topic
.
cid
,))
reply_to
=
db
.
fetchall
()
for
dest
in
dests
:
if
dest
.
uid
!=
author
.
uid
or
dest
.
notify_self
:
send_notify_to_dest
(
post
,
topic
,
course
,
author
,
target
,
dest
)
send_notify_to_dest
(
post
,
topic
,
course
,
author
,
target
,
dest
,
reply_to
)
else
:
app
.
logger
.
info
(
f
"E-mail: not sending self-notify to uid=
{
dest
.
uid
}
"
)
def
send_notify_to_dest
(
post
,
topic
,
course
,
author
,
target
,
dest
):
def
send_notify_to_dest
(
post
,
topic
,
course
,
author
,
target
,
dest
,
reply_to
):
if
'MAIL_FROM'
not
in
app
.
config
:
app
.
logger
.
info
(
'Not sending: MAIL_FROM not defined'
)
return
...
...
@@ -1709,6 +1719,9 @@ def send_notify_to_dest(post, topic, course, author, target, dest):
# Everybody gets his own view of the thread, so the target is the observer's uid
msg
[
'References'
]
=
'<'
+
app
.
config
[
'MAIL_REFERENCES'
].
format
(
tid
=
post
.
tid
,
target
=
dest
.
uid
)
+
'>'
if
reply_to
:
msg
[
'Reply-To'
]
=
[
email
.
headerregistry
.
Address
(
display_name
=
full_name
(
r
),
addr_spec
=
r
.
email
)
for
r
in
reply_to
]
if
dest
.
is_teacher
and
target
:
target_uid
=
target
.
uid
title
=
f
"
{
topic
.
title
}
/
{
full_name
(
target
)
}
"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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