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({
|
||||
name: z.string().optional(),
|
||||
software: z.object({
|
||||
name: z.string(),
|
||||
version: z.string()
|
||||
name: z.string().nullable(),
|
||||
version: z.string().nullable()
|
||||
}),
|
||||
protocols: z.array(z.string()),
|
||||
protocols: z.array(z.string()).optional(),
|
||||
usage: z.optional(
|
||||
z.object({
|
||||
users: z.optional(
|
||||
|
|
|
@ -14,7 +14,12 @@ export const refreshNodeInfo = async (
|
|||
const nodeInfo = await retrieveDomainNodeInfo(node.domain, robotsTxt)
|
||||
return await updateNodeInfo(elastic, node, nodeInfo)
|
||||
} catch (error) {
|
||||
console.warn('Failed to update node info', error)
|
||||
return node
|
||||
console.warn('Failed to update node info, unsetting node', error)
|
||||
return await updateNodeInfo(elastic, node, {
|
||||
software: {
|
||||
name: null,
|
||||
version: null
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ export const updateNodeInfo = async (
|
|||
doc: {
|
||||
name: nodeInfo?.name,
|
||||
openRegistrations: nodeInfo?.openRegistrations,
|
||||
softwareName: nodeInfo?.software?.name?.toLocaleLowerCase(),
|
||||
softwareVersion: nodeInfo?.software?.version,
|
||||
softwareName: nodeInfo?.software?.name?.toLocaleLowerCase() ?? null,
|
||||
softwareVersion: nodeInfo?.software?.version ?? null,
|
||||
halfYearActiveUserCount: assertPositiveInt(
|
||||
nodeInfo?.usage?.users?.activeHalfyear
|
||||
),
|
||||
|
@ -40,6 +40,6 @@ export const updateNodeInfo = async (
|
|||
await getNode(elastic, node.domain),
|
||||
'Missing node after updating it'
|
||||
)
|
||||
console.info('Updated node info', { node })
|
||||
console.info('Updated node info', { resultNode })
|
||||
return resultNode
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue