zephyr_mirror: Improve debugging output on outgoing messages.

Previously all that we logged was the sender, which turns out to be a
constant for humbug=>zephyr mirroring.

(imported from commit 527a3ac4b9b815a2b4d6b63c3ad92d9d5ad99a6e)
This commit is contained in:
Tim Abbott 2012-12-10 13:35:31 -05:00
parent 69c1b8beca
commit 8e0aabc730

View file

@ -440,7 +440,6 @@ def forward_to_zephyr(message):
zwrite_args = ["zwrite", "-n", "-s", zsig_fullname, "-F", "Class $class, Instance $instance:\n" + zwrite_args = ["zwrite", "-n", "-s", zsig_fullname, "-F", "Class $class, Instance $instance:\n" +
"To: @bold($recipient) at $time $date\n" + "To: @bold($recipient) at $time $date\n" +
"From: @bold{$1 <$sender>}\n\n$2@(@color(blue))"] "From: @bold{$1 <$sender>}\n\n$2@(@color(blue))"]
logger.info("Forwarding message from %s" % (message["sender_email"],))
if message['type'] == "stream": if message['type'] == "stream":
zephyr_class = message["display_recipient"] zephyr_class = message["display_recipient"]
instance = message["subject"] instance = message["subject"]
@ -461,21 +460,24 @@ 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])
logger.info("Forwarding message to class %s, instance %s" % (zephyr_class, instance))
elif message['type'] == "private": elif message['type'] == "private":
if len(message['display_recipient']) == 1: if len(message['display_recipient']) == 1:
recipient = to_zephyr_username(message["display_recipient"][0]["email"]) recipient = to_zephyr_username(message["display_recipient"][0]["email"])
zwrite_args.extend([recipient]) recipients = [recipient]
elif len(message['display_recipient']) == 2: elif len(message['display_recipient']) == 2:
recipient = "" recipient = ""
for r in message["display_recipient"]: for r in message["display_recipient"]:
if r["email"].lower() != humbug_account_email.lower(): if r["email"].lower() != humbug_account_email.lower():
recipient = to_zephyr_username(r["email"]) recipient = to_zephyr_username(r["email"])
break break
zwrite_args.extend([recipient]) recipients = [recipient]
else: else:
zwrite_args.extend(["-C"]) zwrite_args.extend(["-C"])
zwrite_args.extend([to_zephyr_username(user["email"]).replace("@ATHENA.MIT.EDU", "") recipients = [to_zephyr_username(user["email"]).replace("@ATHENA.MIT.EDU", "")
for user in message["display_recipient"]]) for user in message["display_recipient"]]
logger.info("Forwarding message to %s" % (recipients,))
zwrite_args.extend(recipients)
if options.test_mode: if options.test_mode:
logger.debug("Would have forwarded: %s\n%s" % logger.debug("Would have forwarded: %s\n%s" %