support black list

This commit is contained in:
2022-10-07 17:31:45 +02:00
parent 3b136ee3c6
commit e06439bf84
4 changed files with 40 additions and 18 deletions
+7 -16
View File
@@ -1,5 +1,6 @@
const {SolveCaptcha, TWO_CAPTCHA_CONNECTION_FAILED} = require("./SolveCaptcha");
const ReserveResultPojo = require("../models/ReserveResultPojo");
const BlackListContactPojo = require("../models/BlackListContactPojo");
const appointmentLogger = require("../utiles/LoggerUtils")
const PublishType = require("../models/PublishType");
const {
@@ -293,7 +294,7 @@ class CommandorPage {
}
async onPageLoad(currentPage) {
console.log("onPageLoad called, url is "+currentPage.url())
console.log("onPageLoad called, url is " + currentPage.url())
try {
let content = await currentPage.content();
let captcha_url = "geo.captcha-delivery.com/captcha";
@@ -374,21 +375,11 @@ class CommandorPage {
this.isTerminated = true
}
async push_message_to_db(publishType, url) {
let splitedUrl = url.split("/");
let id = splitedUrl[splitedUrl.length - 1];
if (url === "https://rendezvousparis.hermes.com/client/welcome") {
return
}
// save to mongoDb
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, this.page.url(), 1, publishType);
reserve.source_from = this.device.model();
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
await delay(2 * 1000)
async saveToBlackList() {
await this.mongoManager.saveBlackListToDb(new BlackListContactPojo(this.contact))
this.isTerminated = true
}
async getErrors() {
if (this.page.url() === BLANK_URL) {
this.isTerminated = true;
@@ -398,7 +389,7 @@ class CommandorPage {
if (errorItem) {
let errorContent = await errorItem.innerHTML();
log("error:" + errorContent);
this.handleError(errorContent);
await this.handleError(errorContent);
}
} catch (e) {
log(e);
@@ -406,12 +397,12 @@ class CommandorPage {
}
}
handleError(errorContent) {
async handleError(errorContent) {
if (errorContent.includes(DOUBLE_REQUEST_ERROR_MESSAGE) || errorContent.includes(DOUBLE_REQUEST_ERROR_MESSAGE_FR)) {
this.isTerminated = true;
} else if (errorContent.includes(TOO_MANY_REQUEST_ERROR_MESSAGE) || errorContent.includes(TOO_MANY_REQUEST_ERROR_MESSAGE_FR)) {
// todo, add contact to black list
this.isTerminated = true;
await this.saveToBlackList()
} else if (errorContent.includes(CAPTCHA_ERROR_MESSAGE) || errorContent.includes(CAPTCHA_ERROR_MESSAGE_FR)) {
this.isTerminated = true;
}