can check email address validation

This commit is contained in:
2022-11-26 00:31:39 +01:00
parent f99b76a244
commit 6d8e3f19dc
2 changed files with 32 additions and 6 deletions
+21
View File
@@ -93,6 +93,17 @@ class MongoDbManager:
self.logger.info(error) self.logger.info(error)
return email_list return email_list
def get_invalid_emails(self) -> list:
collection_name = INVALID_EMAIL_LIST
email_list = []
try:
collection_to_use = self.db[collection_name]
for document in collection_to_use.find():
email_list.append(MailAddress.from_firestore_dict(document))
except Exception as error:
self.logger.info(error)
return email_list
def insert_captcha_error_contact(self, contact: ContactPojo): def insert_captcha_error_contact(self, contact: ContactPojo):
day = str(datetime.date.today()) day = str(datetime.date.today())
collection_name = CAPTCHA_ERROR_COLLECTION_PREFIX + day collection_name = CAPTCHA_ERROR_COLLECTION_PREFIX + day
@@ -192,6 +203,16 @@ class MongoDbManager:
except Exception as error: except Exception as error:
self.logger.info(error) self.logger.info(error)
def remove_email_from_destination_email_list(self, mail: MailAddress):
# DESTINATION_EMAIL_LIST
collection = self.db[DESTINATION_EMAIL_LIST]
to_delete = {'_id': mail.mail}
try:
collection.delete_one(to_delete)
except Exception as error:
self.logger.info(error)
print(error)
def remove_contact_from_black_list(self, contact: ContactPojo): def remove_contact_from_black_list(self, contact: ContactPojo):
collection_name = BLACK_LIST collection_name = BLACK_LIST
collection = self.db[collection_name] collection = self.db[collection_name]
+11 -6
View File
@@ -50,14 +50,19 @@ class MailAddressValidator():
print("{} is not valid".format(self.login)) print("{} is not valid".format(self.login))
if __name__ == '__main__': def remove_invalid_email():
# address = "walter_chad1982@yahoo.com" invalid = MONGO_STORE_MANAGER.get_invalid_emails()
address = "ricejulie1979@yahoo.com" for mail in invalid:
# code = "xawbzyduwoquxsre" MONGO_STORE_MANAGER.remove_email_from_destination_email_list(mail)
code = "eybrvmzdmklizleh"
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
def find_and_update_invalid_emails():
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
with ThreadPoolExecutor(max_workers=20) as executor: with ThreadPoolExecutor(max_workers=20) as executor:
for mail in mail_list: for mail in mail_list:
valiator = MailAddressValidator(mail.mail, mail.password) valiator = MailAddressValidator(mail.mail, mail.password)
executor.submit(valiator.check_and_save_to_db) executor.submit(valiator.check_and_save_to_db)
if __name__ == '__main__':
remove_invalid_email()