Unverified Commit 6ef7c7a4 authored by Hong Minhee's avatar Hong Minhee
Browse files

Add PUBLIC_COLLECTION constant for public addressing

parent 13cd1a05
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -8,6 +8,10 @@ Version 0.7.0

To be released.

 -  Added `PUBLIC_COLLECTION` constant for [public addressing].

[public addressing]: https://www.w3.org/TR/activitypub/#public-addressing


Version 0.6.0
-------------
+8 −5
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ recipient's personal inbox. To deliver an activity to the shared inbox,
you can pass the `preferSharedInbox` option:

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

async function sendNote(
  ctx: Context<void>,
@@ -144,10 +144,10 @@ async function sendNote(
    recipient,
    new Create({
      actor: ctx.getActorUri(senderHandle),
      to: new URL("https://www.w3.org/ns/activitystreams#Public"),
      to: PUBLIC_COLLECTION,
      object: new Note({
        attribution: ctx.getActorUri(senderHandle),
        to: new URL("https://www.w3.org/ns/activitystreams#Public"),
        to: PUBLIC_COLLECTION,
      }),
    }),
    { preferSharedInbox: true },  // [!code highlight]
@@ -156,9 +156,12 @@ async function sendNote(
~~~~

> [!TIP]
> <https://www.w3.org/ns/activitystreams#Public> is a special IRI that
> `PUBLIC_COLLECTION` constant contains a `URL` object of
> <https://www.w3.org/ns/activitystreams#Public>, a special IRI that
> represents the public audience.  By setting the `to` property to this IRI,
> the activity is visible to everyone.
> the activity is visible to everyone.  See also the [*Public Addressing*
> section](https://www.w3.org/TR/activitypub/#public-addressing) in the
> ActivityPub specification.

> [!NOTE]
> To deliver an activity to the shared inbox, the recipient server must support

vocab/constants.ts

0 → 100644
+11 −0
Original line number Diff line number Diff line
/**
 * The special public collection for [public addressing].  *Do not mutate this
 * object.*
 *
 * [public addressing]: https://www.w3.org/TR/activitypub/#public-addressing
 *
 * @since 0.7.0
 */
export const PUBLIC_COLLECTION: URL = new URL(
  "https://www.w3.org/ns/activitystreams#Public",
);
+1 −0
Original line number Diff line number Diff line
@@ -50,5 +50,6 @@
 * @module
 */
export * from "./actor.ts";
export * from "./constants.ts";
export * from "./lookup.ts";
export * from "./vocab.ts";