1
1
import logging , time , base64
2
2
from lamson .routing import route , stateless
3
3
from config .settings import relay
4
- from http_handler .settings import WEBSITE
4
+ from http_handler .settings import WEBSITE , HOST_REGEX
5
5
from schema .models import *
6
6
from lamson .mail import MailResponse
7
7
from email .utils import *
23
23
24
24
GROUP_OR_SQUAD = {'murmur' : 'group' , 'squadbox' : 'squad' }
25
25
26
- @route ("(address)@(host)" , address = "all" , host = HOST )
26
+ @route ("(address)@(host)" , address = "all" , host = HOST_REGEX )
27
27
@stateless
28
28
def all (message , address = None , host = None ):
29
29
# no public groups to list on squadbox.
@@ -45,7 +45,7 @@ def all(message, address=None, host=None):
45
45
relay .deliver (mail )
46
46
47
47
48
- @route ("(group_name)\\ +create@(host)" , group_name = ".+" , host = HOST )
48
+ @route ("(group_name)\\ +create@(host)" , group_name = ".+" , host = HOST_REGEX )
49
49
@stateless
50
50
def create (message , group_name = None , host = None ):
51
51
# at least for now, for now we don't need this
@@ -66,7 +66,7 @@ def create(message, group_name=None, host=None):
66
66
relay .deliver (mail )
67
67
68
68
69
- @route ("(group_name)\\ +activate@(host)" , group_name = ".+" , host = HOST )
69
+ @route ("(group_name)\\ +activate@(host)" , group_name = ".+" , host = HOST_REGEX )
70
70
@stateless
71
71
def activate (message , group_name = None , host = None ):
72
72
@@ -86,7 +86,7 @@ def activate(message, group_name=None, host=None):
86
86
mail = MailResponse (From = NO_REPLY , To = message ['From' ], Subject = subject , Body = body )
87
87
relay .deliver (mail )
88
88
89
- @route ("(group_name)\\ +deactivate@(host)" , group_name = ".+" , host = HOST )
89
+ @route ("(group_name)\\ +deactivate@(host)" , group_name = ".+" , host = HOST_REGEX )
90
90
@stateless
91
91
def deactivate (message , group_name = None , host = None ):
92
92
@@ -108,7 +108,7 @@ def deactivate(message, group_name=None, host=None):
108
108
109
109
110
110
# 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 )
112
112
@stateless
113
113
def admins (message , group_name = None , host = None ):
114
114
@@ -155,7 +155,7 @@ def admins(message, group_name=None, host=None):
155
155
return
156
156
157
157
158
- @route ("(group_name)\\ +subscribe@(host)" , group_name = ".+" , host = HOST )
158
+ @route ("(group_name)\\ +subscribe@(host)" , group_name = ".+" , host = HOST_REGEX )
159
159
@stateless
160
160
def subscribe (message , group_name = None , host = None ):
161
161
@@ -201,7 +201,7 @@ def subscribe(message, group_name=None, host=None):
201
201
relay .deliver (mail )
202
202
203
203
204
- @route ("(group_name)\\ +unsubscribe@(host)" , group_name = ".+" , host = HOST )
204
+ @route ("(group_name)\\ +unsubscribe@(host)" , group_name = ".+" , host = HOST_REGEX )
205
205
@stateless
206
206
def unsubscribe (message , group_name = None , host = None ):
207
207
@@ -236,7 +236,7 @@ def unsubscribe(message, group_name=None, host=None):
236
236
relay .deliver (mail )
237
237
238
238
239
- @route ("(group_name)\\ +info@(host)" , group_name = ".+" , host = HOST )
239
+ @route ("(group_name)\\ +info@(host)" , group_name = ".+" , host = HOST_REGEX )
240
240
@stateless
241
241
def info (message , group_name = None , host = None ):
242
242
@@ -650,7 +650,7 @@ def handle_post_squadbox(message, group, host, verified):
650
650
'squadbox' : handle_post_squadbox ,
651
651
}
652
652
653
- @route ("(address)@(host)" , address = ".+" , host = HOST )
653
+ @route ("(address)@(host)" , address = ".+" , host = HOST_REGEX )
654
654
@stateless
655
655
def handle_post (message , address = None , host = None ):
656
656
@@ -694,7 +694,7 @@ def handle_post(message, address=None, host=None):
694
694
handler_funcs [WEBSITE ](message , group , host , verified )
695
695
696
696
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 )
698
698
@stateless
699
699
def handle_follow (message , group_name = None , thread_id = None , suffix = None , host = None ):
700
700
@@ -714,7 +714,7 @@ def handle_follow(message, group_name=None, thread_id=None, suffix=None, host=No
714
714
relay .deliver (mail )
715
715
716
716
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 )
718
718
@stateless
719
719
def handle_unfollow (message , group_name = None , thread_id = None , suffix = None , host = None ):
720
720
@@ -735,7 +735,7 @@ def handle_unfollow(message, group_name=None, thread_id=None, suffix=None, host=
735
735
relay .deliver (mail )
736
736
737
737
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 )
739
739
@stateless
740
740
def handle_mute (message , group_name = None , thread_id = None , suffix = None , host = None ):
741
741
@@ -755,7 +755,7 @@ def handle_mute(message, group_name=None, thread_id=None, suffix=None, host=None
755
755
relay .deliver (mail )
756
756
757
757
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 )
759
759
@stateless
760
760
def handle_unmute (message , group_name = None , thread_id = None , suffix = None , host = None ):
761
761
@@ -775,7 +775,7 @@ def handle_unmute(message, group_name=None, thread_id=None, suffix=None, host=No
775
775
relay .deliver (mail )
776
776
777
777
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 )
779
779
@stateless
780
780
def handle_follow_tag (message , group_name = None , tag_name = None , suffix = None , host = None ):
781
781
@@ -795,7 +795,7 @@ def handle_follow_tag(message, group_name=None, tag_name=None, suffix=None, host
795
795
relay .deliver (mail )
796
796
797
797
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 )
799
799
@stateless
800
800
def handle_unfollow_tag (message , group_name = None , tag_name = None , suffix = None , host = None ):
801
801
@@ -816,7 +816,7 @@ def handle_unfollow_tag(message, group_name=None, tag_name=None, suffix=None, ho
816
816
relay .deliver (mail )
817
817
818
818
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 )
820
820
@stateless
821
821
def handle_mute_tag (message , group_name = None , tag_name = None , suffix = None , host = None ):
822
822
@@ -836,7 +836,7 @@ def handle_mute_tag(message, group_name=None, tag_name=None, suffix=None, host=N
836
836
relay .deliver (mail )
837
837
838
838
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 )
840
840
@stateless
841
841
def handle_unmute_tag (message , group_name = None , tag_name = None , suffix = None , host = None ):
842
842
@@ -856,7 +856,7 @@ def handle_unmute_tag(message, group_name=None, tag_name=None, suffix=None, host
856
856
relay .deliver (mail )
857
857
858
858
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 )
860
860
@stateless
861
861
def handle_upvote (message , group_name = None , post_id = None , suffix = None , host = None ):
862
862
@@ -878,7 +878,7 @@ def handle_upvote(message, group_name=None, post_id=None, suffix=None, host=None
878
878
mail = MailResponse (From = NO_REPLY , To = addr , Subject = subject , Body = body )
879
879
relay .deliver (mail )
880
880
881
- @route ("(address)@(host)" , address = "help" , host = HOST )
881
+ @route ("(address)@(host)" , address = "help" , host = HOST_REGEX )
882
882
@stateless
883
883
def help (message , address = None , host = None ):
884
884
0 commit comments