diff --git a/locales/en.json b/locales/en.json index e9b10863..ee47b6ff 100644 --- a/locales/en.json +++ b/locales/en.json @@ -107,7 +107,8 @@ "show_preview": "Show preview", "clone": "Clone", "pin": "Pin", - "trusted_instances": "Trusted instances" + "trusted_instances": "Trusted instances", + "actors": "Node" }, "login": { "description": "By logging in you can publish new events.", diff --git a/locales/it.json b/locales/it.json index 0c8e49e4..2e531b90 100644 --- a/locales/it.json +++ b/locales/it.json @@ -105,7 +105,8 @@ "search_coordinates": "Cerca coordinate", "online": "Online", "show_preview": "Mostra anteprima", - "clone": "Clona" + "clone": "Clona", + "actors": "Nodo" }, "login": { "description": "Entrando puoi pubblicare nuovi eventi.", diff --git a/server/api/controller/instance.js b/server/api/controller/instance.js index 030bf4c1..47100d26 100644 --- a/server/api/controller/instance.js +++ b/server/api/controller/instance.js @@ -114,7 +114,9 @@ const instancesController = { } if (applicationActor) { + log.debug('[FEDI] This node supports FEP-2677') const actor = await getActor(applicationActor) + log.debug('[FEDI] Actor %s', actor) await actor.update({ friendly: true }) return res.json(actor) } diff --git a/server/federation/events.js b/server/federation/events.js index 7c7cacaf..17e5081d 100644 --- a/server/federation/events.js +++ b/server/federation/events.js @@ -14,12 +14,17 @@ module.exports = { const APEvent = req.body?.object // TODO: validate the event - + // check ap_id + // check location + // check // check if this event is new const ap_id = req.body.id const exists = await Event.findOne({ where: { ap_id }}) - if (exists) { return res.sendStatus(404)} + if (exists) { + log.warn('[FEDI] Avoid creating a duplicated event %s', ap_id) + return res.sendStatus(404) + } const place = await eventController._findOrCreatePlace({ place_name: APEvent.location?.name, @@ -27,10 +32,11 @@ module.exports = { }) let media = [] - if (APEvent.attachment.length > 0) { + if (APEvent?.attachment?.length > 0) { const image_url = APEvent.attachment[0]?.url req.file = await helpers.getImageFromURL(image_url) + log.debug('[FEDI] Download attachment for event %s', image_url) // let focalpoint = body.image_focalpoint ? body.image_focalpoint.split(',') : ['0', '0'] // focalpoint = [parseFloat(parseFloat(focalpoint[0]).toFixed(2)), parseFloat(parseFloat(focalpoint[1]).toFixed(2))] @@ -48,7 +54,7 @@ module.exports = { const event = await Event.create({ title: APEvent.name.trim(), start_datetime: dayjs(APEvent.startTime).unix(), - end_datetime: dayjs(APEvent.endTime).unix(), + end_datetime: APEvent?.endTime ? dayjs(APEvent.endTime).unix() : null, description: helpers.sanitizeHTML(linkifyHtml(APEvent.content)), media, is_visible: true, diff --git a/server/federation/helpers.js b/server/federation/helpers.js index 36316bcd..7e6325a3 100644 --- a/server/federation/helpers.js +++ b/server/federation/helpers.js @@ -165,17 +165,16 @@ const Helpers = { }) if (fedi_user) { - log.info(`Create a new AP User => ${URL}`) + log.info(`[FEDI] Create a new AP User => ${URL}`) fedi_user = await APUser.create({ ap_id: URL, object: fedi_user }) } return fedi_user }, - async getNodeInfo (instance_url) { let nodeInfo = await axios.get(`${instance_url}/.well-known/nodeinfo`, { headers: { Accept: 'application/json' } }).then(res => res.data) - if (nodeInfo.links) { + if (nodeInfo?.links) { const supportedVersion = nodeInfo.links.find(l => l.rel === 'http://nodeinfo.diaspora.software/ns/schema/2.1' || 'http://nodeinfo.diaspora.software/ns/schema/2.0') if (!supportedVersion) { return false diff --git a/server/federation/inbox.js b/server/federation/inbox.js index 5c7142c6..04e51a86 100644 --- a/server/federation/inbox.js +++ b/server/federation/inbox.js @@ -13,7 +13,7 @@ module.exports = async (req, res) => { return res.status(404).send('User not found') } - log.debug('[FEDI] %', message.type) + log.debug('[FEDI] %s', message.type) switch (message.type) { case 'Follow': Follows.follow(req, res) @@ -63,9 +63,9 @@ module.exports = async (req, res) => { log.debug('Create a resource!') await Resources.create(req, res) } else if (message.object.type === 'Event') { - log.debug(`Event is coming from ${res.locals.fedi_user.ap_id}`) + log.debug(`[FEDI] Event is coming from ${res.locals.fedi_user.ap_id}`) if (!res.locals.fedi_user.following || !res.locals.fedi_user.friendly) { - log.warn(`APUser not followed or not friendly`) + log.warn(`[FEDI] APUser not followed nor trusted`) return res.sendStatus(404) } await Events.create(req, res) diff --git a/server/federation/users.js b/server/federation/users.js index f43452b9..59f36135 100644 --- a/server/federation/users.js +++ b/server/federation/users.js @@ -34,6 +34,8 @@ module.exports = { // https://docs.joinmastodon.org/spec/activitypub/#Hashtag "Hashtag": "https://www.w3.org/ns/activitystreams#Hashtag", + manuallyApprovesFollowers: 'as:manuallyApprovesFollowers', + // focal point - https://docs.joinmastodon.org/spec/activitypub/#focalPoint "focalPoint": { "@container": "@list", @@ -48,7 +50,8 @@ module.exports = { preferredUsername: name, // settings.instance_place, inbox: `${config.baseurl}/federation/u/${name}/inbox`, outbox: `${config.baseurl}/federation/u/${name}/outbox`, - // endpoints: { sharedInbox: `${config.baseurl}/federation/u/${name}/inbox` }, + manuallyApprovesFollowers: false, + endpoints: { sharedInbox: `${config.baseurl}/federation/u/${name}/inbox` }, // followers: `${config.baseurl}/federation/u/${name}/followers`, discoverable: true, attachment: [