Unverified Commit 7d2ba379 authored by Hong Minhee's avatar Hong Minhee
Browse files

Get rid of Link from Collection and CollectionPage

parent fb3d8181
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -43,6 +43,17 @@ To be released.
 -  Added `Offer` class to Activity Vocabulary API.
    [[#65], [#76] by Lee Dogeon]

 -  The below properties of `Collection` and `CollectionPage` in Activity
    Vocabulary API now do not accept `Link` objects:

     -  `Collection.current`
     -  `Collection.first`
     -  `Collection.last`
     -  `Collection.items`
     -  `CollectionPage.partOf`
     -  `CollectionPage.next`
     -  `CollectionPage.prev`

 -  The key pair or the key pair for signing outgoing HTTP requests made from
    the shared inbox now can be configured.  This improves the compatibility
    with other ActivityPub implementations that require authorized fetches
+92 −232

File changed.

Preview size limit exceeded, changes collapsed.

+6 −7
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ import type { Recipient } from "../vocab/actor.ts";
import {
  Activity,
  type CryptographicKey,
  Link,
  Object,
  OrderedCollection,
  OrderedCollectionPage,
@@ -168,7 +167,7 @@ export interface CollectionHandlerParameters<TItem, TContextData, TFilter> {
}

export async function handleCollection<
  TItem extends URL | Object | Link | Recipient,
  TItem extends URL | Object | Recipient,
  TContextData,
  TFilter,
>(
@@ -278,16 +277,16 @@ export async function handleCollection<
  });
}

function filterCollectionItems<TItem extends Object | Link | Recipient | URL>(
function filterCollectionItems<TItem extends Object | Recipient | URL>(
  items: TItem[],
  collectionName: string,
  filterPredicate?: (item: TItem) => boolean,
): (Object | Link | URL)[] {
  const result: (Object | Link | URL)[] = [];
): (Object | URL)[] {
  const result: (Object | URL)[] = [];
  let logged = false;
  for (const item of items) {
    let mappedItem: Object | Link | URL;
    if (item instanceof Object || item instanceof Link || item instanceof URL) {
    let mappedItem: Object | URL;
    if (item instanceof Object || item instanceof URL) {
      mappedItem = item;
    } else if (item.id == null) continue;
    else mappedItem = item.id;
+8 −8
Original line number Diff line number Diff line
@@ -1298,7 +1298,7 @@ snapshot[`Deno.inspect(Collection) [auto] 1`] = `
  current: CollectionPage {},
  first: CollectionPage {},
  last: CollectionPage {},
  items: [ Object {}, Link {} ]
  items: [ Object {} ]
}'
`;

@@ -1415,8 +1415,8 @@ snapshot[`Deno.inspect(CollectionPage) [auto] 1`] = `
  current: CollectionPage {},
  first: CollectionPage {},
  last: CollectionPage {},
  items: [ Object {}, Link {} ],
  partOf: Link {},
  items: [ Object {} ],
  partOf: Collection {},
  next: CollectionPage {},
  prev: CollectionPage {}
}'
@@ -1500,7 +1500,7 @@ snapshot[`Deno.inspect(CollectionPage) [auto] 3`] = `
  first: CollectionPage {},
  last: CollectionPage {},
  items: [ Object {}, Object {} ],
  partOf: Link {},
  partOf: Collection {},
  next: CollectionPage {},
  prev: CollectionPage {}
}'
@@ -3401,7 +3401,7 @@ snapshot[`Deno.inspect(OrderedCollection) [auto] 1`] = `
  current: CollectionPage {},
  first: CollectionPage {},
  last: CollectionPage {},
  items: [ Object {}, Link {} ]
  items: [ Object {} ]
}'
`;

@@ -3518,8 +3518,8 @@ snapshot[`Deno.inspect(OrderedCollectionPage) [auto] 1`] = `
  current: CollectionPage {},
  first: CollectionPage {},
  last: CollectionPage {},
  items: [ Object {}, Link {} ],
  partOf: Link {},
  items: [ Object {} ],
  partOf: Collection {},
  next: CollectionPage {},
  prev: CollectionPage {},
  startIndex: 123
@@ -3605,7 +3605,7 @@ snapshot[`Deno.inspect(OrderedCollectionPage) [auto] 3`] = `
  first: CollectionPage {},
  last: CollectionPage {},
  items: [ Object {}, Object {} ],
  partOf: Link {},
  partOf: Collection {},
  next: CollectionPage {},
  prev: CollectionPage {},
  startIndex: 123
+0 −4
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ properties:
    the most recently updated member items.
  range:
  - "https://www.w3.org/ns/activitystreams#CollectionPage"
  - "https://www.w3.org/ns/activitystreams#Link"

- singularName: first
  functional: true
@@ -40,7 +39,6 @@ properties:
    items in the collection.
  range:
  - "https://www.w3.org/ns/activitystreams#CollectionPage"
  - "https://www.w3.org/ns/activitystreams#Link"

- singularName: last
  functional: true
@@ -50,7 +48,6 @@ properties:
    the collection.
  range:
  - "https://www.w3.org/ns/activitystreams#CollectionPage"
  - "https://www.w3.org/ns/activitystreams#Link"

- pluralName: items
  singularName: item
@@ -60,4 +57,3 @@ properties:
    or unordered.
  range:
  - "https://www.w3.org/ns/activitystreams#Object"
  - "https://www.w3.org/ns/activitystreams#Link"
Loading