From 314d0fc0539141794506522ad0b3e410c5e87102 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 27 Aug 2013 15:25:59 -0400 Subject: [PATCH] zephyr_mirror: Subscribe to mail zephyrs even if we're not using them. This should enabled us, in the future, to enable support for mail zephyrs without requiring users to re-auth. (imported from commit 2665743212da567fe85742d30cca42b902e41a0d) --- bots/zephyr_mirror_backend.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bots/zephyr_mirror_backend.py b/bots/zephyr_mirror_backend.py index aa264680f5..e906e8c9a1 100755 --- a/bots/zephyr_mirror_backend.py +++ b/bots/zephyr_mirror_backend.py @@ -384,6 +384,10 @@ def process_notice(notice, log): if notice.format.startswith("Zephyr error: See") or notice.format.endswith("@(@color(blue))"): logger.debug("Skipping message we got from Zulip!") return + if (zephyr_class == "mail" and notice.instance.lower() == "inbox" and is_personal and + not options.forward_mail_zephyrs): + # Only forward mail zephyrs if forwarding them is enabled. + return if is_personal: if body.startswith("CC:"): @@ -521,8 +525,7 @@ def zephyr_to_zulip(options): # Subscribe to personals; we really can't operate without # those subscriptions, so just retry until it works. zephyr_subscribe_autoretry(("message", "*", "%me%")) - if subscribed_to_mail_messages(): - zephyr_subscribe_autoretry(("mail", "inbox", "%me%")) + zephyr_subscribe_autoretry(("mail", "inbox", "%me%")) if options.nagios_class: zephyr_subscribe_autoretry((options.nagios_class, "*", "*")) if options.use_sessions: @@ -944,6 +947,11 @@ def parse_args(): help=optparse.SUPPRESS_HELP, default=True, action='store_false') + parser.add_option('--forward-mail-zephyrs', + dest='forward_mail_zephyrs', + help=optparse.SUPPRESS_HELP, + default=False, + action='store_true') parser.add_option('--no-forward-from-zulip', default=True, dest='forward_from_zulip', @@ -1099,6 +1107,8 @@ or specify the --api-key-file option.""" % (options.api_key_file,)))) # forwarding and zulip => zephyr forwarding options.forward_personals = False options.forward_from_zulip = False + if options.forward_mail_zephyrs is None: + options.forward_mail_zephyrs = subscribed_to_mail_messages() if options.session_path is None: options.session_path = "/var/tmp/%s" % (options.user,)