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.

58 lines
1.3 KiB

import FileStore from './../../store/file.js'
import HubStore from './../../store/hub.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, opts)
{
/**
* getting post getting allowed parser class and send over xmpp
*
* @param {object} request
* @param {object} response
*
*/
fastify.get('/:hubId([-a-zA-Z0-9]{0,255})', async function (request, reply)
{
// create store
const hubStore = new HubStore()
// getting single hub
const hub = await hubStore.findOneById(request.params.hubId)
// result for request
const result = {
}
if (!hub) {
return reply
.code('404')
.send()
}
let path = hub.directory
// getting path
// @TODO validate path and make sure it is present in homeDir
if (request.query.path) {
path += '/' + request.query.path
}
const fileStore = new FileStore(path)
const files = await fileStore.get()
result['data'] = files['files']
reply
.code(200)
.send(result)
})
}