From a17dd19c0426b37de2262b50bfba4761b863a6d6 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Tue, 23 Aug 2022 13:31:07 -0400 Subject: ez: move the RESEND prefix into --resend switch For UX reasons, make --resend a separate switch instead of operating on the --prefixes RESEND logic. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'b4/__init__.py') diff --git a/b4/__init__.py b/b4/__init__.py index 4e005af..4296b10 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -916,8 +916,8 @@ class LoreMessage: if self.date.tzinfo is None: self.date = self.date.replace(tzinfo=datetime.timezone.utc) - diffre = re.compile(r'^(---.*\n\+\+\+|GIT binary patch|diff --git \w/\S+ \w/\S+)', re.M | re.I) - diffstatre = re.compile(r'^\s*\d+ file.*\d+ (insertion|deletion)', re.M | re.I) + diffre = re.compile(r'^(---.*\n\+\+\+|GIT binary patch|diff --git \w/\S+ \w/\S+)', flags=re.M | re.I) + diffstatre = re.compile(r'^\s*\d+ file.*\d+ (insertion|deletion)', flags=re.M | re.I) # walk until we find the first text/plain part mcharset = self.msg.get_content_charset() @@ -2954,16 +2954,17 @@ def send_mail(smtp: Union[smtplib.SMTP, smtplib.SMTP_SSL, None], msgs: Sequence[ } ses = get_requests_session() res = ses.post(endpoint, json=req) - if res.status_code == 200: - try: - rdata = res.json() - if rdata.get('result') == 'success': - return len(tosend) - except Exception as ex: # noqa - logger.critical('Odd response from the endpoint: %s', res.text) - - logger.critical('500 response from the endpoint: %s', res.text) - return None + try: + rdata = res.json() + if rdata.get('result') == 'success': + return len(tosend) + except Exception as ex: # noqa + logger.critical('Odd response from the endpoint: %s', res.text) + return 0 + + if rdata.get('result') == 'error': + logger.critical('Error from endpoint: %s', rdata.get('message')) + return 0 if smtp: sent = 0 -- cgit v1.2.3