Skip to content

Commit a29e197

Browse files
authored
Merge pull request #60 from amyxzhang/emailhosts
Add support for both hostnames
2 parents 6889497 + ca49a51 commit a29e197

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

engine/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ def group_by_thread(posts_list):
17131713
else:
17141714
sender = p['from']
17151715
if not isinstance(sender, unicode):
1716-
sender = unicode(name, 'utf-8', 'ignore')
1716+
sender = unicode(sender, 'utf-8', 'ignore')
17171717

17181718
senders.add(sender)
17191719

http_handler/settings.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,17 @@ def _get_website():
5555
print "Unable to open configuration file!"
5656

5757
if ENV == 'prod':
58-
BASE_URL = 'squadbox.csail.mit.edu'
58+
BASE_URL = 'squadbox.org'
5959
MYSQL = MYSQL_PROD
60+
HOST_REGEX = 'squadbox.org|squadbox.csail.mit.edu'
6061
elif ENV == 'staging':
6162
BASE_URL = 'murmur-dev.csail.mit.edu'
6263
MYSQL = MYSQL_DEV
64+
HOST_REGEX = BASE_URL
6365
else:
6466
BASE_URL = 'localhost:8000'
6567
MYSQL = MYSQL_LOCAL
68+
HOST_REGEX = BASE_URL
6669

6770
TEMPLATE_DEBUG = DEBUG
6871

smtp_handler/main.py

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging, time, base64
22
from lamson.routing import route, stateless
33
from config.settings import relay
4-
from http_handler.settings import WEBSITE
4+
from http_handler.settings import WEBSITE, HOST_REGEX
55
from schema.models import *
66
from lamson.mail import MailResponse
77
from email.utils import *
@@ -23,7 +23,7 @@
2323

2424
GROUP_OR_SQUAD = {'murmur' : 'group', 'squadbox' : 'squad'}
2525

26-
@route("(address)@(host)", address="all", host=HOST)
26+
@route("(address)@(host)", address="all", host=HOST_REGEX)
2727
@stateless
2828
def all(message, address=None, host=None):
2929
# no public groups to list on squadbox.
@@ -45,7 +45,7 @@ def all(message, address=None, host=None):
4545
relay.deliver(mail)
4646

4747

48-
@route("(group_name)\\+create@(host)", group_name=".+", host=HOST)
48+
@route("(group_name)\\+create@(host)", group_name=".+", host=HOST_REGEX)
4949
@stateless
5050
def create(message, group_name=None, host=None):
5151
# at least for now, for now we don't need this
@@ -66,7 +66,7 @@ def create(message, group_name=None, host=None):
6666
relay.deliver(mail)
6767

6868

69-
@route("(group_name)\\+activate@(host)", group_name=".+", host=HOST)
69+
@route("(group_name)\\+activate@(host)", group_name=".+", host=HOST_REGEX)
7070
@stateless
7171
def activate(message, group_name=None, host=None):
7272

@@ -86,7 +86,7 @@ def activate(message, group_name=None, host=None):
8686
mail = MailResponse(From = NO_REPLY, To = message['From'], Subject = subject, Body = body)
8787
relay.deliver(mail)
8888

89-
@route("(group_name)\\+deactivate@(host)", group_name=".+", host=HOST)
89+
@route("(group_name)\\+deactivate@(host)", group_name=".+", host=HOST_REGEX)
9090
@stateless
9191
def deactivate(message, group_name=None, host=None):
9292

@@ -108,7 +108,7 @@ def deactivate(message, group_name=None, host=None):
108108

109109

110110
# A route to provide a contact email address for a group's administrator(s)
111-
@route("(group_name)\\+admins@(host)", group_name=".+", host=HOST)
111+
@route("(group_name)\\+admins@(host)", group_name=".+", host=HOST_REGEX)
112112
@stateless
113113
def admins(message, group_name=None, host=None):
114114

@@ -155,7 +155,7 @@ def admins(message, group_name=None, host=None):
155155
return
156156

157157

158-
@route("(group_name)\\+subscribe@(host)", group_name=".+", host=HOST)
158+
@route("(group_name)\\+subscribe@(host)", group_name=".+", host=HOST_REGEX)
159159
@stateless
160160
def subscribe(message, group_name=None, host=None):
161161

@@ -201,7 +201,7 @@ def subscribe(message, group_name=None, host=None):
201201
relay.deliver(mail)
202202

203203

204-
@route("(group_name)\\+unsubscribe@(host)", group_name=".+", host=HOST)
204+
@route("(group_name)\\+unsubscribe@(host)", group_name=".+", host=HOST_REGEX)
205205
@stateless
206206
def unsubscribe(message, group_name=None, host=None):
207207

@@ -236,7 +236,7 @@ def unsubscribe(message, group_name=None, host=None):
236236
relay.deliver(mail)
237237

238238

239-
@route("(group_name)\\+info@(host)", group_name=".+", host=HOST)
239+
@route("(group_name)\\+info@(host)", group_name=".+", host=HOST_REGEX)
240240
@stateless
241241
def info(message, group_name=None, host=None):
242242

@@ -650,7 +650,7 @@ def handle_post_squadbox(message, group, host, verified):
650650
'squadbox' : handle_post_squadbox,
651651
}
652652

653-
@route("(address)@(host)", address=".+", host=HOST)
653+
@route("(address)@(host)", address=".+", host=HOST_REGEX)
654654
@stateless
655655
def handle_post(message, address=None, host=None):
656656

@@ -694,7 +694,7 @@ def handle_post(message, address=None, host=None):
694694
handler_funcs[WEBSITE](message, group, host, verified)
695695

696696

697-
@route("(group_name)\\+(thread_id)(suffix)@(host)", group_name=".+", thread_id=".+", suffix=FOLLOW_SUFFIX+"|"+FOLLOW_SUFFIX.upper(), host=HOST)
697+
@route("(group_name)\\+(thread_id)(suffix)@(host)", group_name=".+", thread_id=".+", suffix=FOLLOW_SUFFIX+"|"+FOLLOW_SUFFIX.upper(), host=HOST_REGEX)
698698
@stateless
699699
def handle_follow(message, group_name=None, thread_id=None, suffix=None, host=None):
700700

@@ -714,7 +714,7 @@ def handle_follow(message, group_name=None, thread_id=None, suffix=None, host=No
714714
relay.deliver(mail)
715715

716716

717-
@route("(group_name)\\+(thread_id)(suffix)@(host)", group_name=".+", thread_id=".+", suffix=UNFOLLOW_SUFFIX+"|"+UNFOLLOW_SUFFIX.upper(), host=HOST)
717+
@route("(group_name)\\+(thread_id)(suffix)@(host)", group_name=".+", thread_id=".+", suffix=UNFOLLOW_SUFFIX+"|"+UNFOLLOW_SUFFIX.upper(), host=HOST_REGEX)
718718
@stateless
719719
def handle_unfollow(message, group_name=None, thread_id=None, suffix=None, host=None):
720720

@@ -735,7 +735,7 @@ def handle_unfollow(message, group_name=None, thread_id=None, suffix=None, host=
735735
relay.deliver(mail)
736736

737737

738-
@route("(group_name)\\+(thread_id)(suffix)@(host)", group_name=".+", thread_id=".+", suffix=MUTE_SUFFIX+"|"+MUTE_SUFFIX.upper(), host=HOST)
738+
@route("(group_name)\\+(thread_id)(suffix)@(host)", group_name=".+", thread_id=".+", suffix=MUTE_SUFFIX+"|"+MUTE_SUFFIX.upper(), host=HOST_REGEX)
739739
@stateless
740740
def handle_mute(message, group_name=None, thread_id=None, suffix=None, host=None):
741741

@@ -755,7 +755,7 @@ def handle_mute(message, group_name=None, thread_id=None, suffix=None, host=None
755755
relay.deliver(mail)
756756

757757

758-
@route("(group_name)\\+(thread_id)(suffix)@(host)", group_name=".+", thread_id=".+", suffix=UNMUTE_SUFFIX+"|"+UNMUTE_SUFFIX.upper(), host=HOST)
758+
@route("(group_name)\\+(thread_id)(suffix)@(host)", group_name=".+", thread_id=".+", suffix=UNMUTE_SUFFIX+"|"+UNMUTE_SUFFIX.upper(), host=HOST_REGEX)
759759
@stateless
760760
def handle_unmute(message, group_name=None, thread_id=None, suffix=None, host=None):
761761

@@ -775,7 +775,7 @@ def handle_unmute(message, group_name=None, thread_id=None, suffix=None, host=No
775775
relay.deliver(mail)
776776

777777

778-
@route("(group_name)\\+(tag_name)(suffix)@(host)", group_name=".+", tag_name=".+", suffix=FOLLOW_TAG_SUFFIX+"|"+FOLLOW_TAG_SUFFIX.upper(), host=HOST)
778+
@route("(group_name)\\+(tag_name)(suffix)@(host)", group_name=".+", tag_name=".+", suffix=FOLLOW_TAG_SUFFIX+"|"+FOLLOW_TAG_SUFFIX.upper(), host=HOST_REGEX)
779779
@stateless
780780
def handle_follow_tag(message, group_name=None, tag_name=None, suffix=None, host=None):
781781

@@ -795,7 +795,7 @@ def handle_follow_tag(message, group_name=None, tag_name=None, suffix=None, host
795795
relay.deliver(mail)
796796

797797

798-
@route("(group_name)\\+(tag_name)(suffix)@(host)", group_name=".+", tag_name=".+", suffix=UNFOLLOW_TAG_SUFFIX+"|"+UNFOLLOW_TAG_SUFFIX.upper(), host=HOST)
798+
@route("(group_name)\\+(tag_name)(suffix)@(host)", group_name=".+", tag_name=".+", suffix=UNFOLLOW_TAG_SUFFIX+"|"+UNFOLLOW_TAG_SUFFIX.upper(), host=HOST_REGEX)
799799
@stateless
800800
def handle_unfollow_tag(message, group_name=None, tag_name=None, suffix=None, host=None):
801801

@@ -816,7 +816,7 @@ def handle_unfollow_tag(message, group_name=None, tag_name=None, suffix=None, ho
816816
relay.deliver(mail)
817817

818818

819-
@route("(group_name)\\+(tag_name)(suffix)@(host)", group_name=".+", tag_name=".+", suffix=MUTE_TAG_SUFFIX+"|"+MUTE_TAG_SUFFIX.upper(), host=HOST)
819+
@route("(group_name)\\+(tag_name)(suffix)@(host)", group_name=".+", tag_name=".+", suffix=MUTE_TAG_SUFFIX+"|"+MUTE_TAG_SUFFIX.upper(), host=HOST_REGEX)
820820
@stateless
821821
def handle_mute_tag(message, group_name=None, tag_name=None, suffix=None, host=None):
822822

@@ -836,7 +836,7 @@ def handle_mute_tag(message, group_name=None, tag_name=None, suffix=None, host=N
836836
relay.deliver(mail)
837837

838838

839-
@route("(group_name)\\+(tag_name)(suffix)@(host)", group_name=".+", tag_name=".+", suffix=UNMUTE_TAG_SUFFIX+"|"+UNMUTE_TAG_SUFFIX.upper(), host=HOST)
839+
@route("(group_name)\\+(tag_name)(suffix)@(host)", group_name=".+", tag_name=".+", suffix=UNMUTE_TAG_SUFFIX+"|"+UNMUTE_TAG_SUFFIX.upper(), host=HOST_REGEX)
840840
@stateless
841841
def handle_unmute_tag(message, group_name=None, tag_name=None, suffix=None, host=None):
842842

@@ -856,7 +856,7 @@ def handle_unmute_tag(message, group_name=None, tag_name=None, suffix=None, host
856856
relay.deliver(mail)
857857

858858

859-
@route("(group_name)\\+(post_id)(suffix)@(host)", group_name=".+", post_id=".+", suffix=UPVOTE_SUFFIX+"|"+UPVOTE_SUFFIX.upper(), host=HOST)
859+
@route("(group_name)\\+(post_id)(suffix)@(host)", group_name=".+", post_id=".+", suffix=UPVOTE_SUFFIX+"|"+UPVOTE_SUFFIX.upper(), host=HOST_REGEX)
860860
@stateless
861861
def handle_upvote(message, group_name=None, post_id=None, suffix=None, host=None):
862862

@@ -878,7 +878,7 @@ def handle_upvote(message, group_name=None, post_id=None, suffix=None, host=None
878878
mail = MailResponse(From = NO_REPLY, To = addr, Subject = subject, Body = body)
879879
relay.deliver(mail)
880880

881-
@route("(address)@(host)", address="help", host=HOST)
881+
@route("(address)@(host)", address="help", host=HOST_REGEX)
882882
@stateless
883883
def help(message, address=None, host=None):
884884

0 commit comments

Comments
 (0)