You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
994 B
41 lines
994 B
import tokenHandler from './../../handlers/token.js'
|
|
import parserHandler from './../../handlers/parser.js'
|
|
|
|
/**
|
|
* handle webhook
|
|
*
|
|
* @author Björn Hase
|
|
* @license hhttps://www.gnu.org/licenses/gpl-3.0.en.html GPL-3
|
|
* @link https://gitea.node001.net/HerrHase/tellme-bot.git
|
|
*
|
|
*/
|
|
|
|
export default async function(fastify, options) {
|
|
|
|
fastify.addHook('preHandler', tokenHandler)
|
|
fastify.addHook('preHandler', parserHandler)
|
|
|
|
/**
|
|
* getting post getting allowed parser class and send over xmpp
|
|
*
|
|
* @param {object} request
|
|
* @param {object} response
|
|
*
|
|
*/
|
|
fastify.post('/v1/:token/:parser', async function (request, response) {
|
|
|
|
// getting parser from preHandler: parserHandler
|
|
const result = response.locals.parser.run()
|
|
|
|
// send event for send xmpp
|
|
fastify.eventEmitter.emit('send-message', {
|
|
'message': result
|
|
})
|
|
|
|
response
|
|
.code(200)
|
|
.send()
|
|
})
|
|
|
|
}
|