mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 00:52:01 +01:00
26 lines
744 B
JavaScript
26 lines
744 B
JavaScript
const { ap_user: APUser, instance: Instance, resource: Resource } = require('../models')
|
|
|
|
const instancesController = {
|
|
async getAll (req, res) {
|
|
const instances = await Instance.findAll()
|
|
|
|
return res.json(instances)
|
|
},
|
|
|
|
/**
|
|
* get instance users
|
|
*/
|
|
async get (req, res) {
|
|
const ap_users = await APUser.findAll({ where: { instanceDomain: req.params.instance_domain }, include: [Resource] })
|
|
return res.json(ap_users)
|
|
},
|
|
|
|
async toggleBlock (req, res) {
|
|
const instance = await Instance.findByPk(req.body.instance)
|
|
if (!instance) { return res.status(404).send('Not found') }
|
|
await instance.update({ blocked: req.body.blocked })
|
|
return res.json(instance)
|
|
}
|
|
}
|
|
|
|
module.exports = instancesController
|