fixed new emessage interface change
This commit is contained in:
parent
fe6b96074e
commit
53e0bd5c0f
1 changed files with 34 additions and 19 deletions
|
@ -43,52 +43,67 @@ class eMessagePuppeteerConnectorBase extends Connector {
|
|||
this.connectorRegistry.reportState(msg, UUID, 'puppettering')
|
||||
const page = await browser.newPage()
|
||||
await page.goto('https://ruf.emessage.de/')
|
||||
|
||||
const serviceSelect = 'select[name="pageSendForm:serviceSelect"]'
|
||||
await page.waitForSelector(serviceSelect)
|
||||
await page.select(serviceSelect, serviceName)
|
||||
await page.click(serviceSelect)
|
||||
await page.click(serviceSelect)
|
||||
await sleep(1e3)
|
||||
|
||||
const selectServiceButton = 'input[name="pageSendForm:selectServiceButton"]'
|
||||
await page.waitForSelector(selectServiceButton)
|
||||
await page.click(selectServiceButton)
|
||||
await sleep(1e3)
|
||||
|
||||
const pagerNumberInput = 'input[name="pageSendForm:pagerNumberInput"]'
|
||||
|
||||
const pagerNumberInput = 'input[formcontrolname="eID"]'
|
||||
await page.waitForSelector(pagerNumberInput)
|
||||
await page.type(pagerNumberInput, identifier)
|
||||
await sleep(1e3)
|
||||
|
||||
const validatePagerNumberButton = 'input[id="pageSendForm:validatePagerNumberButton"]'
|
||||
const validatePagerNumberButton = 'form > div:nth-child(2) > button:nth-child(1)'
|
||||
await page.waitForSelector(validatePagerNumberButton)
|
||||
await page.click(validatePagerNumberButton)
|
||||
await sleep(1e3)
|
||||
|
||||
const pageContentInput = 'textarea[id="pageSendForm:pageContentInput"]'
|
||||
const localStorage = await page.evaluate(() => Object.assign({}, window.localStorage))
|
||||
|
||||
console.log(localStorage)
|
||||
if (!!localStorage['token:ruf'])
|
||||
await browser.close()
|
||||
return axios.post('https://api.emessage.de/rs/ruf/send', {
|
||||
messageText: payloadBuffer.toString('ascii'),
|
||||
identifier
|
||||
}, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${ localStorage['token:ruf'] }`
|
||||
}
|
||||
})
|
||||
.then((sndMessageReq) => { // extract tracking ID from response
|
||||
if (sndMessageReq.data.apiStatusCode != 200) { throw sndMessageReq }
|
||||
let msgTrackID = sndMessageReq.data.data.trackingId
|
||||
console.log('TRACKING ID', msgTrackID, sndMessageReq.data.data.recipients)
|
||||
return res(msgTrackID)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
this.connectorRegistry.reportFail(msg, UUID)
|
||||
return rej(err)
|
||||
})
|
||||
|
||||
/*
|
||||
const pageContentInput = 'textarea[formcontrolname="message"]'
|
||||
await page.waitForSelector(pageContentInput)
|
||||
await page.type(pageContentInput, payloadBuffer.toString('ascii'))
|
||||
await sleep(1e3)
|
||||
|
||||
const sendPageButton = 'input[id="pageSendForm:sendPageButton"]'
|
||||
const sendPageButton = 'form > div:nth-child(3) > button:nth-child(2)'
|
||||
await page.waitForSelector(sendPageButton)
|
||||
await page.click(sendPageButton)
|
||||
await sleep(1e3)
|
||||
|
||||
const messageSentResult = 'span[id="pageSendForm:messageSentResult"]'
|
||||
const messageSentResult = '.response-wrapper > div > p'
|
||||
await page.waitForSelector(messageSentResult)
|
||||
|
||||
let $messageSentResult = await page.$(messageSentResult)
|
||||
let value = await page.evaluate(el => el.textContent, $messageSentResult)
|
||||
// pageSendForm:messageSentResult
|
||||
if (value.indexOf("Meldung : OK") > -1) {
|
||||
if (value.indexOf("Ihr Ruf wurde erfolgreich gesendet") > -1) {
|
||||
await browser.close()
|
||||
return res(true)
|
||||
} else {
|
||||
await browser.close()
|
||||
return rej(value)
|
||||
}
|
||||
*/
|
||||
})
|
||||
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue