mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-20 05:09:27 +00:00
Convert validation processing to a celery task
This commit is contained in:
@@ -33,47 +33,3 @@ class UpdateAPIs():
|
||||
else:
|
||||
acc.save()
|
||||
time.sleep(.5)
|
||||
|
||||
|
||||
class APIKeyParser:
|
||||
dictitems = {}
|
||||
|
||||
def __init__(self, key):
|
||||
rows = key.split('\n')
|
||||
for row in rows:
|
||||
key = row.split(":")[0].replace(" ", "_").lower().strip()
|
||||
value = row.split(":")[1].strip()
|
||||
|
||||
self.dictitems[key] = value
|
||||
|
||||
def __getattr__(self, key):
|
||||
return self.dictitems[key]
|
||||
|
||||
def __str__(self):
|
||||
return "%s:%s" % (self.user_id, self.api_key)
|
||||
|
||||
class ProcessValidations():
|
||||
"""
|
||||
Grabs all Reddit Mail and processes validations
|
||||
"""
|
||||
|
||||
@property
|
||||
def _logger(self):
|
||||
if not hasattr(self, '__logger'):
|
||||
self.__logger = logging.getLogger(__name__)
|
||||
return self.__logger
|
||||
|
||||
def job(self, args):
|
||||
inbox = Inbox(settings.REDDIT_USER, settings.REDDIT_PASSWORD)
|
||||
|
||||
for msg in inbox:
|
||||
if not msg.was_comment:
|
||||
try:
|
||||
acc = RedditAccount.objects.get(username__iexact=msg.author)
|
||||
if not acc.validated and msg.subject == "Validation: %s" % acc.user.username:
|
||||
self._logger.info("Validated %s" % acc.user.username)
|
||||
acc.validated = True
|
||||
acc.save()
|
||||
except RedditAccount.DoesNotExist:
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user