zephyr_mirror.py: Clean up duplicated lower-casing code.
(imported from commit 2357202a4d8e0780cda3329f2e86d25b7596afbf)
This commit is contained in:
parent
077d662b14
commit
e718d31cd6
|
@ -197,9 +197,10 @@ def process_notice(notice, log):
|
||||||
|
|
||||||
sender = notice.sender.lower().replace("athena.mit.edu", "mit.edu")
|
sender = notice.sender.lower().replace("athena.mit.edu", "mit.edu")
|
||||||
recipient = notice.recipient.lower().replace("athena.mit.edu", "mit.edu")
|
recipient = notice.recipient.lower().replace("athena.mit.edu", "mit.edu")
|
||||||
|
zephyr_class = notice.cls.lower()
|
||||||
|
instance = notice.instance.lower()
|
||||||
|
|
||||||
if (notice.cls.lower() == "message" and
|
if (zephyr_class == "message" and instance == "personal"):
|
||||||
notice.instance.lower() == "personal"):
|
|
||||||
is_personal = True
|
is_personal = True
|
||||||
if body.startswith("CC:"):
|
if body.startswith("CC:"):
|
||||||
is_huddle = True
|
is_huddle = True
|
||||||
|
@ -209,15 +210,14 @@ def process_notice(notice, log):
|
||||||
if sender not in huddle_recipients_list:
|
if sender not in huddle_recipients_list:
|
||||||
huddle_recipients_list.append(sender)
|
huddle_recipients_list.append(sender)
|
||||||
huddle_recipients = ",".join(huddle_recipients_list)
|
huddle_recipients = ",".join(huddle_recipients_list)
|
||||||
if (notice.cls.lower() == "mail" and
|
if (zephyr_class == "mail" and instance == "inbox"):
|
||||||
notice.instance.lower() == "inbox"):
|
|
||||||
is_personal = True
|
is_personal = True
|
||||||
|
|
||||||
# Drop messages not to the listed subscriptions
|
# Drop messages not to the listed subscriptions
|
||||||
if (notice.cls.lower() not in current_zephyr_subs) and not \
|
if (zephyr_class not in current_zephyr_subs) and not \
|
||||||
(is_personal and options.forward_personals):
|
(is_personal and options.forward_personals):
|
||||||
print "%s: zephyr=>humbug: Skipping ... %s/%s/%s" % \
|
print "%s: zephyr=>humbug: Skipping ... %s/%s/%s" % \
|
||||||
(datetime.datetime.now(), notice.cls, notice.instance, is_personal)
|
(datetime.datetime.now(), zephyr_class, instance, is_personal)
|
||||||
return
|
return
|
||||||
|
|
||||||
if is_huddle:
|
if is_huddle:
|
||||||
|
@ -238,14 +238,13 @@ def process_notice(notice, log):
|
||||||
zeph = { 'type' : 'stream',
|
zeph = { 'type' : 'stream',
|
||||||
'time' : str(notice.time),
|
'time' : str(notice.time),
|
||||||
'sender' : sender,
|
'sender' : sender,
|
||||||
'stream' : notice.cls.lower(),
|
'stream' : zephyr_class,
|
||||||
'subject' : notice.instance.lower(),
|
'subject' : instance,
|
||||||
'zsig' : zsig, # logged here but not used by app
|
'zsig' : zsig, # logged here but not used by app
|
||||||
'content' : body }
|
'content' : body }
|
||||||
|
|
||||||
print "%s: zephyr=>humbug: received a message on %s/%s from %s..." % \
|
print "%s: zephyr=>humbug: received a message on %s/%s from %s..." % \
|
||||||
(datetime.datetime.now(), notice.cls, notice.instance,
|
(datetime.datetime.now(), zephyr_class, instance, notice.sender)
|
||||||
notice.sender)
|
|
||||||
log.write(simplejson.dumps(zeph) + '\n')
|
log.write(simplejson.dumps(zeph) + '\n')
|
||||||
log.flush()
|
log.flush()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue