save email address
This commit is contained in:
@@ -256,11 +256,12 @@ class MongoDbManager:
|
||||
collection.find_one_and_update({'_id': id}, {"$set": {"url_validated": state, "validated_at": validated_at}},
|
||||
upsert=False)
|
||||
|
||||
def save_links_to_validate(self, link: str):
|
||||
def save_links_to_validate(self, link: str, mail_address: str):
|
||||
collection_to_use = self.db[LINKS_TO_VALIDATE]
|
||||
updated_at = time.strftime("%H:%M:%S", time.localtime())
|
||||
collection_to_use.replace_one(filter={'_id': link, }, replacement={
|
||||
u'url': link,
|
||||
u'email': mail_address,
|
||||
"updated_at": updated_at
|
||||
},
|
||||
upsert=True)
|
||||
|
||||
@@ -117,6 +117,7 @@ class MailReader():
|
||||
print(body)
|
||||
if VALIDATION_URL_SUBJECT_fr in subject or VALIDATION_URL_SUBJECT_EN in subject:
|
||||
mail = MailPojo(subject=subject, body=body, from_address=from_address)
|
||||
mail.mail_address = self.login
|
||||
mail_messages.append(mail)
|
||||
return mail_messages
|
||||
|
||||
@@ -157,6 +158,7 @@ class MailReader():
|
||||
|
||||
|
||||
def need_to_valid_url(url: str, successful_items) -> bool:
|
||||
# return True
|
||||
if len(successful_items) == 0:
|
||||
return False
|
||||
print("url is :" + url)
|
||||
@@ -184,8 +186,8 @@ def need_to_check_email(mail: str, successful_items) -> bool:
|
||||
# return True
|
||||
for item in successful_items:
|
||||
if mail in item.email:
|
||||
print("url_validated for {} is {}".format(mail, item.url_validated))
|
||||
if item.url_validated is not None:
|
||||
print("url_validated for {} is {}".format(mail, item.url_validated))
|
||||
return not item.url_validated
|
||||
else:
|
||||
# if url-validated is none, need to check email
|
||||
@@ -200,7 +202,7 @@ def read_mails():
|
||||
if is_time_between(time(7, 30), time(19, 30)):
|
||||
# get email address
|
||||
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
||||
# mail_address1 = MailAddress(mail="enasremor1973@onet.pl", password=")ozBUE0RjZ8N")
|
||||
mail_address1 = MailAddress(mail="camille.gelais@yahoo.com", password="rporemmflqhoewcd")
|
||||
# mail_address1 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb")
|
||||
# # mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce")
|
||||
# mail_list = [mail_address1]
|
||||
@@ -226,7 +228,7 @@ def read_mails():
|
||||
# else:
|
||||
url = match.group(0)
|
||||
if need_to_valid_url(url, successful_items):
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url)
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.mail_address)
|
||||
# url_validator = LinkValidator(url)
|
||||
print("need to validate url: " + url)
|
||||
# executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), False)
|
||||
|
||||
@@ -43,12 +43,29 @@ class ReserveResultPojo:
|
||||
publish_type = source['type']
|
||||
if publish_type:
|
||||
publish_type = PublishType[publish_type]
|
||||
phone = source['phone']
|
||||
url = source['url']
|
||||
id = source['id']
|
||||
if 'phone' in source:
|
||||
phone = source['phone']
|
||||
else:
|
||||
phone = ""
|
||||
if 'url' in source:
|
||||
url = source['url']
|
||||
else:
|
||||
url = ""
|
||||
if 'id' in source:
|
||||
id = source['id']
|
||||
else:
|
||||
id = ""
|
||||
email = source['email']
|
||||
lastName = source['lastName']
|
||||
firstName = source['firstName']
|
||||
if 'lastName' in source:
|
||||
lastName = source['lastName']
|
||||
else:
|
||||
lastName = ""
|
||||
|
||||
if 'firstName' in source:
|
||||
firstName = source['firstName']
|
||||
else:
|
||||
firstName = ""
|
||||
|
||||
result = ReserveResultPojo(type=publish_type, phone=phone,
|
||||
url=url, email=email,
|
||||
firstName=firstName, lastName=lastName)
|
||||
|
||||
Reference in New Issue
Block a user