|
|
@ -1,5 +1,6 @@
|
|
|
|
const Connector = require("./Connector")
|
|
|
|
const Connector = require("./Connector")
|
|
|
|
const config = require('../../config.json')
|
|
|
|
const config = require('../../config.json')
|
|
|
|
|
|
|
|
const boskrypt = require('../../boskrypt')
|
|
|
|
const md5 = require('md5')
|
|
|
|
const md5 = require('md5')
|
|
|
|
const axios = require('axios')
|
|
|
|
const axios = require('axios')
|
|
|
|
// [ "ecityruf", "123456789" ]
|
|
|
|
// [ "ecityruf", "123456789" ]
|
|
|
@ -13,13 +14,28 @@ class eCityrufConnector extends Connector {
|
|
|
|
async transmitMessage(msg, params) {
|
|
|
|
async transmitMessage(msg, params) {
|
|
|
|
const UUID = this.name+':'+md5(JSON.stringify([this.name,...params]))
|
|
|
|
const UUID = this.name+':'+md5(JSON.stringify([this.name,...params]))
|
|
|
|
if (params.length !== 1) return false
|
|
|
|
if (params.length !== 1) return false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const $device = msg.routingParams.device
|
|
|
|
|
|
|
|
let payloadBuffer = Buffer.from(msg.payload)
|
|
|
|
|
|
|
|
const boskryptSupport = require("../DeviceRegistry").Devices[ $device ].supportBOSkrypt || false
|
|
|
|
|
|
|
|
if (boskryptSupport && !!config.pagers[ $device ] && config.pagers[ $device ].boskrypt.enabled) {
|
|
|
|
|
|
|
|
//payloadBuffer
|
|
|
|
|
|
|
|
const keyTable = config.pagers[ $device ].boskrypt.keys
|
|
|
|
|
|
|
|
const FunkrufNummer = "em-"+params[ 0 ]
|
|
|
|
|
|
|
|
if (!!keyTable[ FunkrufNummer ]) {
|
|
|
|
|
|
|
|
payloadBuffer = Buffer.from(boskrypt.encrypt(payloadBuffer, keyTable[ FunkrufNummer ], 0))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const cityrufRequest = require('querystring').stringify({
|
|
|
|
const cityrufRequest = require('querystring').stringify({
|
|
|
|
service: 1,
|
|
|
|
service: 1,
|
|
|
|
class: 7,
|
|
|
|
class: 7,
|
|
|
|
language: 'en',
|
|
|
|
language: 'en',
|
|
|
|
action: 'SendMessage',
|
|
|
|
action: 'SendMessage',
|
|
|
|
number: params[ 0 ],
|
|
|
|
number: params[ 0 ],
|
|
|
|
message: msg.payload,
|
|
|
|
message: payloadBuffer.toString('ascii'),
|
|
|
|
lengthAlert: '',
|
|
|
|
lengthAlert: '',
|
|
|
|
})
|
|
|
|
})
|
|
|
|
console.log(cityrufRequest)
|
|
|
|
console.log(cityrufRequest)
|
|
|
|