fix AP resource removal
This commit is contained in:
@@ -59,7 +59,7 @@ module.exports = {
|
|||||||
async remove (req, res) {
|
async remove (req, res) {
|
||||||
const resource = await Resource.findOne({
|
const resource = await Resource.findOne({
|
||||||
where: { activitypub_id: req.body.object.id },
|
where: { activitypub_id: req.body.object.id },
|
||||||
include: [{ model: APUser, required: false, attributes: ['ap_id'] }]
|
include: [{ model: APUser, required: true, attributes: ['ap_id'] }]
|
||||||
})
|
})
|
||||||
if (!resource) {
|
if (!resource) {
|
||||||
log.info(`Comment ${req.body.object.id} not found`)
|
log.info(`Comment ${req.body.object.id} not found`)
|
||||||
@@ -67,8 +67,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
// check if fedi_user that requested resource removal
|
// check if fedi_user that requested resource removal
|
||||||
// is the same that created the resource at first place
|
// is the same that created the resource at first place
|
||||||
log.debug(res.fedi_user.ap_id, resource.ap_user.ap_id)
|
if (req.fedi_user.ap_id === resource.ap_user.id) {
|
||||||
if (res.fedi_user.ap_id === resource.ap_user.id) {
|
|
||||||
await resource.destroy()
|
await resource.destroy()
|
||||||
log.info(`Comment ${req.body.object.id} removed`)
|
log.info(`Comment ${req.body.object.id} removed`)
|
||||||
res.sendStatus(201)
|
res.sendStatus(201)
|
||||||
|
|||||||
Reference in New Issue
Block a user