[fedi] instances moderation
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
23
server/api/controller/instances.js
Normal file
23
server/api/controller/instances.js
Normal 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
|
||||
Reference in New Issue
Block a user