zephyr_mirror: Shell out to zwrite instead of using python-zephyr to send.
This eliminates the problems with python-zephyr not being able to handle non-ascii characters in instances and class names. (imported from commit c9f295cb18bc5043cd8efecbe6996ff373f66c9a)
This commit is contained in:
parent
2b7007fc1b
commit
86ef645444
|
@ -371,32 +371,19 @@ def forward_to_zephyr(message):
|
||||||
else:
|
else:
|
||||||
instance = zephyr_class
|
instance = zephyr_class
|
||||||
zephyr_class = "message"
|
zephyr_class = "message"
|
||||||
zeph = zephyr.ZNotice(sender=sender_email, auth=True,
|
zwrite_args = ["zwrite", "-s", zsig, "-c", zephyr_class, "-i", instance]
|
||||||
cls=zephyr_class, instance=instance)
|
|
||||||
body = "%s\0%s" % (zsig, wrapped_content)
|
|
||||||
zeph.setmessage(body)
|
|
||||||
zeph.send()
|
|
||||||
elif message['type'] == "personal":
|
elif message['type'] == "personal":
|
||||||
recipient = message["display_recipient"]["email"]
|
recipient = message["display_recipient"]["email"]
|
||||||
recipient = recipient.replace("@mit.edu", "@ATHENA.MIT.EDU")
|
recipient = recipient.replace("@mit.edu", "@ATHENA.MIT.EDU")
|
||||||
zeph = zephyr.ZNotice(sender=sender_email,
|
zwrite_args = ["zwrite", "-s", zsig, recipient]
|
||||||
auth=True, recipient=recipient,
|
|
||||||
cls="message", instance="personal")
|
|
||||||
body = "%s\0%s" % (zsig, wrapped_content)
|
|
||||||
zeph.setmessage(body)
|
|
||||||
zeph.send()
|
|
||||||
elif message['type'] == "huddle":
|
elif message['type'] == "huddle":
|
||||||
cc_list = ["CC:"]
|
zwrite_args = ["zwrite", "-s", zsig, "-C"]
|
||||||
cc_list.extend([user["email"].replace("@mit.edu", "")
|
zwrite_args.extend([user["email"].replace("@mit.edu", "")
|
||||||
for user in message["display_recipient"]])
|
for user in message["display_recipient"]])
|
||||||
body = "%s\0%s\n%s" % (zsig, " ".join(cc_list), wrapped_content)
|
|
||||||
for r in message["display_recipient"]:
|
p = subprocess.Popen(zwrite_args, stdin=subprocess.PIPE,
|
||||||
recipient = r["email"].replace("mit.edu", "ATHENA.MIT.EDU")
|
stdout=subprocess.PIPE)
|
||||||
zeph = zephyr.ZNotice(sender=sender_email, auth=True,
|
p.communicate(input=wrapped_content)
|
||||||
recipient=recipient, cls="message",
|
|
||||||
instance="personal")
|
|
||||||
zeph.setmessage(body)
|
|
||||||
zeph.send()
|
|
||||||
|
|
||||||
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":
|
||||||
|
@ -557,8 +544,6 @@ for pid in out.split():
|
||||||
child_pid = os.fork()
|
child_pid = os.fork()
|
||||||
if child_pid == 0:
|
if child_pid == 0:
|
||||||
# Run the humbug => zephyr mirror in the child
|
# Run the humbug => zephyr mirror in the child
|
||||||
import zephyr
|
|
||||||
zephyr.init()
|
|
||||||
humbug_to_zephyr(options)
|
humbug_to_zephyr(options)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue