diff --git a/src/dv/index.ts b/src/dv/index.ts index ac11a11..a0a851f 100644 --- a/src/dv/index.ts +++ b/src/dv/index.ts @@ -1,15 +1,16 @@ // deno-lint-ignore-file require-await -import { createFederation, Person, Application, Image, PropertyValue, Organization, Federation, KvStore, Context, Actor, Follow, Endpoints, importSpki, importJwk, NodeInfo, Accept } from "@fedify/fedify" +import { createFederation, Person, Application, Image, PropertyValue, Organization, Federation, Context, Actor, Follow, Endpoints, importJwk, Accept } from "@fedify/fedify" import { getLogger } from "https://jsr.io/@logtape/logtape/0.6.3/logtape/logger.ts" import { escapeHtml } from "@@x/escape" import { StratzAPI } from "../stratz/api.ts" import { Database } from "../database/index.ts" +import { handleNodeInfo } from "./nodeinfo.ts" const l = getLogger(["dotino-veloce", "dv", "index"]) -type ContextData = undefined +export type ContextData = undefined export class DotinoVeloce { @@ -39,31 +40,7 @@ export class DotinoVeloce { .on(Follow, this.#followHandler.bind(this)) this.federation - .setNodeInfoDispatcher("/nodeinfo/2.1", this.#nodeInfoHandler.bind(this)) - } - - async #nodeInfoHandler(_ctx: Context): Promise { - return { - software: { - name: "dotino-veloce", - version: { - major: 0, - minor: 1, - patch: 0, - }, - repository: new URL("https://forge.steffo.eu/steffo/dotino-veloce"), - }, - protocols: ["activitypub"], - usage: { - users: { - total: 0, - activeHalfyear: 0, - activeMonth: 0, - }, - localPosts: 0, - localComments: 0, - } - } + .setNodeInfoDispatcher("/nodeinfo/2.1", handleNodeInfo) } async #commonActorProperties(ctx: Context, handle: string): Promise> { diff --git a/src/dv/nodeinfo.ts b/src/dv/nodeinfo.ts new file mode 100644 index 0000000..f29e0af --- /dev/null +++ b/src/dv/nodeinfo.ts @@ -0,0 +1,33 @@ +import { Context, NodeInfo } from "@fedify/fedify" +import { ContextData } from "./index.ts" +import { getLogger } from "@logtape/logtape" + + +const l = getLogger(["dotino-veloce", "dv", "nodeinfo"]) + + +export function handleNodeInfo(_ctx: Context): NodeInfo { + l.info`Creating nodeinfo for...` + + return { + software: { + name: "dotino-veloce", + version: { + major: 0, + minor: 1, + patch: 0, + }, + repository: new URL("https://forge.steffo.eu/steffo/dotino-veloce"), + }, + protocols: ["activitypub"], + usage: { + users: { + total: 0, + activeHalfyear: 0, + activeMonth: 0, + }, + localPosts: 0, + localComments: 0, + } + } +} \ No newline at end of file