[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:
parent
6d8519bc5d
commit
b945113867
|
@ -18,7 +18,7 @@ staging_client = humbug.Client(
|
||||||
site="https://staging.humbughq.com")
|
site="https://staging.humbughq.com")
|
||||||
|
|
||||||
def forward_message(message):
|
def forward_message(message):
|
||||||
if message["type"] != "personal":
|
if message["type"] != "private" or len(message["recipient"]) != 2:
|
||||||
return
|
return
|
||||||
forwarded_message = {
|
forwarded_message = {
|
||||||
"type": "stream",
|
"type": "stream",
|
||||||
|
|
|
@ -461,10 +461,11 @@ def forward_to_zephyr(message):
|
||||||
instance = zephyr_class
|
instance = zephyr_class
|
||||||
zephyr_class = "message"
|
zephyr_class = "message"
|
||||||
zwrite_args.extend(["-c", zephyr_class, "-i", instance])
|
zwrite_args.extend(["-c", zephyr_class, "-i", instance])
|
||||||
elif message['type'] == "personal":
|
elif message['type'] == "private":
|
||||||
recipient = to_zephyr_username(message["display_recipient"]["email"])
|
if len(message['display_recipient']) == 1:
|
||||||
|
recipient = to_zephyr_username(message["display_recipient"][0]["email"])
|
||||||
zwrite_args.extend([recipient])
|
zwrite_args.extend([recipient])
|
||||||
elif message['type'] == "huddle":
|
else:
|
||||||
zwrite_args.extend(["-C"])
|
zwrite_args.extend(["-C"])
|
||||||
zwrite_args.extend([to_zephyr_username(user["email"]).replace("@ATHENA.MIT.EDU", "")
|
zwrite_args.extend([to_zephyr_username(user["email"]).replace("@ATHENA.MIT.EDU", "")
|
||||||
for user in message["display_recipient"]])
|
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):
|
def maybe_forward_to_zephyr(message):
|
||||||
if (message["sender_email"] == options.user + "@mit.edu"):
|
if (message["sender_email"] == options.user + "@mit.edu"):
|
||||||
if not ((message["type"] == "stream") or
|
if not ((message["type"] == "stream") or
|
||||||
(message["type"] == "personal" and
|
(message["type"] == "private" and
|
||||||
message["display_recipient"]["email"].lower().endswith("mit.edu")) or
|
|
||||||
(message["type"] == "huddle" and
|
|
||||||
False not in [u["email"].lower().endswith("mit.edu") for u in
|
False not in [u["email"].lower().endswith("mit.edu") for u in
|
||||||
message["display_recipient"]])):
|
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.
|
# to MIT Zephyr.
|
||||||
return
|
return
|
||||||
timestamp_now = datetime.datetime.now().strftime("%s")
|
timestamp_now = datetime.datetime.now().strftime("%s")
|
||||||
|
|
Loading…
Reference in a new issue