Commit 7c51f4d4 authored by Kim, Hyeonseo's avatar Kim, Hyeonseo Committed by Hyeonseo Kim
Browse files

change: WebFingerLinkDispatcher to WebFingerLinksDispatcher

parent 81f48910
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import type {
  ObjectAuthorizePredicate,
  ObjectDispatcher,
  SharedInboxKeyDispatcher,
  WebFingerLinkDispatcher,
  WebFingerLinksDispatcher,
} from "./callback.ts";
import type { Context, RequestContext } from "./context.ts";
import type {
@@ -49,7 +49,7 @@ export class FederationBuilderImpl<TContextData>
  router: Router;
  actorCallbacks?: ActorCallbacks<TContextData>;
  nodeInfoDispatcher?: NodeInfoDispatcher<TContextData>;
  webFingerDispatcher?: WebFingerLinkDispatcher<TContextData>;
  webFingerLinksDispatcher?: WebFingerLinksDispatcher<TContextData>;
  objectCallbacks: Record<string, ObjectCallbacks<TContextData, string>>;
  objectTypeIds: Record<
    string,
@@ -150,7 +150,7 @@ export class FederationBuilderImpl<TContextData>
      ? undefined
      : { ...this.actorCallbacks };
    f.nodeInfoDispatcher = this.nodeInfoDispatcher;
    f.webFingerDispatcher = this.webFingerDispatcher;
    f.webFingerLinksDispatcher = this.webFingerLinksDispatcher;
    f.objectCallbacks = { ...this.objectCallbacks };
    f.objectTypeIds = { ...this.objectTypeIds };
    f.inboxPath = this.inboxPath;
@@ -494,10 +494,10 @@ export class FederationBuilderImpl<TContextData>
    this.nodeInfoDispatcher = dispatcher;
  }

  setWebFingerLinkDispatcher(
    dispatcher: WebFingerLinkDispatcher<TContextData>,
  setWebFingerLinksDispatcher(
    dispatcher: WebFingerLinksDispatcher<TContextData>,
  ): void {
    this.webFingerDispatcher = dispatcher;
    this.webFingerLinksDispatcher = dispatcher;
  }

  setObjectDispatcher<TObject extends Object, TParam extends string>(
+3 −2
Original line number Diff line number Diff line
@@ -21,9 +21,10 @@ export type NodeInfoDispatcher<TContextData> = (
 *
 * @template TContextData The context data to pass to the {@link Context}.
 */
export type WebFingerLinkDispatcher<TContextData> = (
export type WebFingerLinksDispatcher<TContextData> = (
  context: RequestContext<TContextData>,
) => Link[] | Promise<Link[]>;
  resource: URL,
) => readonly Link[] | Promise<readonly Link[]>;

/**
 * A callback that dispatches an {@link Actor} object.
+3 −3
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import type {
  ObjectDispatcher,
  OutboxErrorHandler,
  SharedInboxKeyDispatcher,
  WebFingerLinkDispatcher,
  WebFingerLinksDispatcher,
} from "./callback.ts";
import type { Context, RequestContext } from "./context.ts";
import type { KvStore } from "./kv.ts";
@@ -84,8 +84,8 @@ export interface Federatable<TContextData> {
   * Registers a links dispatcher to WebFinger
   * @param dispatcher A links dispatcher callback to register.
   */
  setWebFingerLinkDispatcher(
    dispatcher: WebFingerLinkDispatcher<TContextData>,
  setWebFingerLinksDispatcher(
    dispatcher: WebFingerLinksDispatcher<TContextData>,
  ): void;

  /**
+2 −2
Original line number Diff line number Diff line
@@ -16,9 +16,9 @@ import {
  ATTR_HTTP_RESPONSE_STATUS_CODE,
  ATTR_URL_FULL,
} from "@opentelemetry/semantic-conventions";
import metadata from "../../deno.json" with { type: "json" };
import { getDefaultActivityTransformers } from "../compat/transformers.ts";
import type { ActivityTransformer } from "../compat/types.ts";
import metadata from "../../deno.json" with { type: "json" };
import { getNodeInfo, type GetNodeInfoOptions } from "../nodeinfo/client.ts";
import { handleNodeInfo, handleNodeInfoJrd } from "../nodeinfo/handler.ts";
import type { JsonValue, NodeInfo } from "../nodeinfo/types.ts";
@@ -1280,7 +1280,7 @@ export class FederationImpl<TContextData>
          actorDispatcher: this.actorCallbacks?.dispatcher,
          actorHandleMapper: this.actorCallbacks?.handleMapper,
          actorAliasMapper: this.actorCallbacks?.aliasMapper,
          webFingerLinkDispatcher: this.webFingerDispatcher,
          webFingerLinksDispatcher: this.webFingerLinksDispatcher,
          onNotFound,
          tracer,
        });
+4 −4
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ import type {
  ActorAliasMapper,
  ActorDispatcher,
  ActorHandleMapper,
  WebFingerLinkDispatcher,
  WebFingerLinksDispatcher,
} from "../federation/callback.ts";
import type { RequestContext } from "../federation/context.ts";
import { MemoryKvStore } from "../federation/kv.ts";
@@ -540,8 +540,8 @@ test("handleWebFinger()", async (t) => {
    assertEquals(await response.json(), expectedForHostnameWithPort);
  });

  await t.step("webFingerLinkDispatcher", async () => {
    const webFingerLinkDispatcher: WebFingerLinkDispatcher<void> = (_ctx) => {
  await t.step("webFingerLinksDispatcher", async () => {
    const webFingerLinksDispatcher: WebFingerLinksDispatcher<void> = (_ctx) => {
      return [
        {
          rel: "http://ostatus.org/schema/1.0/subscribe",
@@ -557,7 +557,7 @@ test("handleWebFinger()", async (t) => {
    const response = await handleWebFinger(request, {
      context,
      actorDispatcher,
      webFingerLinkDispatcher,
      webFingerLinksDispatcher,
      onNotFound,
    });

Loading