kopia lustrzana https://github.com/Stopka/fedicrawl
If nodeinfo refresh is failed, software name and version is unset
rodzic
a8e6dbdb9d
commit
87f5ddc8b1
|
@ -6,10 +6,10 @@ import RobotsTxt from '../RobotsTxt/RobotsTxt.js'
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
name: z.string().optional(),
|
name: z.string().optional(),
|
||||||
software: z.object({
|
software: z.object({
|
||||||
name: z.string(),
|
name: z.string().nullable(),
|
||||||
version: z.string()
|
version: z.string().nullable()
|
||||||
}),
|
}),
|
||||||
protocols: z.array(z.string()),
|
protocols: z.array(z.string()).optional(),
|
||||||
usage: z.optional(
|
usage: z.optional(
|
||||||
z.object({
|
z.object({
|
||||||
users: z.optional(
|
users: z.optional(
|
||||||
|
|
|
@ -14,7 +14,12 @@ export const refreshNodeInfo = async (
|
||||||
const nodeInfo = await retrieveDomainNodeInfo(node.domain, robotsTxt)
|
const nodeInfo = await retrieveDomainNodeInfo(node.domain, robotsTxt)
|
||||||
return await updateNodeInfo(elastic, node, nodeInfo)
|
return await updateNodeInfo(elastic, node, nodeInfo)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Failed to update node info', error)
|
console.warn('Failed to update node info, unsetting node', error)
|
||||||
return node
|
return await updateNodeInfo(elastic, node, {
|
||||||
|
software: {
|
||||||
|
name: null,
|
||||||
|
version: null
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ export const updateNodeInfo = async (
|
||||||
doc: {
|
doc: {
|
||||||
name: nodeInfo?.name,
|
name: nodeInfo?.name,
|
||||||
openRegistrations: nodeInfo?.openRegistrations,
|
openRegistrations: nodeInfo?.openRegistrations,
|
||||||
softwareName: nodeInfo?.software?.name?.toLocaleLowerCase(),
|
softwareName: nodeInfo?.software?.name?.toLocaleLowerCase() ?? null,
|
||||||
softwareVersion: nodeInfo?.software?.version,
|
softwareVersion: nodeInfo?.software?.version ?? null,
|
||||||
halfYearActiveUserCount: assertPositiveInt(
|
halfYearActiveUserCount: assertPositiveInt(
|
||||||
nodeInfo?.usage?.users?.activeHalfyear
|
nodeInfo?.usage?.users?.activeHalfyear
|
||||||
),
|
),
|
||||||
|
@ -40,6 +40,6 @@ export const updateNodeInfo = async (
|
||||||
await getNode(elastic, node.domain),
|
await getNode(elastic, node.domain),
|
||||||
'Missing node after updating it'
|
'Missing node after updating it'
|
||||||
)
|
)
|
||||||
console.info('Updated node info', { node })
|
console.info('Updated node info', { resultNode })
|
||||||
return resultNode
|
return resultNode
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue