From e97b86f9830b02b522bf161eef783b1fd26dba78 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Sun, 3 Nov 2024 12:43:27 +0100 Subject: [PATCH] feat: :sparkles: Add collections field to Notes --- app/changelog/page.mdx | 2 + app/entities/note/page.mdx | 29 ++++++++++++ app/extensions/custom-emojis/page.mdx | 4 ++ app/extensions/interaction-controls/page.mdx | 4 ++ app/extensions/likes/page.mdx | 19 ++++++++ app/extensions/polls/page.mdx | 4 ++ app/extensions/reactions/page.mdx | 50 +++++--------------- app/extensions/share/page.mdx | 17 +++++++ app/structures/collection/page.mdx | 4 ++ 9 files changed, 95 insertions(+), 38 deletions(-) diff --git a/app/changelog/page.mdx b/app/changelog/page.mdx index 746644d..70a0db6 100644 --- a/app/changelog/page.mdx +++ b/app/changelog/page.mdx @@ -24,6 +24,8 @@ This page lists changes since Working Draft 3. {{ className: 'lead' }} - Added [Interaction Controls Extensions](/extensions/interaction-controls) - Added [URI Collections](/structures/collection#uri-collection) - Changed all Collections that can contain remote entities to use URI Collections (eg. [User](/entities/user) `collections.followers`). +- Add `collections` field to [Notes](/entities/note). + - [Likes Extension](/extensions/likes), [Reactions Extension](/extensions/reactions) and [Share Extension](/extensions/share) now use this field, instead of a custom field in `extensions`. ## Since WD 3 diff --git a/app/entities/note/page.mdx b/app/entities/note/page.mdx index 7a3f363..79f71a5 100644 --- a/app/entities/note/page.mdx +++ b/app/entities/note/page.mdx @@ -36,6 +36,28 @@ Notes represent a piece of content on a Versia instance. They can be posted by [ | "messaging"; // Like Discord, Element (Matrix), Signal ``` + + Collections related to the note. Must contain at least `replies` and `quotes`. + + ```typescript + type URI = string; + + type NoteCollections = { + replies: URI; + quotes: URI; + // Same format as type on Extensions + [key: ExtensionsKey]: URI; + } + ``` + + All URIs must resolve to either a [Collection](/structures/collection) or a [URI Collection](/structures/collection#uri-collection) of the appropriate entities. Extensions may add additional collections. + + ### Replies + All replies to this note (have this note as their `replies_to`). [URI Collection](/structures/collection#uri-collection) of [Note](/entities/note) entities. + + ### Quotes + All quotes of this note (have this note as their `quotes`). [URI Collection](/structures/collection#uri-collection) of [Note](/entities/note) entities. + The content of the note. Must be text format (`text/html`, `text/markdown`, etc). Must not be remote. @@ -126,6 +148,13 @@ Notes represent a piece of content on a Versia instance. They can be posted by [ ], "author": "https://versia.social/users/018eb863-753f-76ff-83d6-fd590de7740a", "category": "microblog", + "collections": { + "replies": "https://versia.social/objects/01902e09-0f8b-72de-8ee3-9afc0cf5eae1/replies", + "quotes": "https://versia.social/objects/01902e09-0f8b-72de-8ee3-9afc0cf5eae1/quotes", + "pub.versia:likes/Likes": "https://versia.social/objects/01902e09-0f8b-72de-8ee3-9afc0cf5eae1/likes", + "pub.versia:likes/Dislikes": "https://versia.social/objects/01902e09-0f8b-72de-8ee3-9afc0cf5eae1/dislikes", + "pub.versia:reactions/Reactions": "https://versia.social/objects/01902e09-0f8b-72de-8ee3-9afc0cf5eae1/reactions" + }, "content": { "text/html": { "content": "

In the next versia-fe update: account settings, finally!

" diff --git a/app/extensions/custom-emojis/page.mdx b/app/extensions/custom-emojis/page.mdx index cf491ed..c9cf810 100644 --- a/app/extensions/custom-emojis/page.mdx +++ b/app/extensions/custom-emojis/page.mdx @@ -87,6 +87,10 @@ Custom Emojis can be added to any entity with text content. The extension ID is "type": "Note", "uri": "https://versia.social/notes/456df8ed-daf1-4062-abab-491071c7b8dd", "created_at": "2024-04-09T01:38:51.743Z", + "collections": { + "replies": "https://versia.social/notes/456df8ed-daf1-4062-abab-491071c7b8dd/replies", + "quotes": "https://versia.social/notes/456df8ed-daf1-4062-abab-491071c7b8dd/quotes" + }, "content": { "text/plain": { "content": "Hello, world :happy_face:!" diff --git a/app/extensions/interaction-controls/page.mdx b/app/extensions/interaction-controls/page.mdx index 682a9c1..12931da 100644 --- a/app/extensions/interaction-controls/page.mdx +++ b/app/extensions/interaction-controls/page.mdx @@ -17,6 +17,10 @@ The entity defined in this document must be inserted in the `pub.versia:interact "type": "Note", "uri": "https://versia.social/notes/456df8ed-daf1-4062-abab-491071c7b8dd", "created_at": "2024-04-09T01:38:51.743Z", + "collections": { + "replies": "https://versia.social/notes/456df8ed-daf1-4062-abab-491071c7b8dd/replies", + "quotes": "https://versia.social/notes/456df8ed-daf1-4062-abab-491071c7b8dd/quotes" + }, "content": { "text/plain": { "content": "Hello, world :happy_face:!" diff --git a/app/extensions/likes/page.mdx b/app/extensions/likes/page.mdx index 20a36ff..569360e 100644 --- a/app/extensions/likes/page.mdx +++ b/app/extensions/likes/page.mdx @@ -107,6 +107,25 @@ The Likes extension adds the following collections to the [User](/entities/user) } ``` +## Note Collections + +The Likes extension adds the following collections to the [Note](/entities/note) entity: + +- `likes`: A [URI Collection](/structures/collection#uri-collection) of all the likes the note has received. +- `dislikes`: A [URI Collection](/structures/collection#uri-collection) of all the dislikes the note has received. + +```jsonc +{ + "type": "Note", + ... + "collections": { + ... + "pub.versia:likes/Likes": "https://example.com/notes/fmKZ763jzIU8/likes", + "pub.versia:likes/Dislikes": "https://example.com/notes/fmKZ763jzIU8/dislikes" + } +} +``` + ## Interaction Types diff --git a/app/extensions/polls/page.mdx b/app/extensions/polls/page.mdx index 71e4bdb..71e8209 100644 --- a/app/extensions/polls/page.mdx +++ b/app/extensions/polls/page.mdx @@ -45,6 +45,10 @@ Note that there is no `question` field: the question should be included in the ` "created_at": "2024-06-19T01:07:44.139Z", "author": "https://versia.social/users/018eb863-753f-76ff-83d6-fd590de7740a", "category": "microblog", + "collections": { + "replies": "https://versia.social/notes/01902e09-0f8b-72de-8ee3-9afc0cf5eae1/replies", + "quotes": "https://versia.social/notes/01902e09-0f8b-72de-8ee3-9afc0cf5eae1/quotes" + }, "content": { "text/plain": { "content": "What is your favourite color?" diff --git a/app/extensions/reactions/page.mdx b/app/extensions/reactions/page.mdx index 687c861..035dccc 100644 --- a/app/extensions/reactions/page.mdx +++ b/app/extensions/reactions/page.mdx @@ -50,48 +50,22 @@ User reactions are (like every other entity) federated to all followers, and can -## Extensions to Note +## Note Collections -The Reactions Extension extends the [Note](/entities/note) entity with the following fields: +The Likes extension adds the following collections to the [Note](/entities/note) entity: - - - - - URI to a [URI Collection](/structures/collection#uri-collection) of the [Reactions](#entity-definition) attached to the note. - - - +- `reactions`: A [URI Collection](/structures/collection#uri-collection) of all the reactions to the note. - - - ```jsonc {{ title: "Example Note" }} - { - "id": "01902e09-0f8b-72de-8ee3-9afc0cf5eae1", - "type": "Note", // [!code focus] - "uri": "https://versia.social/notes/01902e09-0f8b-72de-8ee3-9afc0cf5eae1", - "created_at": "2024-06-19T01:07:44.139Z", - "author": "https://versia.social/users/018eb863-753f-76ff-83d6-fd590de7740a", - "category": "microblog", - "content": { - "text/plain": { - "content": "Bababooey." - } - }, - "extensions": { // [!code focus:5] - "pub.versia:reactions": { - "reactions": "https://versia.social/notes/01902e09-0f8b-72de-8ee3-9afc0cf5eae1/reactions" - } - }, - "group": "public", - "is_sensitive": false, - "mentions": [], +```jsonc +{ + "type": "Note", + ... + "collections": { + ... + "pub.versia:reactions/Reactions": "https://example.com/publications/f08a124e-fe90-439e-8be4-15a428a72a19/reactions" } - - ``` - - - +} +``` ## Interaction Types diff --git a/app/extensions/share/page.mdx b/app/extensions/share/page.mdx index 7bfde0d..7e2e328 100644 --- a/app/extensions/share/page.mdx +++ b/app/extensions/share/page.mdx @@ -46,6 +46,23 @@ When a user shares a note, the note's original author **must** receive the entit +## Note Collections + +The Share extension adds the following collections to the [Note](/entities/note) entity: + +- `shares`: A [URI Collection](/structures/collection#uri-collection) of all the shares of the note. + +```jsonc +{ + "type": "Note", + ... + "collections": { + ... + "pub.versia:share/Shares": "https://example.com/notes/fmKZ763jzIU8/shares" + } +} +``` + ## Interaction Types diff --git a/app/structures/collection/page.mdx b/app/structures/collection/page.mdx index 9140a24..8af34c0 100644 --- a/app/structures/collection/page.mdx +++ b/app/structures/collection/page.mdx @@ -65,6 +65,10 @@ Pages should be limited to a reasonable number of entities, such as 20 or 80. "type": "Note", "uri": "https://versia.social/notes/456df8ed-daf1-4062-abab-491071c7b8dd", "created_at": "2024-04-09T01:38:51.743Z", + "collections": { + "replies": "https://versia.social/notes/456df8ed-daf1-4062-abab-491071c7b8dd/replies", + "quotes": "https://versia.social/notes/456df8ed-daf1-4062-abab-491071c7b8dd/quotes" + }, "content": { "text/plain": { "content": "Hello, world!"