Skip to content

Commit

Permalink
smtp fix tag referencing
Browse files Browse the repository at this point in the history
  • Loading branch information
soyapark committed Jan 27, 2021
1 parent 23a441d commit 6bec739
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
12 changes: 9 additions & 3 deletions smtp_handler/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import logging, time, base64
import logging, time, base64, sys, traceback
from lamson.routing import route, stateless
from config.settings import relay
from http_handler.settings import WEBSITE
Expand Down Expand Up @@ -484,7 +484,10 @@ def handle_post_murmur(message, group, host, verified):

except Exception, e:
logger.debug(e)
send_error_email(group.name, e, None, ADMIN_EMAILS)
exc_type, exc_obj, exc_tb = sys.exc_info()
err_msg = "%s %s %s" % (exc_type, exc_tb.tb_lineno, str(e))

send_error_email(group.name, err_msg, None, ADMIN_EMAILS)

# try to deliver mail even without footers
mail.Html = msg_text['html']
Expand All @@ -493,7 +496,10 @@ def handle_post_murmur(message, group, host, verified):

except Exception, e:
logger.debug(e)
send_error_email(group.name, e, None, ADMIN_EMAILS)
exc_type, exc_obj, exc_tb = sys.exc_info()
err_msg = "%s %s %s" % (exc_type, exc_tb.tb_lineno, str(e))

send_error_email(group.name, err_msg, None, ADMIN_EMAILS)
return

def handle_post_squadbox(message, group, host, verified):
Expand Down
36 changes: 18 additions & 18 deletions smtp_handler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,9 @@ def _insert_plain_tag_line(group, tags, membergroup, tag_following, tag_muting):
if membergroup.no_emails or not membergroup.always_follow_thread:
follow_tags = []
for f in tag_following:
follow_tags.append(f.tag.name)
unfollow_tag_email = 'mailto:%s' % (group.name + '+' + f.tag.name + UNFOLLOW_TAG_SUFFIX + '@' + HOST)
tag_str += 'Unfollow %s<%s> | ' % (f.tag.name, unfollow_tag_email)
follow_tags.append(f.name)
unfollow_tag_email = 'mailto:%s' % (group.name + '+' + f.name + UNFOLLOW_TAG_SUFFIX + '@' + HOST)
tag_str += 'Unfollow %s<%s> | ' % (f.name, unfollow_tag_email)

for tag in tags:
if tag.name not in follow_tags:
Expand All @@ -355,9 +355,9 @@ def _insert_plain_tag_line(group, tags, membergroup, tag_following, tag_muting):
else:
mute_tags = []
for f in tag_muting:
mute_tags.append(f.tag.name)
unmute_tag_email = 'mailto:%s' % (group.name + '+' + f.tag.name + UNMUTE_TAG_SUFFIX + '@' + HOST)
tag_str += 'Unmute %s<%s> | ' % (f.tag.name, unmute_tag_email)
mute_tags.append(f.name)
unmute_tag_email = 'mailto:%s' % (group.name + '+' + f.name + UNMUTE_TAG_SUFFIX + '@' + HOST)
tag_str += 'Unmute %s<%s> | ' % (f.name, unmute_tag_email)

for tag in tags:
if tag.name not in mute_tags:
Expand All @@ -374,17 +374,17 @@ def _insert_tag_line(group, tags, membergroup, tag_following, tag_muting):
if membergroup.no_emails or not membergroup.always_follow_thread:
follow_tags = []
for f in tag_following:
follow_tags.append(f.tag.name)
tag_str += '<a href="%s%s&group=%s">Unfollow %s</a> | ' % (UNFOLLOW_TAG_ADDR, f.tag.name, group.name, f.tag.name)
follow_tags.append(f.name)
tag_str += '<a href="%s%s&group=%s">Unfollow %s</a> | ' % (UNFOLLOW_TAG_ADDR, f.name, group.name, f.name)

for tag in tags:
if tag.name not in follow_tags:
tag_str += ' <a href="%s%s&group=%s">Follow %s</a> |' % (FOLLOW_TAG_ADDR, tag.name, group.name, tag.name)
else:
mute_tags = []
for f in tag_muting:
mute_tags.append(f.tag.name)
tag_str += '<a href="%s%s&group=%s">Unmute %s</a> | ' % (UNMUTE_TAG_ADDR, f.tag.name, group.name, f.tag.name)
mute_tags.append(f.name)
tag_str += '<a href="%s%s&group=%s">Unmute %s</a> | ' % (UNMUTE_TAG_ADDR, f.name, group.name, f.name)

for tag in tags:
if tag.name not in mute_tags:
Expand Down Expand Up @@ -478,12 +478,12 @@ def html_ps(group, thread, post_id, membergroup, following, muting, tag_followin
content += 'You\'re currently following this thread. <a href="%s">Un-Follow thread</a>.<BR>' % (unfollow_addr)
else:
if tag_following.count() > 0:
tag_names = [f.tag.name for f in tag_following]
tag_names = [f.name for f in tag_following]
if len(tag_names) > 1:
n_str = ', '.join(tag_names)
content += 'You\'re currently following the tags %s. <BR>' % (n_str)
content += 'You\'re currently following the tags: %s. <BR>' % (n_str)
else:
content += 'You\'re currently following the tag %s. <BR>' % (tag_names[0])
content += 'You\'re currently following the tag: %s. <BR>' % (tag_names[0])
else:
content += 'You currently aren\'t receiving any replies to this thread. <a href="%s">Follow thread</a>.<BR>' % (follow_addr)
else:
Expand All @@ -493,12 +493,12 @@ def html_ps(group, thread, post_id, membergroup, following, muting, tag_followin
content += 'You\'re currently muting this thread. <a href="%s">Un-Mute thread</a>.<BR>' % (unmute_addr)
else:
if tag_muting.count() > 0:
tag_names = [f.tag.name for f in tag_muting]
tag_names = [f.name for f in tag_muting]
if len(tag_names) > 1:
n_str = ', '.join(tag_names)
content += 'You\'re currently muting the tags %s. <BR>' % (n_str)
content += 'You\'re currently muting the tags: %s. <BR>' % (n_str)
else:
content += 'You\'re currently muting the tag %s. <BR>' % (tag_names[0])
content += 'You\'re currently muting the tag: %s. <BR>' % (tag_names[0])
else:
content += 'You\'re currently receiving emails to this thread. <a href="%s">Mute thread</a>.<BR>' % (mute_addr)

Expand Down Expand Up @@ -543,7 +543,7 @@ def plain_ps(group, thread, post_id, membergroup, following, muting, tag_followi
content += 'You\'re currently following this thread. Un-Follow thread<%s>.\n' % (unfollow_addr)
else:
if tag_following.count() > 0:
tag_names = [m.tag.name for m in tag_muting]
tag_names = [m.name for m in tag_muting]
if len(tag_names) > 1:
n_str = ', '.join(tag_names)
content += 'You\'re currently following the tags %s. \n' % (n_str)
Expand All @@ -559,7 +559,7 @@ def plain_ps(group, thread, post_id, membergroup, following, muting, tag_followi
content += 'You\'re currently muting this thread. Un-Mute thread<%s>.\n' % (unmute_addr)
else:
if tag_muting.count() > 0:
tag_names = [m.tag.name for m in tag_muting]
tag_names = [m.name for m in tag_muting]
if len(tag_names) > 1:
n_str = ', '.join(tag_names)
content += 'You\'re currently muting the tags %s. \n' % (n_str)
Expand Down

0 comments on commit 6bec739

Please sign in to comment.