[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)
This commit is contained in:
Zev Benjamin 2012-12-03 13:49:12 -05:00
parent 6d8519bc5d
commit b945113867
2 changed files with 11 additions and 12 deletions

View file

@ -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",

View file

@ -461,10 +461,11 @@ 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"])
elif message['type'] == "private":
if len(message['display_recipient']) == 1:
recipient = to_zephyr_username(message["display_recipient"][0]["email"])
zwrite_args.extend([recipient])
elif message['type'] == "huddle":
else:
zwrite_args.extend(["-C"])
zwrite_args.extend([to_zephyr_username(user["email"]).replace("@ATHENA.MIT.EDU", "")
for user in message["display_recipient"]])
@ -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")