Unverified Commit 3f646890 authored by Hong Minhee's avatar Hong Minhee
Browse files

Relaxed the required type for activity recipients

parent 59ffb097
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -8,6 +8,14 @@ Version 0.8.0

To be released.

 -  Relaxed the required type for activity recipients. 

     -  Added `Recipient` interface.
     -  The type of the second parameter of `Context.sendActivity()` method
        became `Recipient | Recipient[]` (was `Actor | Actor[]`).  However,
        since `Recipient` is a supertype of `Actor`, the existing code should
        work without any change.


Version 0.7.0
-------------
+12 −6
Original line number Diff line number Diff line
@@ -39,12 +39,12 @@ To send an activity to another actor, you can use the `Context.sendActivity()`
method.  The following shows how to send a `Follow` activity to another actor:

~~~~ typescript{8-15}
import { Actor, Context, Follow } from "@fedify/fedify";
import { Context, Follow, Recipient } from "@fedify/fedify";

async function sendFollow(
  ctx: Context<void>,
  senderHandle: string,
  recipient: Actor,
  recipient: Recipient,
) {
  await ctx.sendActivity(
    { handle: senderHandle },
@@ -101,12 +101,12 @@ You can do this by calling the `~Context.sendActivity()` method with the


~~~~ typescript
import { Actor, Context, Follow } from "@fedify/fedify";
import { Context, Follow, Recipient } from "@fedify/fedify";

async function sendFollow(
  ctx: Context<void>,
  senderHandle: string,
  recipient: Actor,
  recipient: Recipient,
) {
  await ctx.sendActivity(
    { handle: senderHandle },
@@ -132,12 +132,18 @@ recipient's personal inbox. To deliver an activity to the shared inbox,
you can pass the `preferSharedInbox` option:

~~~~ typescript
import { Actor, Context, Create, Note, PUBLIC_COLLECTION } from "@fedify/fedify";
import {
  Context,
  Create,
  Note,
  Recipient,
  PUBLIC_COLLECTION,
} from "@fedify/fedify";

async function sendNote(
  ctx: Context<void>,
  senderHandle: string,
  recipient: Actor,
  recipient: Recipient,
) {
  await ctx.sendActivity(
    { handle: senderHandle },
+2 −2
Original line number Diff line number Diff line
import type { DocumentLoader } from "../runtime/docloader.ts";
import type { Actor } from "../vocab/actor.ts";
import type { Actor, Recipient } from "../vocab/actor.ts";
import type { Activity, CryptographicKey, Object } from "../vocab/mod.ts";

/**
@@ -137,7 +137,7 @@ export interface Context<TContextData> {
   */
  sendActivity(
    sender: { keyId: URL; privateKey: CryptoKey } | { handle: string },
    recipients: Actor | Actor[],
    recipients: Recipient | Recipient[],
    activity: Activity,
    options?: SendActivityOptions,
  ): Promise<void>;
+3 −3
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ import {
  getAuthenticatedDocumentLoader,
  kvCache,
} from "../runtime/docloader.ts";
import type { Actor } from "../vocab/actor.ts";
import type { Actor, Recipient } from "../vocab/actor.ts";
import { Activity, CryptographicKey, type Object } from "../vocab/mod.ts";
import { handleWebFinger } from "../webfinger/handler.ts";
import type {
@@ -431,7 +431,7 @@ export class Federation<TContextData> {
      getDocumentLoader,
      sendActivity: async (
        sender: { keyId: URL; privateKey: CryptoKey } | { handle: string },
        recipients: Actor | Actor[],
        recipients: Recipient | Recipient[],
        activity: Activity,
        options: SendActivityOptions = {},
      ): Promise<void> => {
@@ -1008,7 +1008,7 @@ export class Federation<TContextData> {
   */
  async sendActivity(
    { keyId, privateKey }: { keyId: URL; privateKey: CryptoKey },
    recipients: Actor | Actor[],
    recipients: Recipient | Recipient[],
    activity: Activity,
    { preferSharedInbox, immediate }: SendActivityOptions = {},
  ): Promise<void> {
+2 −2
Original line number Diff line number Diff line
import { getLogger } from "@logtape/logtape";
import { sign } from "../httpsig/mod.ts";
import type { DocumentLoader } from "../runtime/docloader.ts";
import type { Actor } from "../vocab/actor.ts";
import type { Recipient } from "../vocab/actor.ts";
import type { Activity } from "../vocab/mod.ts";

/**
@@ -11,7 +11,7 @@ export interface ExtractInboxesParameters {
  /**
   * Actors to extract the inboxes from.
   */
  recipients: Actor[];
  recipients: Recipient[];

  /**
   * Whether to prefer the shared inbox over the personal inbox.
Loading