aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-23 13:29:02 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-23 13:29:02 -0400
commit7b8cd8047d3c17b08ad888e5bf525bdcb9cc6bbd (patch)
treed660be26429f3f88eb21dc702e45ba072a88361c
parentae63faa8e546381ab16f18bdfeb66a9cee86c88b (diff)
downloadb4-7b8cd8047d3c17b08ad888e5bf525bdcb9cc6bbd.tar.gz
ez: only use web endpoint when sending patches
Force the use of smtp server when sending anything other than patches (e.g. b4 ty automated responses). Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--b4/__init__.py7
-rw-r--r--b4/ez.py4
-rw-r--r--b4/ty.py3
3 files changed, 8 insertions, 6 deletions
diff --git a/b4/__init__.py b/b4/__init__.py
index 2b70c38..4e005af 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -2879,8 +2879,8 @@ def patchwork_set_state(msgids: List[str], state: str) -> bool:
def send_mail(smtp: Union[smtplib.SMTP, smtplib.SMTP_SSL, None], msgs: Sequence[email.message.Message],
fromaddr: Optional[str], destaddrs: Optional[Union[set, list]] = None,
patatt_sign: bool = False, dryrun: bool = False,
- maxheaderlen: Optional[int] = None,
- output_dir: Optional[str] = None) -> Optional[int]:
+ maxheaderlen: Optional[int] = None, output_dir: Optional[str] = None,
+ use_web_endpoint: bool = False) -> Optional[int]:
tosend = list()
if output_dir is not None:
@@ -2945,7 +2945,8 @@ def send_mail(smtp: Union[smtplib.SMTP, smtplib.SMTP_SSL, None], msgs: Sequence[
# Do we have an endpoint defined?
config = get_main_config()
endpoint = config.get('send-endpoint-web')
- if endpoint:
+ if use_web_endpoint and endpoint:
+ logger.info('---')
logger.info('Sending via web endpoint %s', endpoint)
req = {
'action': 'receive',
diff --git a/b4/ez.py b/b4/ez.py
index a175a33..4b7e148 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -1104,7 +1104,7 @@ def cmd_send(cmdargs: argparse.Namespace) -> None:
sys.exit(1)
sent = b4.send_mail(None, send_msgs, fromaddr=None, destaddrs=None, patatt_sign=True,
- dryrun=cmdargs.dryrun, output_dir=cmdargs.output_dir)
+ dryrun=cmdargs.dryrun, output_dir=cmdargs.output_dir, use_web_endpoint=True)
else:
identity = config.get('sendemail-identity')
try:
@@ -1115,7 +1115,7 @@ def cmd_send(cmdargs: argparse.Namespace) -> None:
sys.exit(1)
sent = b4.send_mail(smtp, send_msgs, fromaddr=fromaddr, destaddrs=alldests, patatt_sign=sign,
- dryrun=cmdargs.dryrun, output_dir=cmdargs.output_dir)
+ dryrun=cmdargs.dryrun, output_dir=cmdargs.output_dir, use_web_endpoint=False)
logger.info('---')
if cmdargs.dryrun:
diff --git a/b4/ty.py b/b4/ty.py
index 7ca64da..2bb7d2f 100644
--- a/b4/ty.py
+++ b/b4/ty.py
@@ -431,7 +431,8 @@ def send_messages(listing, branch, cmdargs):
if not fromaddr:
fromaddr = jsondata['myemail']
logger.info(' Sending: %s', msg.get('subject'))
- b4.send_mail(smtp, [msg], fromaddr, dryrun=cmdargs.dryrun)
+ # We never want to use the web endpoint for this (it's only for submitting patches)
+ b4.send_mail(smtp, [msg], fromaddr, dryrun=cmdargs.dryrun, use_web_endpoint=False)
else:
slug_from = re.sub(r'\W', '_', jsondata['fromemail'])
slug_subj = re.sub(r'\W', '_', jsondata['subject'])