support black list
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
class BlackListContactPojo {
|
||||||
|
constructor(contact) {
|
||||||
|
this.phone = contact.phoneNumber;
|
||||||
|
this.passport = contact.passportNumber;
|
||||||
|
this.last_name = contact.lastName;
|
||||||
|
this.first_name = contact.firstName;
|
||||||
|
this.mail = contact.mail;
|
||||||
|
this.update_at_in_s = (new Date()) / 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = BlackListContactPojo
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
const CommandorPage = require("./workers/CommandorPage");
|
||||||
|
const ContactPojo = require("./models/ContactPojo");
|
||||||
|
const {MongoManager} =require("./workers/mongo_manager");
|
||||||
|
const mongoManager = new MongoManager();
|
||||||
|
|
||||||
|
|
||||||
|
mongoManager.connect().then(r => {
|
||||||
|
let contact = new ContactPojo("0649614591", "1234567890", "PAN", "Lei", "panleicim@gmail.com")
|
||||||
|
let commandPage = new CommandorPage(contact, null, mongoManager)
|
||||||
|
commandPage.saveToBlackList().then(r => {
|
||||||
|
console.log("saved to db")
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
const {SolveCaptcha, TWO_CAPTCHA_CONNECTION_FAILED} = require("./SolveCaptcha");
|
const {SolveCaptcha, TWO_CAPTCHA_CONNECTION_FAILED} = require("./SolveCaptcha");
|
||||||
const ReserveResultPojo = require("../models/ReserveResultPojo");
|
const ReserveResultPojo = require("../models/ReserveResultPojo");
|
||||||
|
const BlackListContactPojo = require("../models/BlackListContactPojo");
|
||||||
const appointmentLogger = require("../utiles/LoggerUtils")
|
const appointmentLogger = require("../utiles/LoggerUtils")
|
||||||
const PublishType = require("../models/PublishType");
|
const PublishType = require("../models/PublishType");
|
||||||
const {
|
const {
|
||||||
@@ -293,7 +294,7 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onPageLoad(currentPage) {
|
async onPageLoad(currentPage) {
|
||||||
console.log("onPageLoad called, url is "+currentPage.url())
|
console.log("onPageLoad called, url is " + currentPage.url())
|
||||||
try {
|
try {
|
||||||
let content = await currentPage.content();
|
let content = await currentPage.content();
|
||||||
let captcha_url = "geo.captcha-delivery.com/captcha";
|
let captcha_url = "geo.captcha-delivery.com/captcha";
|
||||||
@@ -374,21 +375,11 @@ class CommandorPage {
|
|||||||
this.isTerminated = true
|
this.isTerminated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
async push_message_to_db(publishType, url) {
|
async saveToBlackList() {
|
||||||
let splitedUrl = url.split("/");
|
await this.mongoManager.saveBlackListToDb(new BlackListContactPojo(this.contact))
|
||||||
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)
|
|
||||||
this.isTerminated = true
|
this.isTerminated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async getErrors() {
|
async getErrors() {
|
||||||
if (this.page.url() === BLANK_URL) {
|
if (this.page.url() === BLANK_URL) {
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
@@ -398,7 +389,7 @@ class CommandorPage {
|
|||||||
if (errorItem) {
|
if (errorItem) {
|
||||||
let errorContent = await errorItem.innerHTML();
|
let errorContent = await errorItem.innerHTML();
|
||||||
log("error:" + errorContent);
|
log("error:" + errorContent);
|
||||||
this.handleError(errorContent);
|
await this.handleError(errorContent);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(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)) {
|
if (errorContent.includes(DOUBLE_REQUEST_ERROR_MESSAGE) || errorContent.includes(DOUBLE_REQUEST_ERROR_MESSAGE_FR)) {
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
} else if (errorContent.includes(TOO_MANY_REQUEST_ERROR_MESSAGE) || errorContent.includes(TOO_MANY_REQUEST_ERROR_MESSAGE_FR)) {
|
} else if (errorContent.includes(TOO_MANY_REQUEST_ERROR_MESSAGE) || errorContent.includes(TOO_MANY_REQUEST_ERROR_MESSAGE_FR)) {
|
||||||
// todo, add contact to black list
|
// 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)) {
|
} else if (errorContent.includes(CAPTCHA_ERROR_MESSAGE) || errorContent.includes(CAPTCHA_ERROR_MESSAGE_FR)) {
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const DB_NAME = "appointment"
|
|||||||
const COLLECTION_NAME = "appointment"
|
const COLLECTION_NAME = "appointment"
|
||||||
const ACCEPTED_APPOINTMENT_LIST = "ACCEPTED_APPOINTMENT_LIST"
|
const ACCEPTED_APPOINTMENT_LIST = "ACCEPTED_APPOINTMENT_LIST"
|
||||||
const EMAIL_LIST = "EMAIL_LIST"
|
const EMAIL_LIST = "EMAIL_LIST"
|
||||||
const DESTINATION_EMAIL_LIST = "DESTINATION_EMAIL_LIST"
|
const BLACK_LIST_COLLECTION_NAME = "BLACK_LIST"
|
||||||
|
|
||||||
const {MongoClient} = require('mongodb');
|
const {MongoClient} = require('mongodb');
|
||||||
const ReserveResultPojo = require("../models/ReserveResultPojo");
|
const ReserveResultPojo = require("../models/ReserveResultPojo");
|
||||||
@@ -37,7 +37,7 @@ class MongoManager {
|
|||||||
this.db = this.client.db("appointment")
|
this.db = this.client.db("appointment")
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllSuccessfulItemsForDay(day) {
|
async getAllSuccessfulItemsForDay(day) {
|
||||||
return await this.db.collection(day).find().toArray()
|
return await this.db.collection(day).find().toArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +45,10 @@ class MongoManager {
|
|||||||
let collectionName = formatDate(new Date())
|
let collectionName = formatDate(new Date())
|
||||||
return await this.db.collection(collectionName).replaceOne({'_id': reservePojo.id,}, reservePojo, {upsert: true})
|
return await this.db.collection(collectionName).replaceOne({'_id': reservePojo.id,}, reservePojo, {upsert: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async saveBlackListToDb(contact) {
|
||||||
|
return await this.db.collection(BLACK_LIST_COLLECTION_NAME).replaceOne({'_id': contact.mail,}, contact, {upsert: true})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user