refactor: 📝 Rework Patch

This commit is contained in:
Jesse Wierzbinski 2024-08-02 16:10:27 +02:00
parent 5e6d30dfde
commit 970673d011
No known key found for this signature in database
2 changed files with 4 additions and 46 deletions

View file

@ -5,28 +5,15 @@ export const metadata = {
# Patches
Patches represent changes to `Note` entities. They can be used to edit notes after their creation, such as fixing typos or adding more content. Patches are applied to notes by the author or by a moderator. {{ className: 'lead' }}
## Why Patches?
The reason why patches are used instead of editing the note directly is to preserve the history of the note. This is important for transparency and accountability. By using patches, users can see the original content of the note and all changes made to it.
This is less important for other entities, such as `User` profiles, as their content is more disposable than notes.
## Structure
`Patch`es are extensions of the `Note` entity, with the type set to `Patch` and extra attributes defined below. Note that each subsequent patch is applied to the original object, not the preceding patch. The server is responsible for presenting the most recent patch stored to the client.
Patches are entities that indicate a change to another entity. They are sent to instances as a kind of "reindex this entity" message. Patches are used to update entities that have already been distributed to other instances.
## Entity Definition
<Row>
<Col>
<Properties>
<Property name="patched_id" type="UUID" required={true} typeLink="/types#uuid">
ID of the note that was patched. The Patch's `id` property should be used to identify the patch itself.
</Property>
<Property name="patched_at" type="ISO8601" required={true} typeLink="/types#iso-8601">
Date and time when the patch was applied.
<Property name="patched" type="URI" required={true} typeLink="/types#uri">
URI of the entity that was patched. Must be an absolute URI on the same instance.
</Property>
</Properties>
</Col>
@ -37,32 +24,7 @@ This is less important for other entities, such as `User` profiles, as their con
"type": "Patch", // [!code focus]
"uri": "https://social.lysand.org/objects/be96bb7a-4b8e-45f9-93aa-23633eb3cfdc",
"created_at": "2024-06-19T01:07:44.139Z",
"patched_id": "01902e09-0f8b-72de-8ee3-9afc0cf5eae1", // [!code focus:2]
"patched_at": "2024-06-19T01:07:44.139Z",
"author": "https://social.lysand.org/users/018eb863-753f-76ff-83d6-fd590de7740a",
"category": "microblog",
"content": {
"text/html": {
"content": "<p>No more attachments!</p>"
},
"text/plain": {
"content": "No more attachments!"
}
},
"device": {
"name": "Megalodon for Android",
"version": "1.3.89",
"url": "https://sk22.github.io/megalodon"
},
"extensions": {
"org.lysand:custom_emojis": {
"emojis": []
}
},
"group": "public",
"is_sensitive": false,
"mentions": [],
"subject": "Lysand development"
"patched": "https://social.lysand.org/notes/9a8928b6-2526-4979-aab1-ef2f88cd5700", // [!code focus]
}
```
</Col>

View file

@ -57,9 +57,6 @@ ALL kinds of HTTP requests/responses between instances **MUST** include a [Signa
<Property name="Date" type="UTC Time" required={true} typeLink="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Date">
Date and time of the response.
</Property>
<Property name="Cache-Control" type="string" required={false}>
Must include `no-store` on entities that can be edited directly without a `Patch`, such as `Users`.
</Property>
</Properties>
</Col>
<Col sticky>
@ -68,7 +65,6 @@ ALL kinds of HTTP requests/responses between instances **MUST** include a [Signa
Content-Type: application/json; charset=utf-8
Date: Thu, 01 Jan 1970 00:00:00 GMT
Signature: keyId="https://example.com/users/1",algorithm="ed25519",headers="(request-target) host date digest",signature="..."
Cache-Control: no-store
```
</Col>
</Row>