bz2pi: have prettier Froms on bug notifications
Include "Author Name via {botname}" in from.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
diff --git a/src/bugspray/bz2pi.py b/src/bugspray/bz2pi.py
index f9806a8..cd1087a 100644
--- a/src/bugspray/bz2pi.py
+++ b/src/bugspray/bz2pi.py
@@ -50,10 +50,16 @@
continue
clines = cdata['text'].strip().splitlines()
inre_cid = None
- comment_author = cdata['creator']
+ creator = cdata['creator']
+ comment_user = bugspray.bz_get_user(creator)
+ comment_author_name = comment_user.get('real_name')
+ if not comment_author_name:
+ comment_author_name = creator.split('@')[0]
if privacy_mode:
- comment_author = comment_author.split('@')[0]
+ comment_author = comment_author_name
logger.debug('Privacy mode, comment_author=%s', comment_author)
+ else:
+ comment_author = f'{comment_author_name} <{creator}>'
bodyvals = {
'bzname': config['bugzilla'].get('name'),
@@ -89,8 +95,11 @@
bodyvals['comment_text'] = '\n'.join(clines)
msg = email.message.EmailMessage()
+ fromaddr = email.utils.parseaddr(config['notify'].get('fromaddr'))
+ fromaddr = (f'{comment_author_name} via {fromaddr[0]}', fromaddr[1])
+ msg['From'] = b4.format_addrs([fromaddr])
if not privacy_mode:
- msg['Reply-To'] = b4.format_addrs([('', cdata['creator'])])
+ msg['Reply-To'] = b4.format_addrs([(comment_author_name, cdata['creator'])])
# A little hack to make sure Date: is consecutive for threads
try:
msg['Date'] = email.utils.formatdate(msgts + int(cdata['count']), localtime=True)