Progress on adding AP objects
This commit is contained in:
parent
6735fcad7e
commit
935ad134ec
11 changed files with 200 additions and 0 deletions
7
ap/attachment.go
Normal file
7
ap/attachment.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
package ap
|
||||||
|
|
||||||
|
type PersonInfoField struct {
|
||||||
|
Type string `json:"type"` // Type of the attachment. Probably should always be "PropertyValue"
|
||||||
|
Name string `json:"name"` // Name of the property. Example: Source
|
||||||
|
Value string `json:"value"` // Value of the property. Link or html or just some text. Example: https://gitlab.com/mstarongitlab/Linstrom
|
||||||
|
}
|
16
ap/create-action.go
Normal file
16
ap/create-action.go
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
package ap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/url"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CreateAction struct {
|
||||||
|
ID url.URL `json:"id"` // URL to this resource
|
||||||
|
Actor url.URL `json:"actor"` // Account that created this action, links to the AP url
|
||||||
|
Type string `json:"type"` // Should always be "Create"
|
||||||
|
Published time.Time `json:"published"` // When this action was created
|
||||||
|
Object map[string]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?
|
||||||
|
Cc []url.URL `json:"cc"` // More targets to deliver to?
|
||||||
|
}
|
9
ap/media.go
Normal file
9
ap/media.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package ap
|
||||||
|
|
||||||
|
import "net/url"
|
||||||
|
|
||||||
|
type Media struct {
|
||||||
|
Type string `json:"type"` // Should probably always be "Image", "Video" or similar. Dunno if "Video" is correct
|
||||||
|
MediaType string `json:"mediaType"` // What media type the linked resource is. Something like "image/png"
|
||||||
|
Url url.URL `json:"url"` // Where to find the media file
|
||||||
|
}
|
29
ap/note-object.go
Normal file
29
ap/note-object.go
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package ap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/url"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Note struct {
|
||||||
|
Context map[string]any `json:"@context,omitempty"` // Lots of something. Not included if note is embedded as object in another object
|
||||||
|
ID url.URL `json:"id"` // Url to this resource
|
||||||
|
Type string `json:"type"` // Should always be "Note"
|
||||||
|
AttributedTo url.URL `json:"attributedTo"` // Author of this note
|
||||||
|
Content string `json:"content"` // Content of this note
|
||||||
|
MkContent string `json:"_misskey_content"` // Misskey version of content
|
||||||
|
Source RawNoteContent `json:"source"` // Raw content
|
||||||
|
InReplyTo *url.URL `json:"inReplyTo,omitempty"` // Note this is a reply to. Empty if not a reply
|
||||||
|
Attachment []map[string]string `json:"attachment"` // Media attachments - TODO: Make proper type for this
|
||||||
|
Tag []Tag `json:"tag"` // List of hashtags
|
||||||
|
Published time.Time `json:"published"` // When this note was created
|
||||||
|
To []url.URL `json:"to"` // Where this note should get sent to
|
||||||
|
Cc []url.URL `json:"cc"` // More where this note should get sent to
|
||||||
|
|
||||||
|
Summary *string `json:"summary"` // Summary of a post (also known as content warning)
|
||||||
|
Sensitive bool `json:"sensitive"` // Does this note have a content warning?
|
||||||
|
|
||||||
|
MkQuote *url.URL `json:"_misskey_quote,omitempty"` // Misskey link to note this quotes
|
||||||
|
QuoteUrl *url.URL `json:"quoteUrl,omitempty"` // Link to quoted note object
|
||||||
|
QuoteUri *url.URL `json:"quoteUri,omitempty"` // Same as Quote Url?
|
||||||
|
}
|
23
ap/ordered-collection.go
Normal file
23
ap/ordered-collection.go
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package ap
|
||||||
|
|
||||||
|
import "net/url"
|
||||||
|
|
||||||
|
type OrderedCollection struct {
|
||||||
|
Context map[string]any `json:"@context"` // Big chunk of hopefully don't give a fuck
|
||||||
|
ID url.URL `json:"id"` // URL to this resource
|
||||||
|
Type string `json:"type"` // Should always be "OrderedCollection"
|
||||||
|
TotalItems int `json:"totalItems"` // Number of resources in this collection
|
||||||
|
First url.URL `json:"first"` // Link to the first resource in this collection, an OrderedCollectionPage object
|
||||||
|
Last url.URL `json:"last"` // Link to the last resource in this collection, an OrderedCollectionPage object
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderedCollectionPage struct {
|
||||||
|
Context map[string]any `json:"@context"` // Big chunk of hopefully don't give a fuck
|
||||||
|
ID url.URL `json:"id"` // URL to this resource
|
||||||
|
PartOf url.URL `json:"partOf"` // URL to the collection this is a part of
|
||||||
|
Type string `json:"type"` // Should always be "OrderedCollectionPage"
|
||||||
|
TotalItems int `json:"totalItems"` // Number of resources in this collection
|
||||||
|
OrderedItems []map[string]any `json:"orderedItems"` // Items in this list. Should all be AP objects/actions
|
||||||
|
Previous *url.URL `json:"prev"` // Previous page
|
||||||
|
Next *url.URL `json:"next"` // Next page
|
||||||
|
}
|
43
ap/person.go
Normal file
43
ap/person.go
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package ap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/url"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Person struct {
|
||||||
|
Context map[string]any `json:"@context"` // Big chunk of hopefully don't give a fuck
|
||||||
|
ID url.URL `json:"id"` // URL to this resource
|
||||||
|
Type string `json:"type"` // Should always be of content "Person"
|
||||||
|
Following url.URL `json:"following"` // Ordered collection of accounts this account follows
|
||||||
|
Followers url.URL `json:"followers"` // Ordered collection of accounts following this account
|
||||||
|
Inbox url.URL `json:"inbox"` // Where others send activities to (posts, follow requests, reactions, etc)
|
||||||
|
Outbox url.URL `json:"outbox"` // Where others can read this account's activities from
|
||||||
|
Featured url.URL `json:"featured"` // Ordered collection of something featured - TODO: Find out what this is
|
||||||
|
FeaturedTags *url.URL `json:"featuredTags"` // Collection of something, not ordered - TODO: Find out what this is
|
||||||
|
PreferredUsername string `json:"preferredUsername"` // Username
|
||||||
|
Name string `json:"name"` // Vanity name
|
||||||
|
Summary string `json:"summary"` // Description of the account. Could contain html or maybe mfm for *key
|
||||||
|
Url url.URL `json:"url"` // Public location of the account
|
||||||
|
Locked bool `json:"manuallyApprovesFollowers"` // Does this account have to approve of follows before they are actual follows?
|
||||||
|
Discoverable bool `json:"discoverable"` // If this account can be found via search things? I guess?
|
||||||
|
Indexable *bool `json:"indexable"` // Probably if this account will be shown to search engines and crawlers?
|
||||||
|
Published *time.Time `json:"published"` // When this account was created I guess?
|
||||||
|
Memorial *bool `json:"memorial"` // If this account is closed? Or moved? Probably closed
|
||||||
|
Devices *url.URL `json:"devices"` // Collection of something - TODO: Find out what this is
|
||||||
|
PublicKey PublicKey `json:"publicKey"` // public key of that account. For verifying that that account is actually them
|
||||||
|
Tag []any `json:"tag"` // Array of something. Probably urls or strings
|
||||||
|
Attachment PersonInfoField `json:"attachment"` // Additional profile information (fields below the description, like "Source: https://gitlab.com/mstarongitlab/linstrom")
|
||||||
|
Endpoints map[string]string `json:"endpoints"` // Stores at least the shared inbox of the server this account is on in "sharedInbox", which is an url
|
||||||
|
Icon *Media `json:"icon"` // Profile image of the account
|
||||||
|
Image *Media `json:"image"` // Header image of the account
|
||||||
|
|
||||||
|
SharedInbox *url.URL `json:"sharedInbox"` // Replicates the shared inbox url here I guess
|
||||||
|
MkSummary *string `json:"_misskey_summary"` // Misskey's version of the summary
|
||||||
|
Background *url.URL `json:"backgroundUrl"` // Background image
|
||||||
|
IsCat *bool `json:"isCat"` // Is the user a cat (apply cat ears in that case)
|
||||||
|
NoIndex *bool `json:"noindex"` // probably the same as Indexable, just reversed?
|
||||||
|
SpeakAsCat *bool `json:"speakAsCat"` // Does the account speak like a cat
|
||||||
|
Birthday *string `json:"vcard:bday"` // Birthday date, but doesn't quite follow normalised datetime
|
||||||
|
Location *string `json:"vcard:Address"` // Where the user of the account lives, could technically be anything as just a string
|
||||||
|
}
|
21
ap/public_key.go
Normal file
21
ap/public_key.go
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package ap
|
||||||
|
|
||||||
|
import "net/url"
|
||||||
|
|
||||||
|
type PublicKey struct {
|
||||||
|
ID url.URL `json:"id"` // ID of the key
|
||||||
|
Owner url.URL `json:"owner"` // Who this key belongs to
|
||||||
|
Content string `json:"publicKeyPem"` // Actual content of the key, example below
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Example for a public key
|
||||||
|
|
||||||
|
"""
|
||||||
|
-----BEGIN PUBLIC KEY-----
|
||||||
|
Big blob of random characters
|
||||||
|
-----END PUBLIC KEY-----
|
||||||
|
|
||||||
|
"""
|
||||||
|
*/
|
10
ap/question-entry.go
Normal file
10
ap/question-entry.go
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
package ap
|
||||||
|
|
||||||
|
type QuestionEntry struct {
|
||||||
|
Type string `json:"type"` // Should always be "Note"
|
||||||
|
Name string `json:"name"` // Name of the entry
|
||||||
|
Replies struct {
|
||||||
|
Type string `json:"type"` // Should always be "Collection"
|
||||||
|
TotalItems int // Nr of people that selected this
|
||||||
|
} `json:"replies"` // Nr of people that selected this option
|
||||||
|
}
|
27
ap/question-object.go
Normal file
27
ap/question-object.go
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package ap
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/url"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Question struct {
|
||||||
|
Context map[string]any `json:"@context,omitempty"` // Lots of something. Not included if note is embedded as object in another object
|
||||||
|
ID url.URL `json:"id"` // Url to this object
|
||||||
|
Type string `json:"type"` // Should always be "Question"
|
||||||
|
AttributedTo url.URL `json:"attributedTo"` // Creator of this object
|
||||||
|
Content string `json:"content"` // Preformated text content
|
||||||
|
MkContent string `json:"_misskey_content"` // Misskey version of the content
|
||||||
|
Source RawNoteContent `json:"source"` // Raw version of the content
|
||||||
|
Published time.Time `json:"published"` // When this object was published
|
||||||
|
To []url.URL `json:"to"` // Who to send this to
|
||||||
|
Cc []url.URL `json:"cc"` // More targets to send to
|
||||||
|
InReplyTo *url.URL `json:"inReplyTo"` // Object this post replies to
|
||||||
|
Attachment []map[string]string `json:"attachment"` // File attachments - TODO: Move to concrete type
|
||||||
|
Sensitive bool `json:"sensitive"` // Whether this post has a content warning
|
||||||
|
Summary *string `json:"summary"` // Summary of a post (also known as content warning)
|
||||||
|
Tag []Tag `json:"tag"` // Hashtags
|
||||||
|
EndTime *time.Time `json:"endTime"` // Timestamp of when the question ends
|
||||||
|
OneOf []QuestionEntry `json:"oneOf,omitempty"` // All available options to vote for. Used if single choice vote
|
||||||
|
AnyOf []QuestionEntry `json:"anyOf,omitempty"` // All available options to vote for. Used if multiple choice vote
|
||||||
|
}
|
6
ap/raw-note-content.go
Normal file
6
ap/raw-note-content.go
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package ap
|
||||||
|
|
||||||
|
type RawNoteContent struct {
|
||||||
|
Content string `json:"content"`
|
||||||
|
MediaType string `json:"mediaType"`
|
||||||
|
}
|
9
ap/tag.go
Normal file
9
ap/tag.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package ap
|
||||||
|
|
||||||
|
import "net/url"
|
||||||
|
|
||||||
|
type Tag struct {
|
||||||
|
Type string `json:"type"` // Should always be "Hashtag"
|
||||||
|
Href url.URL `json:"href"` // Url to that hashtag
|
||||||
|
Name string `json:"name"` // Name of the hashtag, example: "#some-hashtag"
|
||||||
|
}
|
Loading…
Reference in a new issue