aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2023-04-11 11:21:51 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2023-04-11 11:23:05 -0400
commit51e86f7b020ebcfbccfcef7f1efed4a843cb6d9a (patch)
tree91f452fb80e1e6e84236700c1cb57fedb1b2b21f
parenta93d30d7b9ba5f4aaf46408ab05a25d158a15725 (diff)
downloadpeebz-51e86f7b020ebcfbccfcef7f1efed4a843cb6d9a.tar.gz
Include attachment comment
Include the comment info when reporting a new attachment, which may carry important accompanying info. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--default.config.toml5
-rw-r--r--peebz/__init__.py2
-rw-r--r--peebz/bz2pi.py19
-rw-r--r--peebz/command.py2
4 files changed, 16 insertions, 12 deletions
diff --git a/default.config.toml b/default.config.toml
index 38905c4..f432095 100644
--- a/default.config.toml
+++ b/default.config.toml
@@ -64,8 +64,9 @@ You can reply to this message to join the discussion.
'''
new_attachment_notify = '''
-${comment_author} added a new attachment via ${bzname}.
-You can download it by following the link below.
+${comment_author} added an attachment on ${bzname}:
+
+${comment_text}
File: ${file_name} (${content_type})
Size: ${human_size}
diff --git a/peebz/__init__.py b/peebz/__init__.py
index b380c59..d5c1d0c 100644
--- a/peebz/__init__.py
+++ b/peebz/__init__.py
@@ -453,7 +453,7 @@ def bz_get_attachment_by_aid(aid: int, include_fields: Optional[str] = None) ->
radata['human_size'] = get_human_size(radata['size'])
return radata
- raise LookupError('No matching attachment_id found: %s', aid)
+ raise LookupError('No matching attachment_id found: %s' % aid)
def bz_get_all_comments_by_bid(bid: int) -> List[Dict]:
diff --git a/peebz/bz2pi.py b/peebz/bz2pi.py
index fd16dd1..0559d53 100644
--- a/peebz/bz2pi.py
+++ b/peebz/bz2pi.py
@@ -73,17 +73,18 @@ def process_new_comments(bid: int, privacy_mode: bool = False, dry_run: bool = F
attachment_id=cdata['attachment_id'])
else:
logger.info('Processing new comment for bug_id=%s, comment_id=%s', bid, cid)
- fline = clines[0]
- matches = re.search(r'\(In reply to.*from comment #(\d+)', fline, flags=re.I)
- if matches:
- inre_count = int(matches.groups()[0])
- try:
- inre_cid = peebz.bz_get_cid_by_bid_count(bid, inre_count)
- except LookupError:
- pass
- bodyvals['comment_text'] = '\n'.join(clines)
bodytpt = peebz.get_template_by_bid('new_comment_notify', bid)
+ fline = clines[0]
+ matches = re.search(r'\(In reply to.*from comment #(\d+)', fline, flags=re.I)
+ if matches:
+ inre_count = int(matches.groups()[0])
+ try:
+ inre_cid = peebz.bz_get_cid_by_bid_count(bid, inre_count)
+ except LookupError:
+ pass
+ bodyvals['comment_text'] = '\n'.join(clines)
+
msg = email.message.EmailMessage()
if not privacy_mode:
msg['Reply-To'] = b4.format_addrs([('', cdata['creator'])])
diff --git a/peebz/command.py b/peebz/command.py
index 30046bd..a2ebc7d 100644
--- a/peebz/command.py
+++ b/peebz/command.py
@@ -38,6 +38,8 @@ def cmd_bzdump(cmdargs):
rdata = peebz.bz_get_user(cmdargs.username)
elif cmdargs.quicksearch:
rdata = peebz.bz_quicksearch_bugs(query=cmdargs.quicksearch)
+ elif cmdargs.attachment_id:
+ rdata = peebz.bz_get_attachment_by_aid(int(cmdargs.attachment_id))
else:
sys.exit(1)