commit 983dbbd6cbdeab7d179e65411f072a27f30730bf Author: hiro hiro@torproject.org Date: Wed Oct 16 12:53:15 2019 +0200
Fix bug in email and twitter parser --- gettor/parse/email.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/gettor/parse/email.py b/gettor/parse/email.py index 5abf856..fdeefba 100644 --- a/gettor/parse/email.py +++ b/gettor/parse/email.py @@ -150,6 +150,24 @@ class EmailParser(object):
return request
+ + def check_num_requests(self, request_id, hid, request_service, limit): + # check limit first + num_requests = limit + + if hid.hexdigest() == self.settings.get('test_hid'): + num_requests = 1 + else: + num_requests = yield conn.get_num_requests( + id=hid.hexdigest(), service=request_service + ) + + if num_requests[0][0] < email_requests_limit: + return 1 + else: + return 0 + + def parse(self, msg_str): """ Parse message content. Check if email address is well formed, if DKIM @@ -198,23 +216,6 @@ class EmailParser(object): return request
- def check_num_requests(self, request_id, hid, request_service, limit): - # check limit first - num_requests = limit - - if hid.hexdigest() == self.settings.get('test_hid'): - num_requests = 1 - else: - num_requests = yield conn.get_num_requests( - id=hid.hexdigest(), service=request_service - ) - - if num_requests[0][0] < email_requests_limit: - return 1 - else: - return 0 - - @defer.inlineCallbacks def parse_callback(self, request): """