From 8a71fa7612321bf4362244332bd7438375f277c4 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Mon, 25 Mar 2024 10:51:55 +0100 Subject: [PATCH] more fields --- src/workers/CommandorPage.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 4e3bc61..642b349 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -33,7 +33,8 @@ const EMPTY_RESPONSE_ERROR = "ERR_EMPTY_RESPONSE" const MESSAGE_URL_VALIDATION_FR = "Nous avons envoyé un lien par e-mail." const MESSAGE_URL_VALIDATION_EN = "Please click on the link we sent by email" const REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+" -const DEFAULT_STORE = 'faubourg'; +// const DEFAULT_STORE = 'faubourg'; +const DEFAULT_STORE = 'random'; const timeout = (prom, time) => Promise.race([prom, new Promise((_r, rej) => setTimeout(rej, time))]); @@ -76,13 +77,15 @@ function logWithDevice(message, device) { const searchTexts = ['hermes+rdv+online+paris', 'hermes+rdv+enligne+paris', 'hermes+rdv+en+ligne+paris', 'hermes+rendezvous+en+ligne+paris', 'hermes+appointment+online+paris', 'hermes+appointment+online+paris', 'appointment+hermes+paris+on+line', 'hermes+rendez+vous+online+paris', 'hermes+rendez+vous+paris+en+ligne', 'hermes+rendez+vous+paris+enligne', 'hermes+rendez+vous+paris+online', 'online+appointment+hermes+paris', 'hermes+online+appointment+paris', 'paris+hermes+online+appointment'] class CommandorPage { - constructor(contact, device, sender, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false, port = 9000, onlyForCookies = false) { + constructor(contact, device, sender, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false, port = 9000, shareCookiesWithRequests = true) { this.contact = contact; + // to remove this line if we want to use store in contacts + this.contact.store = DEFAULT_STORE this.device = device; this.mongoManager = mongoManager; this.selectedStore = selectedStore; this.choosedStore = selectedStore; - this.onlyForCookies = onlyForCookies; + this.shareCookiesWithRequests = shareCookiesWithRequests; this.port = port; this.sender = sender; this.ocrChecker = new OCRChecker(this.device, this.contact); @@ -759,10 +762,8 @@ class CommandorPage { let url = this.page.url(); logWithDevice("successful url is " + url, this.device) await this.push_message_to_db(publishType, url) - if (this.onlyForCookies) { + if (this.shareCookiesWithRequests) { await this.sendCookiesToQueue(); - this.isTerminated = true; - await this.resetBrowser() } } @@ -1274,13 +1275,14 @@ class CommandorPage { cookiesString = cookiesString + cookie.name + "=" + cookie.value + ";" }) console.log(cookiesString); - if (this.onlyForCookies) { + if (this.shareCookiesWithRequests) { let pojoToSend = await this.getRequestData() pojoToSend.cookiesStr = cookiesString // this.sender.sendMessage(JSON.stringify(pojoToSend), REQUEST_DATA_OBJECT) this.sender.sendMessage(JSON.stringify(pojoToSend), TEST_QUEUE) - } else + } else { this.sender.sendMessage(cookiesString) + } } catch (e) { console.log(e) }