diff --git a/.gitignore b/.gitignore index 378874c..3bc1955 100644 --- a/.gitignore +++ b/.gitignore @@ -134,6 +134,6 @@ storage/* !storage/logs/.gitkeep !storage/.gitkeep -packages/custom -!packages/custom/.gitkeep -!packages/custom/package-custom.json +custom +!custom/.gitkeep +!custom/package-custom.json diff --git a/custom/actions/Pingdom.js b/custom/actions/Pingdom.js deleted file mode 100644 index 71ef190..0000000 --- a/custom/actions/Pingdom.js +++ /dev/null @@ -1,35 +0,0 @@ -import Action from './../../packages/server/actions/action.js' -import XmppHelper from './../helpers/Xmpp.js' - -/** - * Getting Http State - * - * @author Björn Hase - * @license http://opensource.org/licenses/MIT The MIT License - * @link https://git.node001.net/HerrHase/super-hog.git - * - */ - -class Pingdom extends Action { - - /** - * - * - */ - async run() { - - const xmppHelper = new XmppHelper( - process.env.XMPP_SERVICE, - process.env.XMPP_DOMAIN, - process.env.XMPP_USERNAME, - process.env.XMPP_PASSWORD - ) - - const message = this.data.check_params.full_url + ' / ' + this.data.current_state - await xmppHelper.sendToRoom(this.flow, process.env.XMPP_ROOM, message) - - } - -} - -export default Pingdom diff --git a/custom/actions/Xmpp.js b/custom/actions/Xmpp.js deleted file mode 100644 index 20452df..0000000 --- a/custom/actions/Xmpp.js +++ /dev/null @@ -1,32 +0,0 @@ -import Action from './../../packages/server/actions/action.js' -import XmppHelper from './../helpers/Xmpp.js' - -/** - * Xmpp Message - * - * @author Björn Hase - * @license http://opensource.org/licenses/MIT The MIT License - * @link https://git.node001.net/HerrHase/super-hog.git - * - */ - -class Xmpp extends Action { - - /** - * - * - */ - async run() { - const xmppHelper = new XmppHelper( - process.env.XMPP_SERVICE, - process.env.XMPP_DOMAIN, - process.env.XMPP_USERNAME, - process.env.XMPP_PASSWORD - ) - - await xmppHelper.sendToRoom(this.flow, process.env.XMPP_ROOM, this.data.message) - } - -} - -export default Xmpp diff --git a/custom/helpers/Xmpp.js b/custom/helpers/Xmpp.js deleted file mode 100644 index 2e95e2f..0000000 --- a/custom/helpers/Xmpp.js +++ /dev/null @@ -1,80 +0,0 @@ -import { client, xml } from '@xmpp/client' -import debug from '@xmpp/debug' -import DOMPurify from 'isomorphic-dompurify' - -import Action from './../../packages/server/actions/action.js' -import logger from './../../packages/server/helper/logger.js' - -/** - * - * - * @author Björn Hase - * @license http://opensource.org/licenses/MIT The MIT License - * @link https://git.node001.net/HerrHase/super-hog.git - * - */ - -class XmppHelper { - - /** - * - * - */ - constructor(service, domain, username, password) { - this.service = service - this.domain = domain - this.username = username - this.password = password - } - - /** - * - * - */ - async sendToRoom(flow, room, message) { - - // cleaning data - message = DOMPurify.sanitize(message) - - const xmpp = client({ - service: this.service, - domain: this.domain, - username: this.username, - password: this.password - }) - - if (process.env.APP_DEBUG) { - debug(xmpp, true) - } - - // handle if client has errors - xmpp.on('error', (error) => { - logger(flow.uuid).error('xmpp / error ' + error) - }) - - // handle if client goes online - xmpp.once('online', async (address) => { - - // join group - await xmpp.send(xml("presence", { to: room + '/' + this.username }, xml("x", { xmlns: 'http://jabber.org/protocol/muc' }))) - - // sends a message to the room - const message = xml( - 'message', { - type: 'groupchat', - to: room - }, - xml('body', {}, message) - ) - - await xmpp.send(message) - logger(flow.uuid).info('xmpp / message send') - - await xmpp.disconnect() - }) - - await xmpp.start() - } -} - -export default XmppHelper diff --git a/custom/package.json b/custom/package.json deleted file mode 100644 index b71053a..0000000 --- a/custom/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "private": true, - "name": "custom", - "type": "module", - "dependencies": { - "@xmpp/client": "^0.14.0" - }, - "devDependencies": { - "@xmpp/debug": "^0.14.0" - } -}