mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +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",
|
||||
"clone": "Clone",
|
||||
"pin": "Pin",
|
||||
"trusted_instances": "Trusted instances"
|
||||
"trusted_instances": "Trusted instances",
|
||||
"actors": "Node"
|
||||
},
|
||||
"login": {
|
||||
"description": "By logging in you can publish new events.",
|
||||
|
|
|
@ -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.",
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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: [
|
||||
|
|
Loading…
Reference in a new issue