GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit 61afa2c5 authored by Cecylia Bocovich's avatar Cecylia Bocovich

Always reply to gettor emails

This fixes a bug where improperly formatted emails were not receiving
gettor replies. We should always reply to emails and default to sending
a help message if the request was invalid.

This also prioritizes sending links if both a valid links request and
the word help were sent. Several tests were added.
parent 64df8b27
......@@ -127,9 +127,8 @@ class EmailParser(object):
if word.lower() in self.platforms:
request["command"] = "links"
request["platform"] = word.lower()
if word.lower() == "help":
if (not request["command"]) and word.lower() == "help":
request["command"] = "help"
break
return request
def build_request(self, msg_str, norm_addr):
......@@ -155,6 +154,9 @@ class EmailParser(object):
if not request["language"]:
request["language"] = "en-US"
if not request["command"]:
request["command"] = "help"
return request
......
......@@ -88,6 +88,41 @@ class EmailServiceTests(unittest.TestCase):
self.assertEqual(check, False)
del ep
def test_email_parser(self):
ep = conftests.EmailParser(self.settings, "gettor@torproject.org")
ep.locales = ["en-US", "es-ES", "es-AR", "pt-BR", "fa"]
request = ep.parse("From: \"silvia [hiro]\" <hiro@torproject.org>\n"
"Subject: \r\n Reply-To: hiro@torproject.org \nTo:"
"gettor@torproject.org\n\n")
self.assertEqual(request["language"], "en-US")
self.assertEqual(request["command"], "help")
request = ep.parse("From: \"silvia [hiro]\" <hiro@torproject.org>\n"
"Subject: \r\n Reply-To: hiro@torproject.org \nTo:"
"gettor@torproject.org\n\n please send me tor\n")
self.assertEqual(request["language"], "en-US")
self.assertEqual(request["command"], "help")
request = ep.parse("From: \"silvia [hiro]\" <hiro@torproject.org>\n"
"Subject: \r\n Reply-To: hiro@torproject.org \nTo:"
"gettor@torproject.org\n\nwindows\n")
self.assertEqual(request["language"], "en-US")
self.assertEqual(request["platform"], "windows")
self.assertEqual(request["command"], "links")
request = ep.parse("From: \"silvia [hiro]\" <hiro@torproject.org>\n"
"Subject: \r\n Reply-To: hiro@torproject.org \nTo:"
"gettor@torproject.org\n\n fa\n")
self.assertEqual(request["language"], "fa")
self.assertEqual(request["command"], "help")
request = ep.parse("From: \"silvia [hiro]\" <hiro@torproject.org>\n"
"Subject: \r\n Reply-To: hiro@torproject.org \nTo:"
"gettor@torproject.org\n\n please help me get tor for windows\n")
self.assertEqual(request["language"], "en-US")
self.assertEqual(request["command"], "links")
self.assertEqual(request["platform"], "windows")
def test_language_email_parser(self):
ep = conftests.EmailParser(self.settings, "gettor@torproject.org")
ep.locales = ["en-US", "es-ES", "es-AR", "pt-BR", "fa"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment