[fedi] comment/instance/user moderation
This commit is contained in:
@@ -96,7 +96,7 @@ const eventController = {
|
||||
{ model: Tag, attributes: ['tag', 'weigth'], through: { attributes: [] } },
|
||||
{ model: User, attributes: ['username'] },
|
||||
{ model: Place, attributes: ['name', 'address'] },
|
||||
Comment
|
||||
{ model: Comment, where: !is_admin && { hidden: false }, required: false }
|
||||
],
|
||||
order: [ [Comment, 'id', 'DESC'] ]
|
||||
})
|
||||
|
||||
27
server/api/controller/fed_user.js
Normal file
27
server/api/controller/fed_user.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const { fed_users: FedUsers, comment: Comment } = require('../models')
|
||||
|
||||
const fedUserController = {
|
||||
async toggleBlock (req, res) {
|
||||
const user_id = req.body.user_id
|
||||
const user = await FedUsers.findByPk(user_id)
|
||||
user.update({ blocked: !user.blocked })
|
||||
res.json(user)
|
||||
},
|
||||
|
||||
async hideComment (req, res) {
|
||||
const comment_id = req.params.comment_id
|
||||
const hidden = req.body.hidden
|
||||
const comment = await Comment.findByPk(comment_id)
|
||||
await comment.update({ hidden })
|
||||
res.json(comment)
|
||||
},
|
||||
|
||||
async removeComment (req, res) {
|
||||
const comment_id = req.params.comment_id
|
||||
const comment = await Comment.findByPk(comment_id)
|
||||
await comment.destroy()
|
||||
res.sendStatus(200)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = fedUserController
|
||||
@@ -1,5 +1,5 @@
|
||||
const Sequelize = require('sequelize')
|
||||
const { fed_users: FedUsers, instances: Instances } = require('../models')
|
||||
const { fed_users: FedUsers, instances: Instances, comment: Comment } = require('../models')
|
||||
|
||||
const instancesController = {
|
||||
async getAll (req, res) {
|
||||
@@ -12,6 +12,15 @@ const instancesController = {
|
||||
})
|
||||
return res.json(instances)
|
||||
},
|
||||
|
||||
/**
|
||||
* get instance users
|
||||
*/
|
||||
async get (req, res) {
|
||||
const fedi_users = await FedUsers.findAll({ where: { instanceDomain: req.params.instance_domain }, include: [Comment] })
|
||||
return res.json(fedi_users)
|
||||
},
|
||||
|
||||
async toggleBlock (req, res) {
|
||||
const instance = await Instances.findByPk(req.body.instance)
|
||||
if (!instance) { return res.status(404).send('Not found') }
|
||||
|
||||
Reference in New Issue
Block a user