Some fixes to AP types

This commit is contained in:
mStar aka a person 2024-02-01 20:58:36 +00:00
parent 586fa40113
commit e261de7060
6 changed files with 24 additions and 6 deletions

View file

@ -10,5 +10,5 @@ type AnnounceAction struct {
Actor url.URL `json:"actor"` // Who is announcing something Actor url.URL `json:"actor"` // Who is announcing something
To []url.URL `json:"to"` // Targets to share to To []url.URL `json:"to"` // Targets to share to
Cc []url.URL `json:"cc"` // More targets to send 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
} }

View file

@ -15,4 +15,5 @@ type CreateAction struct {
Object any `json:"object"` // Content of the action, is an AP object, like notes or questions (survey) 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 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? Cc []url.URL `json:"cc"` // More targets to deliver to?
Signature Signature `json:"signature"` // Signature of the message
} }

View file

@ -2,7 +2,6 @@ package ap
import ( import (
"net/url" "net/url"
"time"
) )
// When a message is deleted // When a message is deleted
@ -11,6 +10,6 @@ type DeleteAction struct {
Id url.URL `json:"id"` // Location of this resource Id url.URL `json:"id"` // Location of this resource
Type string `json:"type"` // Should always be "Delete" Type string `json:"type"` // Should always be "Delete"
Actor url.URL `json:"actor"` // Account deleting something Actor url.URL `json:"actor"` // Account deleting something
Target url.URL `json:"object"` // Account that the actor wants to follow Target any `json:"object"` // What is being deleted, url or some object
Published time.Time `json:"published"` // When this was done Signature any `json:"signature"` // Probably useless
} }

View file

@ -9,4 +9,9 @@ type LikeAction struct {
Type string `json:"type"` // Should always be "Like" Type string `json:"type"` // Should always be "Like"
Actor url.URL `json:"actor"` // Who is liking something Actor url.URL `json:"actor"` // Who is liking something
Object url.URL `json:"object"` // What is being liked 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
} }

13
ap/signature.go Normal file
View file

@ -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
}

View file

@ -2,11 +2,11 @@ package ap
import "net/url" import "net/url"
// Undo == unfollow // Undoes one action
type UndoAction struct { type UndoAction struct {
Context *map[string]any `json:"@context,omitempty"` // Lots of something. Not included if action is embedded as object in another object 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 Id url.URL `json:"id"` // Location of this resource
Type string `json:"type"` // Should always be "Undo" Type string `json:"type"` // Should always be "Undo"
Actor url.URL `json:"actor"` // Account instanciating the follow request 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
} }