linkify content coming from fedi
This commit is contained in:
parent
36117ada37
commit
061c104632
1 changed files with 7 additions and 3 deletions
|
@ -1,11 +1,17 @@
|
||||||
const { event: Event, resource: Resource, ap_user: APUser } = require('../api/models')
|
const { event: Event, resource: Resource, ap_user: APUser } = require('../api/models')
|
||||||
const debug = require('debug')('fediverse:resource')
|
const debug = require('debug')('fediverse:resource')
|
||||||
const helpers = require('../helpers')
|
const helpers = require('../helpers')
|
||||||
|
const linkifyHtml = require('linkifyjs/html')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
// create a resource from AP Note
|
// create a resource from AP Note
|
||||||
async create (req, res) {
|
async create (req, res) {
|
||||||
|
if (!req.settings.enable_resource) {
|
||||||
|
debug('Ignore resource as it is disabled in settings')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const body = req.body
|
const body = req.body
|
||||||
|
|
||||||
// search for related event
|
// search for related event
|
||||||
|
@ -31,9 +37,7 @@ module.exports = {
|
||||||
|
|
||||||
// TODO should probably map links here
|
// TODO should probably map links here
|
||||||
// clean resource
|
// clean resource
|
||||||
body.object.content = helpers.sanitizeHTML(body.object.content, {
|
body.object.content = helpers.sanitizeHTML(linkifyHtml(body.object.content))
|
||||||
nonTextTags: ['style', 'script', 'textarea', 'noscript']
|
|
||||||
})
|
|
||||||
|
|
||||||
await Resource.create({
|
await Resource.create({
|
||||||
activitypub_id: body.object.id,
|
activitypub_id: body.object.id,
|
||||||
|
|
Loading…
Reference in a new issue