[fedi] instances moderation

This commit is contained in:
les
2019-10-30 15:01:15 +01:00
parent 0876f9baee
commit ec92ce84bb
13 changed files with 193 additions and 88 deletions

View File

@@ -73,15 +73,6 @@ const eventController = {
return ret
},
async updateTag (req, res) {
const tag = await Tag.findByPk(req.body.tag)
if (tag) {
res.json(await tag.update(req.body))
} else {
res.sendStatus(404)
}
},
async updatePlace (req, res) {
const place = await Place.findByPk(req.body.id)
await place.update(req.body)

View File

@@ -29,7 +29,7 @@ const exportController = {
start_datetime: { [Op.gte]: yesterday },
...where
},
include: [ { model: Tag, ...where_tags }, { model: Place, attributes: ['name', 'id', 'address'] }]
include: [{ model: Tag, ...where_tags }, { model: Place, attributes: ['name', 'id', 'address'] }]
})
switch (type) {

View File

@@ -0,0 +1,23 @@
const Sequelize = require('sequelize')
const { fed_users: FedUsers, instances: Instances } = require('../models')
const instancesController = {
async getAll (req, res) {
const instances = await Instances.findAll({
attributes: {
include: [[Sequelize.fn('count', Sequelize.col('domain')), 'users']]
},
group: ['domain'],
include: [{ model: FedUsers, attributes: [] }]
})
return res.json(instances)
},
async toggleBlock (req, res) {
const instance = await Instances.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