mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 00:52:01 +01:00
minor: improve AP logs
This commit is contained in:
parent
ca1bd2487c
commit
a8855e8157
7 changed files with 25 additions and 13 deletions
|
@ -107,7 +107,8 @@
|
||||||
"show_preview": "Show preview",
|
"show_preview": "Show preview",
|
||||||
"clone": "Clone",
|
"clone": "Clone",
|
||||||
"pin": "Pin",
|
"pin": "Pin",
|
||||||
"trusted_instances": "Trusted instances"
|
"trusted_instances": "Trusted instances",
|
||||||
|
"actors": "Node"
|
||||||
},
|
},
|
||||||
"login": {
|
"login": {
|
||||||
"description": "By logging in you can publish new events.",
|
"description": "By logging in you can publish new events.",
|
||||||
|
|
|
@ -105,7 +105,8 @@
|
||||||
"search_coordinates": "Cerca coordinate",
|
"search_coordinates": "Cerca coordinate",
|
||||||
"online": "Online",
|
"online": "Online",
|
||||||
"show_preview": "Mostra anteprima",
|
"show_preview": "Mostra anteprima",
|
||||||
"clone": "Clona"
|
"clone": "Clona",
|
||||||
|
"actors": "Nodo"
|
||||||
},
|
},
|
||||||
"login": {
|
"login": {
|
||||||
"description": "Entrando puoi pubblicare nuovi eventi.",
|
"description": "Entrando puoi pubblicare nuovi eventi.",
|
||||||
|
|
|
@ -114,7 +114,9 @@ const instancesController = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (applicationActor) {
|
if (applicationActor) {
|
||||||
|
log.debug('[FEDI] This node supports FEP-2677')
|
||||||
const actor = await getActor(applicationActor)
|
const actor = await getActor(applicationActor)
|
||||||
|
log.debug('[FEDI] Actor %s', actor)
|
||||||
await actor.update({ friendly: true })
|
await actor.update({ friendly: true })
|
||||||
return res.json(actor)
|
return res.json(actor)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,17 @@ module.exports = {
|
||||||
const APEvent = req.body?.object
|
const APEvent = req.body?.object
|
||||||
|
|
||||||
// TODO: validate the event
|
// TODO: validate the event
|
||||||
|
// check ap_id
|
||||||
|
// check location
|
||||||
|
// check
|
||||||
|
|
||||||
// check if this event is new
|
// check if this event is new
|
||||||
const ap_id = req.body.id
|
const ap_id = req.body.id
|
||||||
const exists = await Event.findOne({ where: { ap_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({
|
const place = await eventController._findOrCreatePlace({
|
||||||
place_name: APEvent.location?.name,
|
place_name: APEvent.location?.name,
|
||||||
|
@ -27,10 +32,11 @@ module.exports = {
|
||||||
})
|
})
|
||||||
|
|
||||||
let media = []
|
let media = []
|
||||||
if (APEvent.attachment.length > 0) {
|
if (APEvent?.attachment?.length > 0) {
|
||||||
|
|
||||||
const image_url = APEvent.attachment[0]?.url
|
const image_url = APEvent.attachment[0]?.url
|
||||||
req.file = await helpers.getImageFromURL(image_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']
|
// let focalpoint = body.image_focalpoint ? body.image_focalpoint.split(',') : ['0', '0']
|
||||||
// focalpoint = [parseFloat(parseFloat(focalpoint[0]).toFixed(2)), parseFloat(parseFloat(focalpoint[1]).toFixed(2))]
|
// focalpoint = [parseFloat(parseFloat(focalpoint[0]).toFixed(2)), parseFloat(parseFloat(focalpoint[1]).toFixed(2))]
|
||||||
|
@ -48,7 +54,7 @@ module.exports = {
|
||||||
const event = await Event.create({
|
const event = await Event.create({
|
||||||
title: APEvent.name.trim(),
|
title: APEvent.name.trim(),
|
||||||
start_datetime: dayjs(APEvent.startTime).unix(),
|
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)),
|
description: helpers.sanitizeHTML(linkifyHtml(APEvent.content)),
|
||||||
media,
|
media,
|
||||||
is_visible: true,
|
is_visible: true,
|
||||||
|
|
|
@ -165,17 +165,16 @@ const Helpers = {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (fedi_user) {
|
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 })
|
fedi_user = await APUser.create({ ap_id: URL, object: fedi_user })
|
||||||
}
|
}
|
||||||
return fedi_user
|
return fedi_user
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
async getNodeInfo (instance_url) {
|
async getNodeInfo (instance_url) {
|
||||||
let nodeInfo = await axios.get(`${instance_url}/.well-known/nodeinfo`, { headers: { Accept: 'application/json' } }).then(res => res.data)
|
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')
|
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) {
|
if (!supportedVersion) {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -13,7 +13,7 @@ module.exports = async (req, res) => {
|
||||||
return res.status(404).send('User not found')
|
return res.status(404).send('User not found')
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug('[FEDI] %', message.type)
|
log.debug('[FEDI] %s', message.type)
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case 'Follow':
|
case 'Follow':
|
||||||
Follows.follow(req, res)
|
Follows.follow(req, res)
|
||||||
|
@ -63,9 +63,9 @@ module.exports = async (req, res) => {
|
||||||
log.debug('Create a resource!')
|
log.debug('Create a resource!')
|
||||||
await Resources.create(req, res)
|
await Resources.create(req, res)
|
||||||
} else if (message.object.type === 'Event') {
|
} 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) {
|
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)
|
return res.sendStatus(404)
|
||||||
}
|
}
|
||||||
await Events.create(req, res)
|
await Events.create(req, res)
|
||||||
|
|
|
@ -34,6 +34,8 @@ module.exports = {
|
||||||
// https://docs.joinmastodon.org/spec/activitypub/#Hashtag
|
// https://docs.joinmastodon.org/spec/activitypub/#Hashtag
|
||||||
"Hashtag": "https://www.w3.org/ns/activitystreams#Hashtag",
|
"Hashtag": "https://www.w3.org/ns/activitystreams#Hashtag",
|
||||||
|
|
||||||
|
manuallyApprovesFollowers: 'as:manuallyApprovesFollowers',
|
||||||
|
|
||||||
// focal point - https://docs.joinmastodon.org/spec/activitypub/#focalPoint
|
// focal point - https://docs.joinmastodon.org/spec/activitypub/#focalPoint
|
||||||
"focalPoint": {
|
"focalPoint": {
|
||||||
"@container": "@list",
|
"@container": "@list",
|
||||||
|
@ -48,7 +50,8 @@ module.exports = {
|
||||||
preferredUsername: name, // settings.instance_place,
|
preferredUsername: name, // settings.instance_place,
|
||||||
inbox: `${config.baseurl}/federation/u/${name}/inbox`,
|
inbox: `${config.baseurl}/federation/u/${name}/inbox`,
|
||||||
outbox: `${config.baseurl}/federation/u/${name}/outbox`,
|
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`,
|
// followers: `${config.baseurl}/federation/u/${name}/followers`,
|
||||||
discoverable: true,
|
discoverable: true,
|
||||||
attachment: [
|
attachment: [
|
||||||
|
|
Loading…
Reference in a new issue