From e261de70603a4e6b9aeae485da48dbfd12b30c4a Mon Sep 17 00:00:00 2001 From: mStar aka a person <12024604-mstarongitlab@users.noreply.gitlab.com> Date: Thu, 1 Feb 2024 20:58:36 +0000 Subject: [PATCH] Some fixes to AP types --- ap/announce-action.go | 2 +- ap/create-action.go | 1 + ap/delete-action.go | 5 ++--- ap/like-action.go | 5 +++++ ap/signature.go | 13 +++++++++++++ ap/undo-action.go | 4 ++-- 6 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 ap/signature.go diff --git a/ap/announce-action.go b/ap/announce-action.go index 2591896..adb1751 100644 --- a/ap/announce-action.go +++ b/ap/announce-action.go @@ -10,5 +10,5 @@ type AnnounceAction struct { Actor url.URL `json:"actor"` // Who is announcing something To []url.URL `json:"to"` // Targets to share to Cc []url.URL `json:"cc"` // More targets to send to - Object url.URL `json:"object"` // Url to announced object + Object any `json:"object"` // Url to announced object. Url or embedded object, usually a note or survey } diff --git a/ap/create-action.go b/ap/create-action.go index dfc3748..36f1730 100644 --- a/ap/create-action.go +++ b/ap/create-action.go @@ -15,4 +15,5 @@ type CreateAction struct { Object any `json:"object"` // Content of the action, is an AP object, like notes or questions (survey) To []url.URL `json:"to"` // Array of url targets to deliver it to. With dms, oonly includes target accounts. Followers only goes to followers url of posting account Cc []url.URL `json:"cc"` // More targets to deliver to? + Signature Signature `json:"signature"` // Signature of the message } diff --git a/ap/delete-action.go b/ap/delete-action.go index 978007e..c249d65 100644 --- a/ap/delete-action.go +++ b/ap/delete-action.go @@ -2,7 +2,6 @@ package ap import ( "net/url" - "time" ) // When a message is deleted @@ -11,6 +10,6 @@ type DeleteAction struct { Id url.URL `json:"id"` // Location of this resource Type string `json:"type"` // Should always be "Delete" Actor url.URL `json:"actor"` // Account deleting something - Target url.URL `json:"object"` // Account that the actor wants to follow - Published time.Time `json:"published"` // When this was done + Target any `json:"object"` // What is being deleted, url or some object + Signature any `json:"signature"` // Probably useless } diff --git a/ap/like-action.go b/ap/like-action.go index ebfb569..d8e3b51 100644 --- a/ap/like-action.go +++ b/ap/like-action.go @@ -9,4 +9,9 @@ type LikeAction struct { Type string `json:"type"` // Should always be "Like" Actor url.URL `json:"actor"` // Who is liking something Object url.URL `json:"object"` // What is being liked + + // Reaction data Misskey style + Content *string `json:"content,omitempty"` // Raw emote name + MkReaction *string `json:"_misskey_reaction,omitempty"` // Misskey version of content + Tag []Emote `json:"tag,omitempty"` // Emote in use } diff --git a/ap/signature.go b/ap/signature.go new file mode 100644 index 0000000..de4b821 --- /dev/null +++ b/ap/signature.go @@ -0,0 +1,13 @@ +package ap + +import ( + "net/url" + "time" +) + +type Signature struct { + Created time.Time `json:"created"` // When this signature was created + Creator url.URL `json:"creator"` // What key was used to create it + Value string `json:"signatureValue"` // The signature itself + Type string `json:"type"` // What algorithm was used +} diff --git a/ap/undo-action.go b/ap/undo-action.go index 039f559..544509b 100644 --- a/ap/undo-action.go +++ b/ap/undo-action.go @@ -2,11 +2,11 @@ package ap import "net/url" -// Undo == unfollow +// Undoes one action type UndoAction struct { Context *map[string]any `json:"@context,omitempty"` // Lots of something. Not included if action is embedded as object in another object Id url.URL `json:"id"` // Location of this resource Type string `json:"type"` // Should always be "Undo" Actor url.URL `json:"actor"` // Account instanciating the follow request - Target FollowAction `json:"object"` // Follow to undo + Target any `json:"object"` // Action to undo, usually a like or follow }