diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 709be13..557194a 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -8,8 +8,7 @@ const puppeteer = require('puppeteer'); const GeoCaptchaSolver = require("./GeoCaptchaSolver"); const SlidingCaptchaSolver = require("./SlidingCaptchaSolver"); const OCRChecker = require("./OCRChecker"); -const {disconnect} = require("mongoose"); -const {execSync} = require("child_process"); +const {main} = require("yarn/lib/cli"); // const RDV_URL = "http://192.168.0.44:8000/test_appointment.html" const RDV_URL = "https://rendezvousparis.hermes.com/client/register"; const BLANK_URL = "about:blank" @@ -381,6 +380,32 @@ class CommandorPage { } } + async getRawAppointmentInfo(page) { + let passportId = await page.evaluate(() => { + let field = document.getElementById("passport_id"); + return field.value + }) + + let lastName = await page.evaluate(() => { + let field = document.getElementById("surname"); + return field.value + }) + let firstName = await page.evaluate(() => { + let field = document.getElementById("name"); + return field.value + }) + let phone = await page.evaluate(() => { + let field = document.getElementById("phone_number"); + return field.value + }) + + let email = await page.evaluate(() => { + let field = document.getElementById("email"); + return field.value + }) + return new ReserveResultPojo(email, phone, passportId, email, lastName, firstName, "random", "", PublishType.PENDING) + } + async inputPassportId(page) { logWithDevice("inputPassportId", this.device) try { @@ -659,6 +684,23 @@ class CommandorPage { return } // save to mongoDb + let raw = await this.getRawAppointmentInfo(this.page) + // await this.mongoManager.saveRawReserveInfoToDb(raw) + if (raw.email !== undefined) { + this.contact.mail = raw.email + } + if (raw.passportNumber !== undefined) { + this.contact.passportNumber = raw.passportNumber + } + if (raw.lastName !== undefined) { + this.contact.lastName = raw.lastName + } + if (raw.phoneNumber !== undefined) { + this.contact.phoneNumber = raw.phoneNumber + } + if (raw.firstName !== undefined) { + this.contact.firstName = raw.firstName + } let reserve = ReserveResultPojo.create_from_contact(this.contact, id, url, this.choosedStore, publishType); reserve.source_from = this.device.model(); await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict()) diff --git a/src/workers/mongo_manager.js b/src/workers/mongo_manager.js index 12327f0..67343d6 100644 --- a/src/workers/mongo_manager.js +++ b/src/workers/mongo_manager.js @@ -4,6 +4,7 @@ const BLACK_LIST = "BLACK_LIST" const DB_NAME = "appointment" const COLLECTION_NAME = "appointment" const ACCEPTED_APPOINTMENT_LIST = "ACCEPTED_APPOINTMENT_LIST" +const RAW_APPOINTMENT_LIST = "RAW_APPOINTMENT_LIST" const BLACK_LIST_COLLECTION_NAME = "BLACK_LIST" const LINKS_TO_VALIDATE = "LINKS_TO_VALIDATE" const {MongoClient} = require('mongodb'); @@ -49,6 +50,11 @@ class MongoManager { return await this.db.collection(collectionName).replaceOne({'_id': reservePojo.id,}, reservePojo, {upsert: true}) } + async saveRawReserveInfoToDb(reservePojo) { + return await this.db.collection(RAW_APPOINTMENT_LIST).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}) }