Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
25 changed files with 112 additions and 1084 deletions
19
CHANGELOG
19
CHANGELOG
|
@ -1,19 +0,0 @@
|
||||||
- v2.0.0:
|
|
||||||
- Update module name to sync up with host change
|
|
||||||
- Added parser from base AP object to Mastodon person
|
|
||||||
- Bug fix:
|
|
||||||
- ASAlsoKnownAs is now the correct type
|
|
||||||
- v1.1.0:
|
|
||||||
- More attributes added:
|
|
||||||
- Activitystreams#first
|
|
||||||
- Activitystreams#next
|
|
||||||
- Activitystreams#items
|
|
||||||
- Activitystreams#partOf
|
|
||||||
- Activitystreams#inReplyTo
|
|
||||||
- Activitystreams#quoteUrl
|
|
||||||
- Ostatus#inReplyToAtomUri
|
|
||||||
- Misskey#mk_quote
|
|
||||||
- Fedibird#quoteUri
|
|
||||||
- Bug fixes:
|
|
||||||
- A few Attributes were returning the wrong struct due to copy paste mistakes
|
|
||||||
- v1.0.0: Release
|
|
|
@ -21,9 +21,6 @@ func (idtype *FullIdType) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
|
|
||||||
func (idtype *FullIdType) MarshalToMapWithName(name string) map[string]any {
|
func (idtype *FullIdType) MarshalToMapWithName(name string) map[string]any {
|
||||||
m := idtype.Next.MarshalToMap()
|
m := idtype.Next.MarshalToMap()
|
||||||
if m == nil {
|
|
||||||
m = map[string]any{}
|
|
||||||
}
|
|
||||||
m[name] = []map[string]any{{KEY_ID: idtype.Id}}
|
m[name] = []map[string]any{{KEY_ID: idtype.Id}}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
@ -66,9 +63,6 @@ func (v *FullValueType[T]) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
|
|
||||||
func (v *FullValueType[T]) MarshalToMapWithName(name string) map[string]any {
|
func (v *FullValueType[T]) MarshalToMapWithName(name string) map[string]any {
|
||||||
m := v.Next.MarshalToMap()
|
m := v.Next.MarshalToMap()
|
||||||
if m == nil {
|
|
||||||
m = map[string]any{}
|
|
||||||
}
|
|
||||||
m[name] = []map[string]any{v.Value.Marshal()}
|
m[name] = []map[string]any{v.Value.Marshal()}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
36
constants.go
36
constants.go
|
@ -1,13 +1,11 @@
|
||||||
package goap
|
package goap
|
||||||
|
|
||||||
// JsonLD fields
|
|
||||||
const (
|
const (
|
||||||
KEY_ID = "@id" // Value of type string
|
KEY_ID = "@id" // Value of type string
|
||||||
KEY_TYPE = "@type" // Value of type string slice / activitystreams object url slice
|
KEY_TYPE = "@type" // Value of type string slice / activitystreams object url slice
|
||||||
KEY_VALUE = "@value" // Could be any type really
|
KEY_VALUE = "@value" // Could be any type really
|
||||||
)
|
)
|
||||||
|
|
||||||
// Mastodon fields
|
|
||||||
const (
|
const (
|
||||||
KEY_MASTO_DEVICES = "http://joinmastodon.org/ns#devices" // No idea what this is, but Masto includes it
|
KEY_MASTO_DEVICES = "http://joinmastodon.org/ns#devices" // No idea what this is, but Masto includes it
|
||||||
KEY_MASTO_DISCOVERABLE = "http://joinmastodon.org/ns#discoverable" // iirc this is whether the object can be found by crawlers
|
KEY_MASTO_DISCOVERABLE = "http://joinmastodon.org/ns#discoverable" // iirc this is whether the object can be found by crawlers
|
||||||
|
@ -19,7 +17,6 @@ const (
|
||||||
KEY_MASTO_EMOJI = "http://joinmastodon.org/ns#Emoji" // Object is an emoji
|
KEY_MASTO_EMOJI = "http://joinmastodon.org/ns#Emoji" // Object is an emoji
|
||||||
)
|
)
|
||||||
|
|
||||||
// Generic W3 fields
|
|
||||||
const (
|
const (
|
||||||
KEY_W3_INBOX = "http://www.w3.org/ns/ldp#inbox" // Where to send activities to
|
KEY_W3_INBOX = "http://www.w3.org/ns/ldp#inbox" // Where to send activities to
|
||||||
KEY_W3_SECURITY_OWNER = "https://w3id.org/security#owner" // Owner of the public key
|
KEY_W3_SECURITY_OWNER = "https://w3id.org/security#owner" // Owner of the public key
|
||||||
|
@ -28,14 +25,9 @@ const (
|
||||||
KEY_W3_VCARD_ADDRESS = "http://www.w3.org/2006/vcard/ns#Address" // Vcard address of an account
|
KEY_W3_VCARD_ADDRESS = "http://www.w3.org/2006/vcard/ns#Address" // Vcard address of an account
|
||||||
KEY_W3_VCARD_BIRTHDAY = "http://www.w3.org/2006/vcard/ns#bday" // Vcard birthday of an account
|
KEY_W3_VCARD_BIRTHDAY = "http://www.w3.org/2006/vcard/ns#bday" // Vcard birthday of an account
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
// Generic W3 object type
|
|
||||||
const (
|
|
||||||
KEY_W3_SECURITY_KEY = "https://w3id.org/security#Key" // Object is a PublicKey
|
KEY_W3_SECURITY_KEY = "https://w3id.org/security#Key" // Object is a PublicKey
|
||||||
)
|
)
|
||||||
|
|
||||||
// W3 Activitystreams fields
|
|
||||||
const (
|
const (
|
||||||
KEY_ACTIVITYSTREAMS_ACTOR = "https://www.w3.org/ns/activitystreams#actor"
|
KEY_ACTIVITYSTREAMS_ACTOR = "https://www.w3.org/ns/activitystreams#actor"
|
||||||
KEY_ACTIVITYSTREAMS_ALSOKNOWNAS = "https://www.w3.org/ns/activitystreams#alsoKnownAs" // Lists of usernames?
|
KEY_ACTIVITYSTREAMS_ALSOKNOWNAS = "https://www.w3.org/ns/activitystreams#alsoKnownAs" // Lists of usernames?
|
||||||
|
@ -64,12 +56,7 @@ const (
|
||||||
KEY_ACTIVITYSTREAMS_TO = "https://www.w3.org/ns/activitystreams#to" // Urls to send an activity to
|
KEY_ACTIVITYSTREAMS_TO = "https://www.w3.org/ns/activitystreams#to" // Urls to send an activity to
|
||||||
KEY_ACTIVITYSTREAMS_URL = "https://www.w3.org/ns/activitystreams#url" // Some url
|
KEY_ACTIVITYSTREAMS_URL = "https://www.w3.org/ns/activitystreams#url" // Some url
|
||||||
KEY_ACTIVITYSTREAMS_UPDATED = "https://www.w3.org/ns/activitystreams#updated" // When the content was last updated
|
KEY_ACTIVITYSTREAMS_UPDATED = "https://www.w3.org/ns/activitystreams#updated" // When the content was last updated
|
||||||
KEY_ACTIVITYSTREAMS_INREPLYTO = "https://www.w3.org/ns/activitystreams#inReplyTo" // What the object is replying to
|
|
||||||
KEY_ACTIVITYSTREAMS_QUOTEURL = "https://www.w3.org/ns/activitystreams#quoteUrl" // Url to the object being quoted
|
|
||||||
)
|
|
||||||
|
|
||||||
// W3 Activitystreams object types
|
|
||||||
const (
|
|
||||||
// Object types (I think)
|
// Object types (I think)
|
||||||
// Those are values the object type can have
|
// Those are values the object type can have
|
||||||
|
|
||||||
|
@ -89,10 +76,7 @@ const (
|
||||||
KEY_ACTIVITYSTREAMS_ITEMS = "https://www.w3.org/ns/activitystreams#items" // Items in this collection page
|
KEY_ACTIVITYSTREAMS_ITEMS = "https://www.w3.org/ns/activitystreams#items" // Items in this collection page
|
||||||
KEY_ACTIVITYSTREAMS_NEXT = "https://www.w3.org/ns/activitystreams#next" // Next page in a collection
|
KEY_ACTIVITYSTREAMS_NEXT = "https://www.w3.org/ns/activitystreams#next" // Next page in a collection
|
||||||
KEY_ACTIVITYSTREAMS_PARTOF = "https://www.w3.org/ns/activitystreams#partOf" // Collection the current page is a part of
|
KEY_ACTIVITYSTREAMS_PARTOF = "https://www.w3.org/ns/activitystreams#partOf" // Collection the current page is a part of
|
||||||
)
|
|
||||||
|
|
||||||
// W3 Activitystreams unknown
|
|
||||||
const (
|
|
||||||
// Misc
|
// Misc
|
||||||
KEY_ACTIVITYSTREAMS_OAUTHAUTHORIZATION = "https://www.w3.org/ns/activitystreams#oauthAuthorizationEndpoint" // Endpoint url for oauth login?
|
KEY_ACTIVITYSTREAMS_OAUTHAUTHORIZATION = "https://www.w3.org/ns/activitystreams#oauthAuthorizationEndpoint" // Endpoint url for oauth login?
|
||||||
KEY_ACTIVITYSTREAMS_OAUTHTOKEN = "https://www.w3.org/ns/activitystreams#oauthTokenEndpoint" // Endpoint url for oauth token verification?
|
KEY_ACTIVITYSTREAMS_OAUTHTOKEN = "https://www.w3.org/ns/activitystreams#oauthTokenEndpoint" // Endpoint url for oauth token verification?
|
||||||
|
@ -100,51 +84,35 @@ const (
|
||||||
KEY_ACTIVITYSTREAMS_PUBLIC = "https://www.w3.org/ns/activitystreams#Public" // Note target
|
KEY_ACTIVITYSTREAMS_PUBLIC = "https://www.w3.org/ns/activitystreams#Public" // Note target
|
||||||
)
|
)
|
||||||
|
|
||||||
// schema fields
|
|
||||||
const (
|
const (
|
||||||
KEY_SCHEMA_VALUE = "http://schema.org#value" // The value for some field
|
KEY_SCHEMA_VALUE = "http://schema.org#value" // The value for some field
|
||||||
|
|
||||||
KEY_SCHEMA_PROPERTYVALUE = "http://schema.org#PropertyValue" // Object is of type property value
|
KEY_SCHEMA_PROPERTYVALUE = "http://schema.org#PropertyValue" // Object is of type property value
|
||||||
)
|
)
|
||||||
|
|
||||||
// Misskey and fork fields
|
|
||||||
const (
|
const (
|
||||||
KEY_MISSKEY_MKSUMMARY = "https://misskey-hub.net/ns#_misskey_summary" // Misskey specific formatted summary
|
KEY_MISSKEY_MKSUMMARY = "https://misskey-hub.net/ns#_misskey_summary" // Misskey specific formatted summary
|
||||||
KEY_MISSKEY_ISCAT = "https://misskey-hub.net/ns#isCat" // Does the account identify as cat?
|
KEY_MISSKEY_ISCAT = "https://misskey-hub.net/ns#isCat" // Does the account identify as cat?
|
||||||
KEY_MISSKEY_MKQUOTE = "https://misskey-hub.net/ns#_misskey_quote" // Misskey specific quote field
|
|
||||||
KEY_FIREFISH_SPEAKASCAT = "https://joinfirefish.org/ns#speakAsCat" // Does the account speak like a cat?
|
KEY_FIREFISH_SPEAKASCAT = "https://joinfirefish.org/ns#speakAsCat" // Does the account speak like a cat?
|
||||||
)
|
)
|
||||||
|
|
||||||
// No idea what either of those two do or are used for
|
|
||||||
|
|
||||||
// Litepub fields
|
|
||||||
const (
|
const (
|
||||||
KEY_LITEPUB_CAPABILITIES = "http://litepub.social/ns#capabilities"
|
KEY_LITEPUB_CAPABILITIES = "http://litepub.social/ns#capabilities"
|
||||||
KEY_LITEPUB_OAUTHREGISTRATION = "http://litepub.social/ns#oauthRegistrationEndpoint"
|
KEY_LITEPUB_OAUTHREGISTRATION = "http://litepub.social/ns#oauthRegistrationEndpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// W3 XML fields
|
|
||||||
const (
|
const (
|
||||||
KEY_XMLSCHEMA_DATETIME = "http://www.w3.org/2001/XMLSchema#dateTime" // Type value for published value field
|
KEY_XMLSCHEMA_DATETIME = "http://www.w3.org/2001/XMLSchema#dateTime" // Type value for published value field
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ostatus fields
|
|
||||||
//
|
|
||||||
// NOTE: ostatus.org seems to be redirecting to some weird scam(?) page
|
// NOTE: ostatus.org seems to be redirecting to some weird scam(?) page
|
||||||
const (
|
const (
|
||||||
KEY_OSTATUS_ATOMURI = "http://ostatus.org#atomUri" // Same as @id I think
|
KEY_OSTATUS_ATOMURI = "http://ostatus.org#atomUri"
|
||||||
KEY_OSTATUS_CONVERSATION = "http://ostatus.org#conversation" // Similar to inReplyTo
|
KEY_OSTATUS_CONVERSATION = "http://ostatus.org#conversation"
|
||||||
KEY_OSTATUS_INREPLYTOATOMURI = "http://ostatus.org#inReplyToAtomUri" // Same as InReplyTo, but with an atom uri as target
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Unknown origin fields
|
|
||||||
const (
|
const (
|
||||||
KEY_MYSTERIOUS_NOINDEX = "_:noindex"
|
KEY_MYSTERIOUS_NOINDEX = "_:noindex"
|
||||||
KEY_MYSTERIOUS_BACKGROUNDURL = "_:backgroundUrl"
|
KEY_MYSTERIOUS_BACKGROUNDURL = "_:backgroundUrl"
|
||||||
KEY_MYSTERIOUS_FEATURED = "_:featured"
|
KEY_MYSTERIOUS_FEATURED = "_:featured"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Fedibird fields
|
|
||||||
const (
|
|
||||||
KEY_FEDIBIRD_QUOTEURI = "http://fedibird.com/ns#quoteUri"
|
|
||||||
)
|
|
||||||
|
|
|
@ -1,122 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113046100718699502/replies",
|
|
||||||
"@type": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Collection"
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#first": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113046100718699502/replies?page=true",
|
|
||||||
"@type": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#CollectionPage"
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#items": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113046106230737452",
|
|
||||||
"@type": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Note"
|
|
||||||
],
|
|
||||||
"http://ostatus.org#atomUri": [
|
|
||||||
{
|
|
||||||
"@value": "https://activitypub.academy/users/fagusia_aseod/statuses/113046106230737452"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"http://ostatus.org#conversation": [
|
|
||||||
{
|
|
||||||
"@value": "tag:activitypub.academy,2024-08-29:objectId=186920:objectType=Conversation"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"http://ostatus.org#inReplyToAtomUri": [
|
|
||||||
{
|
|
||||||
"@value": "https://activitypub.academy/users/fagusia_aseod/statuses/113046100718699502"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#attachment": [],
|
|
||||||
"https://www.w3.org/ns/activitystreams#attributedTo": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#cc": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/followers"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#content": [
|
|
||||||
{
|
|
||||||
"@value": "\u003cp\u003ereply\u003c/p\u003e"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"@language": "en",
|
|
||||||
"@value": "\u003cp\u003ereply\u003c/p\u003e"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#inReplyTo": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113046100718699502"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#published": [
|
|
||||||
{
|
|
||||||
"@type": "http://www.w3.org/2001/XMLSchema#dateTime",
|
|
||||||
"@value": "2024-08-29T15:51:29Z"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#replies": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113046106230737452/replies",
|
|
||||||
"@type": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Collection"
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#first": [
|
|
||||||
{
|
|
||||||
"@type": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#CollectionPage"
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#items": [],
|
|
||||||
"https://www.w3.org/ns/activitystreams#next": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113046106230737452/replies?only_other_accounts=true\u0026page=true"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#partOf": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113046106230737452/replies"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#sensitive": [
|
|
||||||
{
|
|
||||||
"@value": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#tag": [],
|
|
||||||
"https://www.w3.org/ns/activitystreams#to": [
|
|
||||||
{
|
|
||||||
"@id": "https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#url": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/@fagusia_aseod/113046106230737452"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#next": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113046100718699502/replies?only_other_accounts=true\u0026page=true"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#partOf": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113046100718699502/replies"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -1,96 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113049754774052158",
|
|
||||||
"@type": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Note"
|
|
||||||
],
|
|
||||||
"http://ostatus.org#atomUri": [
|
|
||||||
{
|
|
||||||
"@value": "https://activitypub.academy/users/fagusia_aseod/statuses/113049754774052158"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"http://ostatus.org#conversation": [
|
|
||||||
{
|
|
||||||
"@value": "tag:activitypub.academy,2024-08-30:objectId=186955:objectType=Conversation"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"http://ostatus.org#inReplyToAtomUri": [
|
|
||||||
{
|
|
||||||
"@value": "https://activitypub.academy/users/fagusia_aseod/statuses/113049753895761634"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#attachment": [],
|
|
||||||
"https://www.w3.org/ns/activitystreams#attributedTo": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#cc": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/followers"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#content": [
|
|
||||||
{
|
|
||||||
"@value": "\u003cp\u003ereply\u003c/p\u003e"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"@language": "en",
|
|
||||||
"@value": "\u003cp\u003ereply\u003c/p\u003e"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#inReplyTo": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113049753895761634"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#published": [
|
|
||||||
{
|
|
||||||
"@type": "http://www.w3.org/2001/XMLSchema#dateTime",
|
|
||||||
"@value": "2024-08-30T07:19:21Z"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#replies": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113049754774052158/replies",
|
|
||||||
"@type": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Collection"
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#first": [
|
|
||||||
{
|
|
||||||
"@type": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#CollectionPage"
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#items": [],
|
|
||||||
"https://www.w3.org/ns/activitystreams#next": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113049754774052158/replies?only_other_accounts=true\u0026page=true"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#partOf": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/users/fagusia_aseod/statuses/113049754774052158/replies"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#sensitive": [
|
|
||||||
{
|
|
||||||
"@value": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#tag": [],
|
|
||||||
"https://www.w3.org/ns/activitystreams#to": [
|
|
||||||
{
|
|
||||||
"@id": "https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#url": [
|
|
||||||
{
|
|
||||||
"@id": "https://activitypub.academy/@fagusia_aseod/113049754774052158"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -1,75 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"@id": "https://fedi.catboy.agency/notes/9xk3lj95g43b02t8",
|
|
||||||
"@type": [
|
|
||||||
"https://www.w3.org/ns/activitystreams#Note"
|
|
||||||
],
|
|
||||||
"http://fedibird.com/ns#quoteUri": [
|
|
||||||
{
|
|
||||||
"@value": "https://activitypub.academy/users/fagusia_aseod/statuses/113050350412353987"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://misskey-hub.net/ns#_misskey_content": [
|
|
||||||
{
|
|
||||||
"@value": "quote test"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://misskey-hub.net/ns#_misskey_quote": [
|
|
||||||
{
|
|
||||||
"@value": "https://activitypub.academy/users/fagusia_aseod/statuses/113050350412353987"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#attachment": [],
|
|
||||||
"https://www.w3.org/ns/activitystreams#attributedTo": [
|
|
||||||
{
|
|
||||||
"@id": "https://fedi.catboy.agency/users/9ltetvu2n34t01lj"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#cc": [
|
|
||||||
{
|
|
||||||
"@id": "https://fedi.catboy.agency/users/9ltetvu2n34t01lj/followers"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#content": [
|
|
||||||
{
|
|
||||||
"@value": "\u003cp\u003e\u003cspan\u003equote test\u003cbr\u003e\u003cbr\u003eRE: \u003c/span\u003e\u003ca href=\"https://activitypub.academy/users/fagusia_aseod/statuses/113050350412353987\"\u003ehttps://activitypub.academy/users/fagusia_aseod/statuses/113050350412353987\u003c/a\u003e\u003c/p\u003e"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#published": [
|
|
||||||
{
|
|
||||||
"@type": "http://www.w3.org/2001/XMLSchema#dateTime",
|
|
||||||
"@value": "2024-08-30T09:51:01.049Z"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#quoteUrl": [
|
|
||||||
{
|
|
||||||
"@value": "https://activitypub.academy/users/fagusia_aseod/statuses/113050350412353987"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#sensitive": [
|
|
||||||
{
|
|
||||||
"@value": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#source": [
|
|
||||||
{
|
|
||||||
"https://www.w3.org/ns/activitystreams#content": [
|
|
||||||
{
|
|
||||||
"@value": "quote test"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#mediaType": [
|
|
||||||
{
|
|
||||||
"@value": "text/x.misskeymarkdown"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"https://www.w3.org/ns/activitystreams#tag": [],
|
|
||||||
"https://www.w3.org/ns/activitystreams#to": [
|
|
||||||
{
|
|
||||||
"@id": "https://www.w3.org/ns/activitystreams#Public"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -1,43 +0,0 @@
|
||||||
{
|
|
||||||
"@context": [
|
|
||||||
"https://www.w3.org/ns/activitystreams",
|
|
||||||
{
|
|
||||||
"ostatus": "http://ostatus.org#",
|
|
||||||
"atomUri": "ostatus:atomUri",
|
|
||||||
"inReplyToAtomUri": "ostatus:inReplyToAtomUri",
|
|
||||||
"conversation": "ostatus:conversation",
|
|
||||||
"sensitive": "as:sensitive",
|
|
||||||
"toot": "http://joinmastodon.org/ns#",
|
|
||||||
"votersCount": "toot:votersCount"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"id": "https://activitypub.academy/users/fagusia_aseod/statuses/113049754774052158",
|
|
||||||
"type": "Note",
|
|
||||||
"summary": null,
|
|
||||||
"inReplyTo": "https://activitypub.academy/users/fagusia_aseod/statuses/113049753895761634",
|
|
||||||
"published": "2024-08-30T07:19:21Z",
|
|
||||||
"url": "https://activitypub.academy/@fagusia_aseod/113049754774052158",
|
|
||||||
"attributedTo": "https://activitypub.academy/users/fagusia_aseod",
|
|
||||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
|
||||||
"cc": ["https://activitypub.academy/users/fagusia_aseod/followers"],
|
|
||||||
"sensitive": false,
|
|
||||||
"atomUri": "https://activitypub.academy/users/fagusia_aseod/statuses/113049754774052158",
|
|
||||||
"inReplyToAtomUri": "https://activitypub.academy/users/fagusia_aseod/statuses/113049753895761634",
|
|
||||||
"conversation": "tag:activitypub.academy,2024-08-30:objectId=186955:objectType=Conversation",
|
|
||||||
"content": "<p>reply</p>",
|
|
||||||
"contentMap": {
|
|
||||||
"en": "<p>reply</p>"
|
|
||||||
},
|
|
||||||
"attachment": [],
|
|
||||||
"tag": [],
|
|
||||||
"replies": {
|
|
||||||
"id": "https://activitypub.academy/users/fagusia_aseod/statuses/113049754774052158/replies",
|
|
||||||
"type": "Collection",
|
|
||||||
"first": {
|
|
||||||
"type": "CollectionPage",
|
|
||||||
"next": "https://activitypub.academy/users/fagusia_aseod/statuses/113049754774052158/replies?only_other_accounts=true&page=true",
|
|
||||||
"partOf": "https://activitypub.academy/users/fagusia_aseod/statuses/113049754774052158/replies",
|
|
||||||
"items": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
{
|
|
||||||
"@context": [
|
|
||||||
"https://www.w3.org/ns/activitystreams",
|
|
||||||
"https://w3id.org/security/v1",
|
|
||||||
{
|
|
||||||
"Key": "sec:Key",
|
|
||||||
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
|
||||||
"sensitive": "as:sensitive",
|
|
||||||
"Hashtag": "as:Hashtag",
|
|
||||||
"quoteUrl": "as:quoteUrl",
|
|
||||||
"fedibird": "http://fedibird.com/ns#",
|
|
||||||
"quoteUri": "fedibird:quoteUri",
|
|
||||||
"toot": "http://joinmastodon.org/ns#",
|
|
||||||
"Emoji": "toot:Emoji",
|
|
||||||
"featured": "toot:featured",
|
|
||||||
"discoverable": "toot:discoverable",
|
|
||||||
"schema": "http://schema.org#",
|
|
||||||
"PropertyValue": "schema:PropertyValue",
|
|
||||||
"value": "schema:value",
|
|
||||||
"misskey": "https://misskey-hub.net/ns#",
|
|
||||||
"_misskey_content": "misskey:_misskey_content",
|
|
||||||
"_misskey_quote": "misskey:_misskey_quote",
|
|
||||||
"_misskey_reaction": "misskey:_misskey_reaction",
|
|
||||||
"_misskey_votes": "misskey:_misskey_votes",
|
|
||||||
"_misskey_summary": "misskey:_misskey_summary",
|
|
||||||
"isCat": "misskey:isCat",
|
|
||||||
"firefish": "https://joinfirefish.org/ns#",
|
|
||||||
"speakAsCat": "firefish:speakAsCat",
|
|
||||||
"sharkey": "https://joinsharkey.org/ns#",
|
|
||||||
"backgroundUrl": "sharkey:backgroundUrl",
|
|
||||||
"listenbrainz": "sharkey:listenbrainz",
|
|
||||||
"vcard": "http://www.w3.org/2006/vcard/ns#"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"id": "https://fedi.catboy.agency/notes/9xk3lj95g43b02t8",
|
|
||||||
"type": "Note",
|
|
||||||
"attributedTo": "https://fedi.catboy.agency/users/9ltetvu2n34t01lj",
|
|
||||||
"content": "<p><span>quote test<br><br>RE: </span><a href=\"https://activitypub.academy/users/fagusia_aseod/statuses/113050350412353987\">https://activitypub.academy/users/fagusia_aseod/statuses/113050350412353987</a></p>",
|
|
||||||
"_misskey_content": "quote test",
|
|
||||||
"source": {
|
|
||||||
"content": "quote test",
|
|
||||||
"mediaType": "text/x.misskeymarkdown"
|
|
||||||
},
|
|
||||||
"_misskey_quote": "https://activitypub.academy/users/fagusia_aseod/statuses/113050350412353987",
|
|
||||||
"quoteUrl": "https://activitypub.academy/users/fagusia_aseod/statuses/113050350412353987",
|
|
||||||
"quoteUri": "https://activitypub.academy/users/fagusia_aseod/statuses/113050350412353987",
|
|
||||||
"published": "2024-08-30T09:51:01.049Z",
|
|
||||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
|
||||||
"cc": ["https://fedi.catboy.agency/users/9ltetvu2n34t01lj/followers"],
|
|
||||||
"inReplyTo": null,
|
|
||||||
"attachment": [],
|
|
||||||
"sensitive": false,
|
|
||||||
"tag": []
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@ package general
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.mstar.dev/mstar/goap"
|
"gitlab.com/mstarongitlab/goap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateEvent struct {
|
type CreateEvent struct {
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
||||||
module git.mstar.dev/mstar/goap
|
module gitlab.com/mstarongitlab/goap
|
||||||
|
|
||||||
go 1.22.5
|
go 1.22.5
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package mastodon
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.mstar.dev/mstar/goap"
|
"gitlab.com/mstarongitlab/goap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Person struct {
|
type Person struct {
|
||||||
|
@ -32,139 +32,3 @@ type Person struct {
|
||||||
Tags []goap.Tag
|
Tags []goap.Tag
|
||||||
Url string
|
Url string
|
||||||
}
|
}
|
||||||
|
|
||||||
func PersonFromChain(base goap.BaseApChain) (*Person, error) {
|
|
||||||
id, ok := goap.FindAttribute[*goap.UDIdData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ID}
|
|
||||||
}
|
|
||||||
devices, ok := goap.FindAttribute[*goap.MastoDevicesData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_MASTO_DEVICES}
|
|
||||||
}
|
|
||||||
discoverable, ok := goap.FindAttribute[*goap.MastoDiscoverableData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_MASTO_DISCOVERABLE}
|
|
||||||
}
|
|
||||||
|
|
||||||
featured, ok := goap.FindAttribute[*goap.MastoFeaturedData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_MASTO_FEATURED}
|
|
||||||
}
|
|
||||||
featuredTags, ok := goap.FindAttribute[*goap.MastoFeaturedTagsData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_MASTO_FEATURED_TAGS}
|
|
||||||
}
|
|
||||||
Indexable, ok := goap.FindAttribute[*goap.MastoIndexableData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_MASTO_INDEXABLE}
|
|
||||||
}
|
|
||||||
memorial, ok := goap.FindAttribute[*goap.MastoMemorialData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_MASTO_MEMORIAL}
|
|
||||||
}
|
|
||||||
inbox, ok := goap.FindAttribute[*goap.W3InboxData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_W3_INBOX}
|
|
||||||
}
|
|
||||||
publicKey, ok := goap.FindAttribute[*goap.W3SecurityPublicKeyData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_W3_SECURITY_PUBLICKEY}
|
|
||||||
}
|
|
||||||
alsoKnownAs, ok := goap.FindAttribute[*goap.ASAlsoKnownAsData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_ALSOKNOWNAS}
|
|
||||||
}
|
|
||||||
attachments, ok := goap.FindAttribute[*goap.ASAttachmentsData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_ATTACHMENTS}
|
|
||||||
}
|
|
||||||
endpoints, ok := goap.FindAttribute[*goap.ASEndpointsData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_ENDPOINTS}
|
|
||||||
}
|
|
||||||
followers, ok := goap.FindAttribute[*goap.ASFollowersData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_FOLLOWERS}
|
|
||||||
}
|
|
||||||
following, ok := goap.FindAttribute[*goap.ASFollowingData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_FOLLOWING}
|
|
||||||
}
|
|
||||||
icon, ok := goap.FindAttribute[*goap.ASIconData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_ICON}
|
|
||||||
}
|
|
||||||
image, ok := goap.FindAttribute[*goap.ASImageData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_IMAGE_ATTRIBUTE}
|
|
||||||
}
|
|
||||||
approvesFollowers, ok := goap.FindAttribute[*goap.ASRestrictedFollowData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_RESTRICTED_FOLLOW}
|
|
||||||
}
|
|
||||||
name, ok := goap.FindAttribute[*goap.ASNameData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_NAME}
|
|
||||||
}
|
|
||||||
outbox, ok := goap.FindAttribute[*goap.ASOutboxData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_OUTBOX}
|
|
||||||
}
|
|
||||||
preferredUsername, ok := goap.FindAttribute[*goap.ASPreferredNameData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_PREFFEREDUSERNAME}
|
|
||||||
}
|
|
||||||
published, ok := goap.FindAttribute[*goap.ASPublishedData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_PUBLISHED}
|
|
||||||
}
|
|
||||||
summary, ok := goap.FindAttribute[*goap.ASSummaryData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_SUMMARY}
|
|
||||||
}
|
|
||||||
tags, ok := goap.FindAttribute[*goap.ASTagData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_TAG}
|
|
||||||
}
|
|
||||||
url, ok := goap.FindAttribute[*goap.ASUrlData](base)
|
|
||||||
if !ok {
|
|
||||||
return nil, goap.NoRequiredFieldError{FieldName: goap.KEY_ACTIVITYSTREAMS_URL}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Person{
|
|
||||||
Id: id.Id,
|
|
||||||
Devices: devices.Id,
|
|
||||||
Discoverable: discoverable.Value.Value,
|
|
||||||
Featured: featured.Id,
|
|
||||||
FeaturedTags: featuredTags.Id,
|
|
||||||
Indexable: Indexable.Value.Value,
|
|
||||||
Memorial: memorial.Value.Value,
|
|
||||||
Inbox: inbox.Id,
|
|
||||||
PublicKey: goap.PublicKey{
|
|
||||||
Id: publicKey.Id,
|
|
||||||
Owner: publicKey.Owner,
|
|
||||||
Pem: publicKey.Key,
|
|
||||||
},
|
|
||||||
AlsoKnownAs: alsoKnownAs.Id,
|
|
||||||
Attachments: attachments.Attachments,
|
|
||||||
Endpoints: endpoints.Endpoints,
|
|
||||||
Followers: followers.Id,
|
|
||||||
Following: following.Id,
|
|
||||||
Icon: icon.Media,
|
|
||||||
Image: image.Media,
|
|
||||||
ApprovesFollowers: approvesFollowers.Value.Value,
|
|
||||||
Name: name.Value.Value,
|
|
||||||
Outbox: outbox.Id,
|
|
||||||
PreferredUsername: preferredUsername.Value.Value,
|
|
||||||
Published: published.Timestamp,
|
|
||||||
Summary: summary.Value.Value,
|
|
||||||
Tags: tags.Tags,
|
|
||||||
Url: url.Id,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Person) ToChain() goap.BaseApChain {
|
|
||||||
var x goap.BaseApChain = &goap.EmptyBaseObject{}
|
|
||||||
panic("not implemented") // TODO: Implement me
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package goap
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
xmldatetime "github.com/datainq/xml-date-time"
|
"github.com/datainq/xml-date-time"
|
||||||
"gitlab.com/mstarongitlab/goutils/sliceutils"
|
"gitlab.com/mstarongitlab/goutils/sliceutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,32 +27,55 @@ func ParseASActorData(raw map[string]any, next BaseApChain) (BaseApChain, error)
|
||||||
return &ASActorData{FullIdType: *id}, nil
|
return &ASActorData{FullIdType: *id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASActorData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASActorData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASAlsoKnownAsData struct {
|
type ASAlsoKnownAsData struct {
|
||||||
FullIdType
|
Next BaseApChain
|
||||||
|
Urls []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ASAlsoKnownAsData) GetSelfOrBase() (BaseApChain, bool) {
|
func (cc *ASAlsoKnownAsData) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
return cc.FullIdType.GetSelfOrBase()
|
return cc.Next, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ASAlsoKnownAsData) MarshalToMap() map[string]any {
|
func (cc *ASAlsoKnownAsData) MarshalToMap() map[string]any {
|
||||||
return cc.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_ALSOKNOWNAS)
|
return appendWithKey(
|
||||||
|
cc.Next.MarshalToMap(),
|
||||||
|
KEY_ACTIVITYSTREAMS_ALSOKNOWNAS,
|
||||||
|
sliceutils.Map(cc.Urls, func(t string) map[string]any {
|
||||||
|
return map[string]any{KEY_ID: t}
|
||||||
|
}),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseASAlsoKnownAsData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
func ParseASAlsoKnownAsData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
id, err := ParseIdTypeWithName(raw, next, KEY_ACTIVITYSTREAMS_ALSOKNOWNAS)
|
rawData1, ok := raw[KEY_ACTIVITYSTREAMS_ALSOKNOWNAS]
|
||||||
if err != nil {
|
if !ok {
|
||||||
return nil, err
|
return nil, NoRequiredFieldError{KEY_ACTIVITYSTREAMS_ALSOKNOWNAS}
|
||||||
}
|
}
|
||||||
return &ASAlsoKnownAsData{FullIdType: *id}, nil
|
data1, ok := rawData1.([]map[string]any)
|
||||||
}
|
if !ok {
|
||||||
|
return nil, BadFieldValueError[[]map[string]any]{
|
||||||
func AppendASAlsoKnownAsData(base BaseApChain, id string) BaseApChain {
|
KEY_ACTIVITYSTREAMS_ALSOKNOWNAS,
|
||||||
return &ASAlsoKnownAsData{FullIdType{base, id}}
|
rawData1,
|
||||||
|
[]map[string]any{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
urls := []string{}
|
||||||
|
for _, v := range data1 {
|
||||||
|
rawData2, ok := v[KEY_ID]
|
||||||
|
if !ok {
|
||||||
|
return nil, NoRequiredSubFieldError{KEY_ACTIVITYSTREAMS_ALSOKNOWNAS, KEY_ID}
|
||||||
|
}
|
||||||
|
data2, ok := rawData2.(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, BadFieldValueError[string]{KEY_ACTIVITYSTREAMS_ALSOKNOWNAS, rawData2, ""}
|
||||||
|
}
|
||||||
|
urls = append(urls, data2)
|
||||||
|
}
|
||||||
|
delete(raw, KEY_ACTIVITYSTREAMS_ALSOKNOWNAS)
|
||||||
|
return &ASAlsoKnownAsData{
|
||||||
|
Next: next,
|
||||||
|
Urls: urls,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type ASAttachmentsData struct {
|
type ASAttachmentsData struct {
|
||||||
|
@ -104,10 +127,6 @@ func ParseASAttachmentsData(raw map[string]any, next BaseApChain) (BaseApChain,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASAttachmentsData(base BaseApChain, attachments ...Attachment) BaseApChain {
|
|
||||||
return &ASAttachmentsData{base, attachments}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASAttributedToData struct {
|
type ASAttributedToData struct {
|
||||||
FullIdType
|
FullIdType
|
||||||
}
|
}
|
||||||
|
@ -128,10 +147,6 @@ func ParseASAttributedToData(raw map[string]any, next BaseApChain) (BaseApChain,
|
||||||
return &ASAttributedToData{FullIdType: *id}, nil
|
return &ASAttributedToData{FullIdType: *id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASAttributedToData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASAttributedToData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASCCData struct {
|
type ASCCData struct {
|
||||||
Next BaseApChain
|
Next BaseApChain
|
||||||
Targets []string
|
Targets []string
|
||||||
|
@ -183,10 +198,6 @@ func ParseASCCData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASCCData(base BaseApChain, targets ...string) BaseApChain {
|
|
||||||
return &ASCCData{base, targets}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Content is an array of string value types due to some servers including the content in multiple languages or with different metadata attached
|
// Content is an array of string value types due to some servers including the content in multiple languages or with different metadata attached
|
||||||
type ASContentData struct {
|
type ASContentData struct {
|
||||||
Next BaseApChain
|
Next BaseApChain
|
||||||
|
@ -235,10 +246,6 @@ func ParseASContentData(raw map[string]any, next BaseApChain) (BaseApChain, erro
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASContentData(base BaseApChain, entries ...ValueValue[string]) BaseApChain {
|
|
||||||
return &ASContentData{base, entries}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASEndpointsData struct {
|
type ASEndpointsData struct {
|
||||||
Next BaseApChain
|
Next BaseApChain
|
||||||
Endpoints map[string]string
|
Endpoints map[string]string
|
||||||
|
@ -303,10 +310,6 @@ func ParseASEndpointsData(raw map[string]any, next BaseApChain) (BaseApChain, er
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASEndpointsData(base BaseApChain, endpoints map[string]string) BaseApChain {
|
|
||||||
return &ASEndpointsData{base, endpoints}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASFollowersData struct {
|
type ASFollowersData struct {
|
||||||
FullIdType
|
FullIdType
|
||||||
}
|
}
|
||||||
|
@ -324,11 +327,7 @@ func ParseASFollowersData(raw map[string]any, next BaseApChain) (BaseApChain, er
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &ASFollowersData{FullIdType: *id}, nil
|
return &ASAttributedToData{FullIdType: *id}, nil
|
||||||
}
|
|
||||||
|
|
||||||
func AppendASFollowersData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASActorData{FullIdType{base, id}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ASFollowingData struct {
|
type ASFollowingData struct {
|
||||||
|
@ -348,11 +347,7 @@ func ParseASFollowingData(raw map[string]any, next BaseApChain) (BaseApChain, er
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &ASFollowingData{FullIdType: *id}, nil
|
return &ASAttributedToData{FullIdType: *id}, nil
|
||||||
}
|
|
||||||
|
|
||||||
func AppendASFollowingData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASFollowingData{FullIdType{base, id}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ASHrefData struct {
|
type ASHrefData struct {
|
||||||
|
@ -372,11 +367,7 @@ func ParseASHrefData(raw map[string]any, next BaseApChain) (BaseApChain, error)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &ASHrefData{FullIdType: *id}, nil
|
return &ASAttributedToData{FullIdType: *id}, nil
|
||||||
}
|
|
||||||
|
|
||||||
func AppendASHrefData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASHrefData{FullIdType{base, id}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ASIconData struct {
|
type ASIconData struct {
|
||||||
|
@ -419,10 +410,6 @@ func ParseASIconData(raw map[string]any, next BaseApChain) (BaseApChain, error)
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASIconData(base BaseApChain, media Media) BaseApChain {
|
|
||||||
return &ASIconData{base, media}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASImageData struct {
|
type ASImageData struct {
|
||||||
Next BaseApChain
|
Next BaseApChain
|
||||||
Media Media
|
Media Media
|
||||||
|
@ -467,10 +454,6 @@ func ParseASImageData(raw map[string]any, next BaseApChain) (BaseApChain, error)
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASImageData(base BaseApChain, media Media) BaseApChain {
|
|
||||||
return &ASImageData{base, media}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASMediaTypeData struct {
|
type ASMediaTypeData struct {
|
||||||
FullValueType[string]
|
FullValueType[string]
|
||||||
}
|
}
|
||||||
|
@ -491,10 +474,6 @@ func ParseASMediaTypeData(raw map[string]any, next BaseApChain) (BaseApChain, er
|
||||||
return &ASMediaTypeData{*tmp}, nil
|
return &ASMediaTypeData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASMediaTypeData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
|
||||||
return &ASMediaTypeData{FullValueType[string]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASNameData struct {
|
type ASNameData struct {
|
||||||
FullValueType[string]
|
FullValueType[string]
|
||||||
}
|
}
|
||||||
|
@ -515,10 +494,6 @@ func ParseASNameData(raw map[string]any, next BaseApChain) (BaseApChain, error)
|
||||||
return &ASNameData{*tmp}, nil
|
return &ASNameData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASNameData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
|
||||||
return &ASNameData{FullValueType[string]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASOutboxData struct {
|
type ASOutboxData struct {
|
||||||
FullIdType
|
FullIdType
|
||||||
}
|
}
|
||||||
|
@ -528,7 +503,7 @@ func (attributedtodata *ASOutboxData) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (attributedtodata *ASOutboxData) MarshalToMap() map[string]any {
|
func (attributedtodata *ASOutboxData) MarshalToMap() map[string]any {
|
||||||
return attributedtodata.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_OUTBOX)
|
return attributedtodata.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_HREF)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseASOutboxData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
func ParseASOutboxData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
|
@ -539,10 +514,6 @@ func ParseASOutboxData(raw map[string]any, next BaseApChain) (BaseApChain, error
|
||||||
return &ASOutboxData{FullIdType: *id}, nil
|
return &ASOutboxData{FullIdType: *id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASOutboxData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASOutboxData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASObjectData struct {
|
type ASObjectData struct {
|
||||||
Next BaseApChain
|
Next BaseApChain
|
||||||
// Unparsed objects. Please parse yourself. Go doesn't like the recursion if the parser for this attribute was calling Unmarshal
|
// Unparsed objects. Please parse yourself. Go doesn't like the recursion if the parser for this attribute was calling Unmarshal
|
||||||
|
@ -569,10 +540,6 @@ func ParseASObjectData(raw map[string]any, next BaseApChain) (BaseApChain, error
|
||||||
return &ASObjectData{Next: next, Objects: data}, nil
|
return &ASObjectData{Next: next, Objects: data}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASObjectData(base BaseApChain, rawObjects []map[string]any) BaseApChain {
|
|
||||||
return &ASObjectData{base, rawObjects}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASPreferredNameData struct {
|
type ASPreferredNameData struct {
|
||||||
FullValueType[string]
|
FullValueType[string]
|
||||||
}
|
}
|
||||||
|
@ -593,10 +560,6 @@ func ParseASPreferredNameData(raw map[string]any, next BaseApChain) (BaseApChain
|
||||||
return &ASPreferredNameData{*tmp}, nil
|
return &ASPreferredNameData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASPreferredNameData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
|
||||||
return &ASPreferredNameData{FullValueType[string]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASPublishedData struct {
|
type ASPublishedData struct {
|
||||||
Next BaseApChain
|
Next BaseApChain
|
||||||
Timestamp time.Time
|
Timestamp time.Time
|
||||||
|
@ -644,10 +607,6 @@ func ParseASPublishedData(raw map[string]any, next BaseApChain) (BaseApChain, er
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASPublishedData(base BaseApChain, timestamp time.Time) BaseApChain {
|
|
||||||
return &ASPublishedData{base, timestamp}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASRestrictedFollowData struct {
|
type ASRestrictedFollowData struct {
|
||||||
FullValueType[bool]
|
FullValueType[bool]
|
||||||
}
|
}
|
||||||
|
@ -668,10 +627,6 @@ func ParseASRestrictedData(raw map[string]any, next BaseApChain) (BaseApChain, e
|
||||||
return &ASRestrictedFollowData{*tmp}, nil
|
return &ASRestrictedFollowData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASRestrictedFollowData(base BaseApChain, data ValueValue[bool]) BaseApChain {
|
|
||||||
return &ASRestrictedFollowData{FullValueType[bool]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASRepliesData struct {
|
type ASRepliesData struct {
|
||||||
FullIdType
|
FullIdType
|
||||||
}
|
}
|
||||||
|
@ -692,10 +647,6 @@ func ParseASRepliesData(raw map[string]any, next BaseApChain) (BaseApChain, erro
|
||||||
return &ASRepliesData{FullIdType: *id}, nil
|
return &ASRepliesData{FullIdType: *id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASRepliesData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASRepliesData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASSharedInboxData struct {
|
type ASSharedInboxData struct {
|
||||||
FullIdType
|
FullIdType
|
||||||
}
|
}
|
||||||
|
@ -716,10 +667,6 @@ func ParseASSharedInboxData(raw map[string]any, next BaseApChain) (BaseApChain,
|
||||||
return &ASSharedInboxData{FullIdType: *id}, nil
|
return &ASSharedInboxData{FullIdType: *id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASSharedInboxData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASSharedInboxData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASSummaryData struct {
|
type ASSummaryData struct {
|
||||||
FullValueType[string]
|
FullValueType[string]
|
||||||
}
|
}
|
||||||
|
@ -740,10 +687,6 @@ func ParseASSummaryData(raw map[string]any, next BaseApChain) (BaseApChain, erro
|
||||||
return &ASSummaryData{*tmp}, nil
|
return &ASSummaryData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASSummaryData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
|
||||||
return &ASSummaryData{FullValueType[string]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASSensitiveData struct {
|
type ASSensitiveData struct {
|
||||||
FullValueType[bool]
|
FullValueType[bool]
|
||||||
}
|
}
|
||||||
|
@ -764,10 +707,6 @@ func ParseASSensitiveData(raw map[string]any, next BaseApChain) (BaseApChain, er
|
||||||
return &ASSensitiveData{*tmp}, nil
|
return &ASSensitiveData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASSensitiveData(base BaseApChain, data ValueValue[bool]) BaseApChain {
|
|
||||||
return &ASSensitiveData{FullValueType[bool]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASTagData struct {
|
type ASTagData struct {
|
||||||
Next BaseApChain
|
Next BaseApChain
|
||||||
Tags []Tag
|
Tags []Tag
|
||||||
|
@ -811,10 +750,6 @@ func ParseASTagData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASTagData(base BaseApChain, tags []Tag) BaseApChain {
|
|
||||||
return &ASTagData{base, tags}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASToData struct {
|
type ASToData struct {
|
||||||
Next BaseApChain
|
Next BaseApChain
|
||||||
Targets []string
|
Targets []string
|
||||||
|
@ -863,10 +798,6 @@ func ParseASToData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASToData(base BaseApChain, targets ...string) BaseApChain {
|
|
||||||
return &ASToData{base, targets}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASUrlData struct {
|
type ASUrlData struct {
|
||||||
FullIdType
|
FullIdType
|
||||||
}
|
}
|
||||||
|
@ -876,7 +807,7 @@ func (object *ASUrlData) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (object *ASUrlData) MarshalToMap() map[string]any {
|
func (object *ASUrlData) MarshalToMap() map[string]any {
|
||||||
return object.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_URL)
|
return object.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_SHAREDINBOX)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseASUrlData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
func ParseASUrlData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
|
@ -887,10 +818,6 @@ func ParseASUrlData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
return &ASUrlData{FullIdType: *id}, nil
|
return &ASUrlData{FullIdType: *id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASUrlData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASUrlData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASUpdatedData struct {
|
type ASUpdatedData struct {
|
||||||
Next BaseApChain
|
Next BaseApChain
|
||||||
Timestamp time.Time
|
Timestamp time.Time
|
||||||
|
@ -937,176 +864,3 @@ func ParseASUpdatedData(raw map[string]any, next BaseApChain) (BaseApChain, erro
|
||||||
Timestamp: t,
|
Timestamp: t,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendASUpdatedData(base BaseApChain, timestamp time.Time) BaseApChain {
|
|
||||||
return &ASUpdatedData{base, timestamp}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASFirstData struct {
|
|
||||||
Next BaseApChain
|
|
||||||
// Technically the object is decodable into BaseApChain as well
|
|
||||||
// but Go doesn't like the potential recursive call
|
|
||||||
// So uhh, you have to do it yourself
|
|
||||||
Objects map[string]any
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *ASFirstData) GetSelfOrBase() (BaseApChain, bool) {
|
|
||||||
return a.Next, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *ASFirstData) MarshalToMap() map[string]any {
|
|
||||||
return appendWithKey(
|
|
||||||
a.Next.MarshalToMap(),
|
|
||||||
KEY_ACTIVITYSTREAMS_FIRST,
|
|
||||||
[]map[string]any{a.Objects},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseASFirstData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
|
||||||
rawData, ok := raw[KEY_ACTIVITYSTREAMS_FIRST]
|
|
||||||
if !ok {
|
|
||||||
return nil, NoRequiredFieldError{KEY_ACTIVITYSTREAMS_FIRST}
|
|
||||||
}
|
|
||||||
data, ok := rawData.([]map[string]any)
|
|
||||||
if !ok {
|
|
||||||
return nil, BadFieldValueError[[]map[string]any]{KEY_ACTIVITYSTREAMS_FIRST, rawData, data}
|
|
||||||
}
|
|
||||||
if len(data) != 1 {
|
|
||||||
return nil, BadFieldArrayLengthError{KEY_ACTIVITYSTREAMS_FIRST, 1, len(data)}
|
|
||||||
}
|
|
||||||
delete(raw, KEY_ACTIVITYSTREAMS_FIRST)
|
|
||||||
return &ASFirstData{
|
|
||||||
Next: next,
|
|
||||||
Objects: data[0],
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func AppendASFirstData(base BaseApChain, rawObject map[string]any) BaseApChain {
|
|
||||||
return &ASFirstData{base, rawObject}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASItemsData struct {
|
|
||||||
Next BaseApChain
|
|
||||||
// Items are all AP objects, but can't preparse since Go doesn't like the potential recursion
|
|
||||||
Items []map[string]any
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *ASItemsData) GetSelfOrBase() (BaseApChain, bool) {
|
|
||||||
return a.Next, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *ASItemsData) MarshalToMap() map[string]any {
|
|
||||||
return appendWithKey(a.Next.MarshalToMap(), KEY_ACTIVITYSTREAMS_ITEMS, a.Items)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseASItemsData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
|
||||||
rawData, ok := raw[KEY_ACTIVITYSTREAMS_ITEMS]
|
|
||||||
if !ok {
|
|
||||||
return nil, NoRequiredFieldError{KEY_ACTIVITYSTREAMS_ITEMS}
|
|
||||||
}
|
|
||||||
data, ok := rawData.([]map[string]any)
|
|
||||||
if !ok {
|
|
||||||
return nil, BadFieldValueError[[]map[string]any]{KEY_ACTIVITYSTREAMS_ITEMS, rawData, data}
|
|
||||||
}
|
|
||||||
return &ASItemsData{Next: next, Items: data}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func AppendASItemsData(base BaseApChain, rawObjects ...map[string]any) BaseApChain {
|
|
||||||
return &ASItemsData{base, rawObjects}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASNextData struct {
|
|
||||||
FullIdType
|
|
||||||
}
|
|
||||||
|
|
||||||
func (object *ASNextData) GetSelfOrBase() (BaseApChain, bool) {
|
|
||||||
return object.FullIdType.Next, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (object *ASNextData) MarshalToMap() map[string]any {
|
|
||||||
return object.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_NEXT)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseASNextData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
|
||||||
id, err := ParseIdTypeWithName(raw, next, KEY_ACTIVITYSTREAMS_NEXT)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &ASNextData{FullIdType: *id}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func AppendASNextData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASNextData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASPartOfData struct {
|
|
||||||
FullIdType
|
|
||||||
}
|
|
||||||
|
|
||||||
func (object *ASPartOfData) GetSelfOrBase() (BaseApChain, bool) {
|
|
||||||
return object.FullIdType.Next, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (object *ASPartOfData) MarshalToMap() map[string]any {
|
|
||||||
return object.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_PARTOF)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseASPartOfData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
|
||||||
id, err := ParseIdTypeWithName(raw, next, KEY_ACTIVITYSTREAMS_PARTOF)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &ASPartOfData{FullIdType: *id}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func AppendASPartOfData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASPartOfData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASInReplyToData struct {
|
|
||||||
FullIdType
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *ASInReplyToData) GetSelfOrBase() (BaseApChain, bool) {
|
|
||||||
return a.Next, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *ASInReplyToData) MarshalToMap() map[string]any {
|
|
||||||
return a.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_INREPLYTO)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseASInReplyToData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
|
||||||
id, err := ParseIdTypeWithName(raw, next, KEY_ACTIVITYSTREAMS_INREPLYTO)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &ASInReplyToData{*id}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func AppendASInReplyToData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &ASInReplyToData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ASQuoteUrlData struct {
|
|
||||||
FullValueType[string]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (namedata *ASQuoteUrlData) GetSelfOrBase() (BaseApChain, bool) {
|
|
||||||
return namedata.Next, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (namedata *ASQuoteUrlData) MarshalToMap() map[string]any {
|
|
||||||
return namedata.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_QUOTEURL)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseASQuoteUrlData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
|
||||||
tmp, err := ParseValueTypeWithName[string](raw, next, KEY_ACTIVITYSTREAMS_QUOTEURL)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &ASQuoteUrlData{*tmp}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func AppendASQuoteUrlData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
|
||||||
return &ASQuoteUrlData{FullValueType[string]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
package goap
|
|
||||||
|
|
||||||
type FedibirdQuoteUriData struct {
|
|
||||||
FullValueType[string]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *FedibirdQuoteUriData) GetSelfOrBase() (BaseApChain, bool) {
|
|
||||||
return f.Next, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *FedibirdQuoteUriData) MarshalToMap() map[string]any {
|
|
||||||
return f.MarshalToMapWithName(KEY_FEDIBIRD_QUOTEURI)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseFedibirdQuoteUriData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
|
||||||
v, err := ParseValueTypeWithName[string](raw, next, KEY_FEDIBIRD_QUOTEURI)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &FedibirdQuoteUriData{*v}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func AppendFedibirdQuoteUriData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
|
||||||
return &FedibirdQuoteUriData{FullValueType[string]{base, data}}
|
|
||||||
}
|
|
|
@ -32,10 +32,6 @@ func ParseLitepubCapabilitiesData(raw map[string]any, next BaseApChain) (BaseApC
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendLitepubCapabilitiesData(base BaseApChain, rawData ...map[string]any) BaseApChain {
|
|
||||||
return &LitepubCapabilitiesData{base, rawData}
|
|
||||||
}
|
|
||||||
|
|
||||||
type LitepubOauthRegistrationEndpointData struct {
|
type LitepubOauthRegistrationEndpointData struct {
|
||||||
FullIdType
|
FullIdType
|
||||||
}
|
}
|
||||||
|
@ -60,7 +56,3 @@ func ParseLitepubOauthRegistrationEndpointData(
|
||||||
}
|
}
|
||||||
return &LitepubOauthRegistrationEndpointData{FullIdType: *id}, nil
|
return &LitepubOauthRegistrationEndpointData{FullIdType: *id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendLitepubOauthRegistrationEndpointsData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &LitepubOauthRegistrationEndpointData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
24
nsMasto.go
24
nsMasto.go
|
@ -20,10 +20,6 @@ func ParseMastoDevicesData(raw map[string]any, next BaseApChain) (BaseApChain, e
|
||||||
return &MastoDevicesData{FullIdType: *id}, nil
|
return &MastoDevicesData{FullIdType: *id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendMastoDevicesData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &MastoDevicesData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type MastoDiscoverableData struct {
|
type MastoDiscoverableData struct {
|
||||||
FullValueType[bool]
|
FullValueType[bool]
|
||||||
}
|
}
|
||||||
|
@ -44,10 +40,6 @@ func ParseMastoDiscoverableData(raw map[string]any, next BaseApChain) (BaseApCha
|
||||||
return &MastoDiscoverableData{*tmp}, nil
|
return &MastoDiscoverableData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendMastoDiscoverableData(base BaseApChain, data ValueValue[bool]) BaseApChain {
|
|
||||||
return &MastoDiscoverableData{FullValueType[bool]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type MastoFeaturedData struct {
|
type MastoFeaturedData struct {
|
||||||
FullIdType
|
FullIdType
|
||||||
}
|
}
|
||||||
|
@ -68,10 +60,6 @@ func ParseMastoFeaturedData(raw map[string]any, next BaseApChain) (BaseApChain,
|
||||||
return &MastoFeaturedData{FullIdType: *id}, nil
|
return &MastoFeaturedData{FullIdType: *id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendMastoFeaturedData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &MastoFeaturedData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type MastoFeaturedTagsData struct {
|
type MastoFeaturedTagsData struct {
|
||||||
FullIdType
|
FullIdType
|
||||||
}
|
}
|
||||||
|
@ -92,10 +80,6 @@ func ParseMastoFeaturedTagsData(raw map[string]any, next BaseApChain) (BaseApCha
|
||||||
return &MastoFeaturedTagsData{FullIdType: *id}, nil
|
return &MastoFeaturedTagsData{FullIdType: *id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendMastoFeaturedTagsData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &MastoFeaturedTagsData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type MastoIndexableData struct {
|
type MastoIndexableData struct {
|
||||||
FullValueType[bool]
|
FullValueType[bool]
|
||||||
}
|
}
|
||||||
|
@ -116,10 +100,6 @@ func ParseMastoIndexableData(raw map[string]any, next BaseApChain) (BaseApChain,
|
||||||
return &MastoIndexableData{*tmp}, nil
|
return &MastoIndexableData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendMastoIndexableData(base BaseApChain, data ValueValue[bool]) BaseApChain {
|
|
||||||
return &MastoIndexableData{FullValueType[bool]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type MastoMemorialData struct {
|
type MastoMemorialData struct {
|
||||||
FullValueType[bool]
|
FullValueType[bool]
|
||||||
}
|
}
|
||||||
|
@ -139,7 +119,3 @@ func ParseMastoMemorialData(raw map[string]any, next BaseApChain) (BaseApChain,
|
||||||
}
|
}
|
||||||
return &MastoMemorialData{*tmp}, nil
|
return &MastoMemorialData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendMastoMemorialData(base BaseApChain, data ValueValue[bool]) BaseApChain {
|
|
||||||
return &MastoMemorialData{FullValueType[bool]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
36
nsMisskey.go
36
nsMisskey.go
|
@ -22,10 +22,6 @@ func ParseMKSummaryData(raw map[string]any, next BaseApChain) (BaseApChain, erro
|
||||||
return &MKSummaryData{*tmp}, nil
|
return &MKSummaryData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendMKSummaryData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
|
||||||
return &MKSummaryData{FullValueType[string]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type MKIsCatData struct {
|
type MKIsCatData struct {
|
||||||
FullValueType[bool]
|
FullValueType[bool]
|
||||||
}
|
}
|
||||||
|
@ -46,10 +42,6 @@ func ParseMKIsCatData(raw map[string]any, next BaseApChain) (BaseApChain, error)
|
||||||
return &MKIsCatData{*tmp}, nil
|
return &MKIsCatData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendMKIsCatData(base BaseApChain, data ValueValue[bool]) BaseApChain {
|
|
||||||
return &MKIsCatData{FullValueType[bool]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type FFSpeakAsCatData struct {
|
type FFSpeakAsCatData struct {
|
||||||
FullValueType[bool]
|
FullValueType[bool]
|
||||||
}
|
}
|
||||||
|
@ -69,31 +61,3 @@ func ParseFFSpeakAsCatData(raw map[string]any, next BaseApChain) (BaseApChain, e
|
||||||
}
|
}
|
||||||
return &FFSpeakAsCatData{*tmp}, nil
|
return &FFSpeakAsCatData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendFFSpeakAsCatData(base BaseApChain, data ValueValue[bool]) BaseApChain {
|
|
||||||
return &FFSpeakAsCatData{FullValueType[bool]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type MKQuoteData struct {
|
|
||||||
FullValueType[string]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (misskeysummarydata *MKQuoteData) GetSelfOrBase() (BaseApChain, bool) {
|
|
||||||
return misskeysummarydata.Next, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (misskeysummarydata *MKQuoteData) MarshalToMap() map[string]any {
|
|
||||||
return misskeysummarydata.MarshalToMapWithName(KEY_MISSKEY_MKQUOTE)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseMKQuoteData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
|
||||||
tmp, err := ParseValueTypeWithName[string](raw, next, KEY_MISSKEY_MKQUOTE)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &MKQuoteData{*tmp}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func AppendMKQuoteData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
|
||||||
return &MKQuoteData{FullValueType[string]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
96
nsOstatus.go
96
nsOstatus.go
|
@ -1,7 +1,8 @@
|
||||||
package goap
|
package goap
|
||||||
|
|
||||||
type OstatusAtomUriData struct {
|
type OstatusAtomUriData struct {
|
||||||
FullValueType[string]
|
Next BaseApChain
|
||||||
|
Uri ValueValue[string]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (atomurivalue *OstatusAtomUriData) GetSelfOrBase() (BaseApChain, bool) {
|
func (atomurivalue *OstatusAtomUriData) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
|
@ -9,23 +10,43 @@ func (atomurivalue *OstatusAtomUriData) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (atomurivalue *OstatusAtomUriData) MarshalToMap() map[string]any {
|
func (atomurivalue *OstatusAtomUriData) MarshalToMap() map[string]any {
|
||||||
return atomurivalue.MarshalToMapWithName(KEY_OSTATUS_ATOMURI)
|
return appendWithKey(
|
||||||
|
atomurivalue.Next.MarshalToMap(),
|
||||||
|
KEY_OSTATUS_ATOMURI,
|
||||||
|
[]map[string]any{atomurivalue.Uri.Marshal()},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseOstatusAtomUriData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
func ParseOstatusAtomUriData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
v, err := ParseValueTypeWithName[string](raw, next, KEY_OSTATUS_ATOMURI)
|
rawData1, ok := raw[KEY_OSTATUS_ATOMURI]
|
||||||
|
if !ok {
|
||||||
|
return nil, NoRequiredFieldError{KEY_OSTATUS_ATOMURI}
|
||||||
|
}
|
||||||
|
data1, ok := rawData1.([]map[string]any)
|
||||||
|
if !ok {
|
||||||
|
return nil, BadFieldValueError[[]map[string]any]{
|
||||||
|
KEY_OSTATUS_ATOMURI,
|
||||||
|
rawData1,
|
||||||
|
data1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(data1) != 1 {
|
||||||
|
return nil, BadFieldArrayLengthError{KEY_OSTATUS_ATOMURI, 1, len(data1)}
|
||||||
|
}
|
||||||
|
tmp, err := ParseValueValue[string](data1[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &OstatusAtomUriData{*v}, nil
|
delete(raw, KEY_OSTATUS_ATOMURI)
|
||||||
}
|
return &OstatusAtomUriData{
|
||||||
|
Next: next,
|
||||||
func AppendOstatusAtomUriData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
Uri: *tmp,
|
||||||
return &OstatusAtomUriData{FullValueType[string]{base, data}}
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type OstatusConversationData struct {
|
type OstatusConversationData struct {
|
||||||
FullValueType[string]
|
Next BaseApChain
|
||||||
|
Uri ValueValue[string]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (atomurivalue *OstatusConversationData) GetSelfOrBase() (BaseApChain, bool) {
|
func (atomurivalue *OstatusConversationData) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
|
@ -33,41 +54,36 @@ func (atomurivalue *OstatusConversationData) GetSelfOrBase() (BaseApChain, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (atomurivalue *OstatusConversationData) MarshalToMap() map[string]any {
|
func (atomurivalue *OstatusConversationData) MarshalToMap() map[string]any {
|
||||||
return atomurivalue.MarshalToMapWithName(KEY_OSTATUS_CONVERSATION)
|
return appendWithKey(
|
||||||
|
atomurivalue.Next.MarshalToMap(),
|
||||||
|
KEY_OSTATUS_CONVERSATION,
|
||||||
|
[]map[string]any{atomurivalue.Uri.Marshal()},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseOstatusConversationData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
func ParseOstatusConversationData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
v, err := ParseValueTypeWithName[string](raw, next, KEY_OSTATUS_CONVERSATION)
|
rawData1, ok := raw[KEY_OSTATUS_CONVERSATION]
|
||||||
|
if !ok {
|
||||||
|
return nil, NoRequiredFieldError{KEY_OSTATUS_CONVERSATION}
|
||||||
|
}
|
||||||
|
data1, ok := rawData1.([]map[string]any)
|
||||||
|
if !ok {
|
||||||
|
return nil, BadFieldValueError[[]map[string]any]{
|
||||||
|
KEY_OSTATUS_CONVERSATION,
|
||||||
|
rawData1,
|
||||||
|
data1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(data1) != 1 {
|
||||||
|
return nil, BadFieldArrayLengthError{KEY_OSTATUS_CONVERSATION, 1, len(data1)}
|
||||||
|
}
|
||||||
|
tmp, err := ParseValueValue[string](data1[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &OstatusConversationData{*v}, nil
|
delete(raw, KEY_OSTATUS_CONVERSATION)
|
||||||
}
|
return &OstatusConversationData{
|
||||||
|
Next: next,
|
||||||
func AppendOstatusConversationData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
Uri: *tmp,
|
||||||
return &OstatusConversationData{FullValueType[string]{base, data}}
|
}, nil
|
||||||
}
|
|
||||||
|
|
||||||
type OstatusReplyToAtomUriData struct {
|
|
||||||
FullValueType[string]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *OstatusReplyToAtomUriData) GetSelfOrBase() (BaseApChain, bool) {
|
|
||||||
return a.Next, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *OstatusReplyToAtomUriData) MarshalToMap() map[string]any {
|
|
||||||
return a.MarshalToMapWithName(KEY_OSTATUS_INREPLYTOATOMURI)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseOstatusInReplyToAtomUriData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
|
||||||
v, err := ParseValueTypeWithName[string](raw, next, KEY_OSTATUS_INREPLYTOATOMURI)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &OstatusReplyToAtomUriData{*v}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func AppendOstatusInReplyToAtomUriData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
|
||||||
return &OstatusReplyToAtomUriData{FullValueType[string]{base, data}}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,3 @@ func ParseSchemaValueData(raw map[string]any, next BaseApChain) (BaseApChain, er
|
||||||
}
|
}
|
||||||
return &SchemaValueData{*tmp}, nil
|
return &SchemaValueData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendSchemaValueData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
|
||||||
return &SchemaValueData{FullValueType[string]{base, data}}
|
|
||||||
}
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ func (u *UDIdData) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *UDIdData) MarshalToMap() map[string]any {
|
func (b *UDIdData) MarshalToMap() map[string]any {
|
||||||
return appendWithKey(b.Next.MarshalToMap(), KEY_ID, b.Id)
|
return appendWithKey(b.Next.MarshalToMap(), "KEY_ID", b.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseUDIdData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
func ParseUDIdData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
|
@ -29,10 +29,6 @@ func ParseUDIdData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendUDIdData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &UDIdData{base, id}
|
|
||||||
}
|
|
||||||
|
|
||||||
type UDTypeData struct {
|
type UDTypeData struct {
|
||||||
Next BaseApChain
|
Next BaseApChain
|
||||||
Type string
|
Type string
|
||||||
|
@ -60,7 +56,3 @@ func ParseUDTypeData(raw map[string]any, next BaseApChain) (BaseApChain, error)
|
||||||
}
|
}
|
||||||
return &UDTypeData{Next: next, Type: objType[0]}, nil
|
return &UDTypeData{Next: next, Type: objType[0]}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendUDTypeData(base BaseApChain, typeString string) BaseApChain {
|
|
||||||
return &UDTypeData{base, typeString}
|
|
||||||
}
|
|
||||||
|
|
4
nsW3.go
4
nsW3.go
|
@ -19,7 +19,3 @@ func ParseW3InboxData(raw map[string]any, next BaseApChain) (BaseApChain, error)
|
||||||
}
|
}
|
||||||
return &W3InboxData{*tmp}, nil
|
return &W3InboxData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendW3InboxData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &W3InboxData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,12 +20,7 @@ func ParseW3SecurityOwnerData(raw map[string]any, next BaseApChain) (BaseApChain
|
||||||
return &W3SecurityOwnerData{*tmp}, nil
|
return &W3SecurityOwnerData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendW3SecurityOwnerData(base BaseApChain, id string) BaseApChain {
|
|
||||||
return &W3SecurityOwnerData{FullIdType{base, id}}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Handle case with multiple public keys (if allowed, idk if it is)
|
// TODO: Handle case with multiple public keys (if allowed, idk if it is)
|
||||||
|
|
||||||
type W3SecurityPublicKeyData struct {
|
type W3SecurityPublicKeyData struct {
|
||||||
Next BaseApChain
|
Next BaseApChain
|
||||||
Id string
|
Id string
|
||||||
|
@ -82,10 +77,6 @@ func ParseW3SecurityPublicKeyData(raw map[string]any, next BaseApChain) (BaseApC
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendW3SecurityPublicKeyData(base BaseApChain, id, owner, key string) BaseApChain {
|
|
||||||
return &W3SecurityPublicKeyData{base, id, owner, key}
|
|
||||||
}
|
|
||||||
|
|
||||||
type W3SecurityPublicKeyPemData struct {
|
type W3SecurityPublicKeyPemData struct {
|
||||||
FullValueType[string]
|
FullValueType[string]
|
||||||
}
|
}
|
||||||
|
@ -105,7 +96,3 @@ func ParseW3SecurityPublicKeyPemData(raw map[string]any, next BaseApChain) (Base
|
||||||
}
|
}
|
||||||
return &W3SecurityPublicKeyPemData{*tmp}, nil
|
return &W3SecurityPublicKeyPemData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendW3SecurityPublicKeyPemData(base BaseApChain, value ValueValue[string]) BaseApChain {
|
|
||||||
return &W3SecurityPublicKeyPemData{FullValueType[string]{base, value}}
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,10 +20,6 @@ func ParseW3VcardAddressData(raw map[string]any, next BaseApChain) (BaseApChain,
|
||||||
return &W3VcardAddressData{*tmp}, nil
|
return &W3VcardAddressData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendW3VcardAddressData(base BaseApChain, value ValueValue[string]) BaseApChain {
|
|
||||||
return &W3VcardAddressData{FullValueType[string]{base, value}}
|
|
||||||
}
|
|
||||||
|
|
||||||
type W3VcardBirthdayData struct {
|
type W3VcardBirthdayData struct {
|
||||||
FullValueType[string]
|
FullValueType[string]
|
||||||
}
|
}
|
||||||
|
@ -43,7 +39,3 @@ func ParseW3VcardBirthdayData(raw map[string]any, next BaseApChain) (BaseApChain
|
||||||
}
|
}
|
||||||
return &W3VcardBirthdayData{*tmp}, nil
|
return &W3VcardBirthdayData{*tmp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AppendW3VcardBirthdayData(base BaseApChain, value ValueValue[string]) BaseApChain {
|
|
||||||
return &W3VcardBirthdayData{FullValueType[string]{base, value}}
|
|
||||||
}
|
|
||||||
|
|
35
parser.go
35
parser.go
|
@ -1,7 +1,6 @@
|
||||||
package goap
|
package goap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
|
@ -39,16 +38,9 @@ var allInternalParsersExceptBase []UnmarshalFunc = []UnmarshalFunc{
|
||||||
ParseASToData,
|
ParseASToData,
|
||||||
ParseASUrlData,
|
ParseASUrlData,
|
||||||
ParseASUpdatedData,
|
ParseASUpdatedData,
|
||||||
ParseASFirstData,
|
|
||||||
ParseASNextData,
|
|
||||||
ParseASItemsData,
|
|
||||||
ParseASPartOfData,
|
|
||||||
ParseASInReplyToData,
|
|
||||||
ParseASQuoteUrlData,
|
|
||||||
|
|
||||||
ParseOstatusAtomUriData,
|
ParseOstatusAtomUriData,
|
||||||
ParseOstatusConversationData,
|
ParseOstatusConversationData,
|
||||||
ParseOstatusInReplyToAtomUriData,
|
|
||||||
|
|
||||||
ParseW3InboxData,
|
ParseW3InboxData,
|
||||||
|
|
||||||
|
@ -70,11 +62,8 @@ var allInternalParsersExceptBase []UnmarshalFunc = []UnmarshalFunc{
|
||||||
|
|
||||||
ParseMKIsCatData,
|
ParseMKIsCatData,
|
||||||
ParseMKSummaryData,
|
ParseMKSummaryData,
|
||||||
ParseMKQuoteData,
|
|
||||||
|
|
||||||
ParseFFSpeakAsCatData,
|
ParseFFSpeakAsCatData,
|
||||||
|
|
||||||
ParseFedibirdQuoteUriData,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func chainParse(
|
func chainParse(
|
||||||
|
@ -140,7 +129,7 @@ func UnmarshalPreprocessed(
|
||||||
// Find an attribute in an ActivityPub object of the given type
|
// Find an attribute in an ActivityPub object of the given type
|
||||||
// Returns a pointer to the found attribute and whether it found it
|
// Returns a pointer to the found attribute and whether it found it
|
||||||
// 2nd parameter is true if the attribute was found, false otherwise
|
// 2nd parameter is true if the attribute was found, false otherwise
|
||||||
func FindAttribute[T BaseApChain](object BaseApChain) (T, bool) {
|
func FindAttribute[T BaseApChain](object BaseApChain) (*T, bool) {
|
||||||
var obj T
|
var obj T
|
||||||
var ok bool
|
var ok bool
|
||||||
// Try and cast object into wanted type
|
// Try and cast object into wanted type
|
||||||
|
@ -151,26 +140,8 @@ func FindAttribute[T BaseApChain](object BaseApChain) (T, bool) {
|
||||||
object, ok = object.GetSelfOrBase()
|
object, ok = object.GetSelfOrBase()
|
||||||
// If this is the final object in the chain, cancel and return false
|
// If this is the final object in the chain, cancel and return false
|
||||||
if !ok {
|
if !ok {
|
||||||
return obj, false
|
return nil, false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return obj, true
|
return &obj, true
|
||||||
}
|
|
||||||
|
|
||||||
func Compact(chain BaseApChain, ldContext any) (map[string]any, error) {
|
|
||||||
chainMap := chain.MarshalToMap()
|
|
||||||
proc := ld.NewJsonLdProcessor()
|
|
||||||
options := ld.NewJsonLdOptions("")
|
|
||||||
return proc.Compact(chainMap, ldContext, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Marshal(chain BaseApChain, ldContext any) ([]byte, error) {
|
|
||||||
chainMap := chain.MarshalToMap()
|
|
||||||
proc := ld.NewJsonLdProcessor()
|
|
||||||
options := ld.NewJsonLdOptions("")
|
|
||||||
compacted, err := proc.Compact(chainMap, ldContext, options)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return json.Marshal(compacted)
|
|
||||||
}
|
}
|
||||||
|
|
3
tags.go
3
tags.go
|
@ -2,7 +2,10 @@ package goap
|
||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
|
// go-sumtype:decl TagSum
|
||||||
type Tag interface {
|
type Tag interface {
|
||||||
|
// TagEmoji | TagMention | TagHashtag
|
||||||
|
|
||||||
Marshal() map[string]any
|
Marshal() map[string]any
|
||||||
sealed()
|
sealed()
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,9 +56,6 @@ func (i IdValue) Marshal() map[string]any {
|
||||||
|
|
||||||
func (v ValueValue[T]) Marshal() map[string]any {
|
func (v ValueValue[T]) Marshal() map[string]any {
|
||||||
m := maps.Clone(v.OtherThings)
|
m := maps.Clone(v.OtherThings)
|
||||||
if m == nil {
|
|
||||||
m = map[string]any{}
|
|
||||||
}
|
|
||||||
m[KEY_VALUE] = v.Value
|
m[KEY_VALUE] = v.Value
|
||||||
if v.Type != nil {
|
if v.Type != nil {
|
||||||
m[KEY_TYPE] = *v.Type
|
m[KEY_TYPE] = *v.Type
|
||||||
|
|
Loading…
Reference in a new issue