Unverified Commit a509d6af authored by Hong Minhee's avatar Hong Minhee
Browse files

cli: NodeInfo for inbox

parent ff77b8a3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -34,12 +34,14 @@
  },
  "cSpell.words": [
    "aarch64",
    "activitypub",
    "codegen",
    "Deno",
    "denokv",
    "docloader",
    "fedify",
    "fediverse",
    "halfyear",
    "highligher",
    "hongminhee",
    "hono",
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
    "@poppanator/http-constants": "npm:@poppanator/http-constants@^1.1.1",
    "@std/fs": "jsr:@std/fs@^0.229.3",
    "@std/path": "jsr:@std/path@^0.225.1",
    "@std/semver": "jsr:@std/semver@^0.224.3",
    "cli-highlight": "npm:cli-highlight@^2.1.11",
    "hono": "jsr:@hono/hono@^4.4.6",
    "hono/": "jsr:/@hono/hono@^4.4.6/",
+22 −0
Original line number Diff line number Diff line
@@ -20,8 +20,10 @@ import {
  type Recipient,
} from "@fedify/fedify";
import { getLogger } from "@logtape/logtape";
import { parse } from "@std/semver";
import { Hono } from "hono";
import ora from "ora";
import metadata from "./deno.json" with { type: "json" };
import { getDocumentLoader } from "./docloader.ts";
import type { ActivityEntry } from "./inbox/entry.ts";
import { ActivityEntryPage, ActivityListPage } from "./inbox/view.tsx";
@@ -237,6 +239,26 @@ federation
  .setOutboxDispatcher("/{handle}/outbox", (_ctx, _handle) => null)
  .setCounter((_ctx, _handle) => 0);

federation.setNodeInfoDispatcher("/nodeinfo/2.1", (_ctx) => {
  return {
    software: {
      name: "fedify-cli",
      version: parse(metadata.version),
      repository: new URL("https://github.com/dahlia/fedify"),
    },
    protocols: ["activitypub"],
    usage: {
      users: {
        total: 1,
        activeMonth: 1,
        activeHalfyear: 1,
      },
      localComments: 0,
      localPosts: 0,
    },
  };
});

function printServerInfo(fedCtx: Context<number>): void {
  new Table(
    [