From b945113867fea020723e6cd9010b45e2f1152511 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Mon, 3 Dec 2012 13:49:12 -0500 Subject: [PATCH] [manual] Unify huddles and personals into private messages on the receive path feedback-bot and zephyr_mirror will need to be updated and restarted when this is deployed to prod. (imported from commit fe2b524424c174bcb1b717a851a5d3815fda3f69) --- bots/feedback-bot | 2 +- bots/zephyr_mirror_backend.py | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/bots/feedback-bot b/bots/feedback-bot index b1d521e..75f130d 100755 --- a/bots/feedback-bot +++ b/bots/feedback-bot @@ -18,7 +18,7 @@ staging_client = humbug.Client( site="https://staging.humbughq.com") def forward_message(message): - if message["type"] != "personal": + if message["type"] != "private" or len(message["recipient"]) != 2: return forwarded_message = { "type": "stream", diff --git a/bots/zephyr_mirror_backend.py b/bots/zephyr_mirror_backend.py index 058c8dd..8428ea5 100755 --- a/bots/zephyr_mirror_backend.py +++ b/bots/zephyr_mirror_backend.py @@ -461,13 +461,14 @@ def forward_to_zephyr(message): instance = zephyr_class zephyr_class = "message" zwrite_args.extend(["-c", zephyr_class, "-i", instance]) - elif message['type'] == "personal": - recipient = to_zephyr_username(message["display_recipient"]["email"]) - zwrite_args.extend([recipient]) - elif message['type'] == "huddle": - zwrite_args.extend(["-C"]) - zwrite_args.extend([to_zephyr_username(user["email"]).replace("@ATHENA.MIT.EDU", "") - for user in message["display_recipient"]]) + elif message['type'] == "private": + if len(message['display_recipient']) == 1: + recipient = to_zephyr_username(message["display_recipient"][0]["email"]) + zwrite_args.extend([recipient]) + else: + zwrite_args.extend(["-C"]) + zwrite_args.extend([to_zephyr_username(user["email"]).replace("@ATHENA.MIT.EDU", "") + for user in message["display_recipient"]]) if options.test_mode: logger.debug("Would have forwarded: %s\n%s" % @@ -522,12 +523,10 @@ received it, Zephyr users did not. The error message from zwrite was: def maybe_forward_to_zephyr(message): if (message["sender_email"] == options.user + "@mit.edu"): if not ((message["type"] == "stream") or - (message["type"] == "personal" and - message["display_recipient"]["email"].lower().endswith("mit.edu")) or - (message["type"] == "huddle" and + (message["type"] == "private" and False not in [u["email"].lower().endswith("mit.edu") for u in message["display_recipient"]])): - # Don't try forward personals/huddles with non-MIT users + # Don't try forward private messages with non-MIT users # to MIT Zephyr. return timestamp_now = datetime.datetime.now().strftime("%s")