zephyr_mirror: Support whitespace-only zephyr instances.
Previously messages sent to zephyr instance " " wouldn't be forwarded zephyr=>humbug because the target instance is the null instance; I learned this when we got a few tracebacks in the zephyr_mirror log, so clearly this does happen. (imported from commit 08bd7470e75ac6af24ac83696b6cf68d70654664)
This commit is contained in:
parent
2735c8410e
commit
c38587191e
|
@ -263,10 +263,10 @@ def process_notice(notice, log):
|
||||||
else:
|
else:
|
||||||
zeph['type'] = 'stream'
|
zeph['type'] = 'stream'
|
||||||
zeph['stream'] = zephyr_class
|
zeph['stream'] = zephyr_class
|
||||||
if notice.instance != "":
|
if notice.instance.strip() != "":
|
||||||
zeph['subject'] = notice.instance
|
zeph['subject'] = notice.instance
|
||||||
else:
|
else:
|
||||||
zeph["subject"] = "(no instance)"
|
zeph["subject"] = '(instance "%s")' % (notice.instance,)
|
||||||
|
|
||||||
# Add instances in for instanced personals
|
# Add instances in for instanced personals
|
||||||
if zeph['type'] == "personal" and notice.instance.lower() != "personal":
|
if zeph['type'] == "personal" and notice.instance.lower() != "personal":
|
||||||
|
@ -367,11 +367,13 @@ def forward_to_zephyr(message):
|
||||||
if message['type'] == "stream":
|
if message['type'] == "stream":
|
||||||
zephyr_class = message["display_recipient"]
|
zephyr_class = message["display_recipient"]
|
||||||
instance = message["subject"]
|
instance = message["subject"]
|
||||||
if instance == "(no instance)":
|
|
||||||
# Forward messages sent to "(no instance)" back to the
|
match_whitespace_instance = re.match(r'^\(instance "(\s*)"\)$', instance)
|
||||||
# empty instance for bidirectional mirroring
|
if match_whitespace_instance:
|
||||||
instance = ""
|
# Forward messages sent to '(instance "WHITESPACE")' back to the
|
||||||
if (instance == "instance %s" % (zephyr_class,) or
|
# appropriate WHITESPACE instance for bidirectional mirroring
|
||||||
|
instance = match_whitespace_instance.group(1)
|
||||||
|
elif (instance == "instance %s" % (zephyr_class,) or
|
||||||
instance == "test instance %s" % (zephyr_class,)):
|
instance == "test instance %s" % (zephyr_class,)):
|
||||||
# Forward messages to e.g. -c -i white-magic back from the
|
# Forward messages to e.g. -c -i white-magic back from the
|
||||||
# place we forward them to
|
# place we forward them to
|
||||||
|
|
Loading…
Reference in a new issue