Compare commits
17 commits
Author | SHA1 | Date | |
---|---|---|---|
de5dd7ce13 | |||
cb09d23eb5 | |||
bb46f46cd6 | |||
832ee39b45 | |||
e94a1f9267 | |||
dedb3faf8c | |||
45fa095a15 | |||
f85e4b0a9b | |||
6f9ac80c39 | |||
e534fc8ec4 | |||
43b1310f3e | |||
6fa37a91b8 | |||
2bee4c5fb5 | |||
5aec50990e | |||
![]() |
d83260e277 | ||
![]() |
ce173bbb74 | ||
![]() |
0281bc9428 |
25 changed files with 1084 additions and 112 deletions
19
CHANGELOG
Normal file
19
CHANGELOG
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
- 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,6 +21,9 @@ 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
|
||||||
}
|
}
|
||||||
|
@ -63,6 +66,9 @@ 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,11 +1,13 @@
|
||||||
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
|
||||||
|
@ -17,6 +19,7 @@ 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
|
||||||
|
@ -25,9 +28,14 @@ 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?
|
||||||
|
@ -56,7 +64,12 @@ 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
|
||||||
|
|
||||||
|
@ -76,7 +89,10 @@ 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?
|
||||||
|
@ -84,35 +100,51 @@ 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"
|
KEY_OSTATUS_ATOMURI = "http://ostatus.org#atomUri" // Same as @id I think
|
||||||
KEY_OSTATUS_CONVERSATION = "http://ostatus.org#conversation"
|
KEY_OSTATUS_CONVERSATION = "http://ostatus.org#conversation" // Similar to inReplyTo
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
|
122
examples/filled_collection.json
Normal file
122
examples/filled_collection.json
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"@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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
96
examples/masto_reply.json
Normal file
96
examples/masto_reply.json
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"@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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
75
examples/mk_quote.json
Normal file
75
examples/mk_quote.json
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"@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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
43
examples/raw/masto_reply.json
Normal file
43
examples/raw/masto_reply.json
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"@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": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
54
examples/raw/mk_quote.json
Normal file
54
examples/raw/mk_quote.json
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
{
|
||||||
|
"@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"
|
||||||
|
|
||||||
"gitlab.com/mstarongitlab/goap"
|
"git.mstar.dev/mstar/goap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateEvent struct {
|
type CreateEvent struct {
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
||||||
module gitlab.com/mstarongitlab/goap
|
module git.mstar.dev/mstar/goap
|
||||||
|
|
||||||
go 1.22.5
|
go 1.22.5
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package mastodon
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gitlab.com/mstarongitlab/goap"
|
"git.mstar.dev/mstar/goap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Person struct {
|
type Person struct {
|
||||||
|
@ -32,3 +32,139 @@ 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"
|
||||||
|
|
||||||
"github.com/datainq/xml-date-time"
|
xmldatetime "github.com/datainq/xml-date-time"
|
||||||
"gitlab.com/mstarongitlab/goutils/sliceutils"
|
"gitlab.com/mstarongitlab/goutils/sliceutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,55 +27,32 @@ 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 {
|
||||||
Next BaseApChain
|
FullIdType
|
||||||
Urls []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ASAlsoKnownAsData) GetSelfOrBase() (BaseApChain, bool) {
|
func (cc *ASAlsoKnownAsData) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
return cc.Next, true
|
return cc.FullIdType.GetSelfOrBase()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ASAlsoKnownAsData) MarshalToMap() map[string]any {
|
func (cc *ASAlsoKnownAsData) MarshalToMap() map[string]any {
|
||||||
return appendWithKey(
|
return cc.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_ALSOKNOWNAS)
|
||||||
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) {
|
||||||
rawData1, ok := raw[KEY_ACTIVITYSTREAMS_ALSOKNOWNAS]
|
id, err := ParseIdTypeWithName(raw, next, KEY_ACTIVITYSTREAMS_ALSOKNOWNAS)
|
||||||
if !ok {
|
if err != nil {
|
||||||
return nil, NoRequiredFieldError{KEY_ACTIVITYSTREAMS_ALSOKNOWNAS}
|
return nil, err
|
||||||
}
|
}
|
||||||
data1, ok := rawData1.([]map[string]any)
|
return &ASAlsoKnownAsData{FullIdType: *id}, nil
|
||||||
if !ok {
|
|
||||||
return nil, BadFieldValueError[[]map[string]any]{
|
|
||||||
KEY_ACTIVITYSTREAMS_ALSOKNOWNAS,
|
|
||||||
rawData1,
|
|
||||||
[]map[string]any{},
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
urls := []string{}
|
func AppendASAlsoKnownAsData(base BaseApChain, id string) BaseApChain {
|
||||||
for _, v := range data1 {
|
return &ASAlsoKnownAsData{FullIdType{base, id}}
|
||||||
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 {
|
||||||
|
@ -127,6 +104,10 @@ 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
|
||||||
}
|
}
|
||||||
|
@ -147,6 +128,10 @@ 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
|
||||||
|
@ -198,6 +183,10 @@ 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
|
||||||
|
@ -246,6 +235,10 @@ 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
|
||||||
|
@ -310,6 +303,10 @@ 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
|
||||||
}
|
}
|
||||||
|
@ -327,7 +324,11 @@ func ParseASFollowersData(raw map[string]any, next BaseApChain) (BaseApChain, er
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &ASAttributedToData{FullIdType: *id}, nil
|
return &ASFollowersData{FullIdType: *id}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func AppendASFollowersData(base BaseApChain, id string) BaseApChain {
|
||||||
|
return &ASActorData{FullIdType{base, id}}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ASFollowingData struct {
|
type ASFollowingData struct {
|
||||||
|
@ -347,7 +348,11 @@ func ParseASFollowingData(raw map[string]any, next BaseApChain) (BaseApChain, er
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &ASAttributedToData{FullIdType: *id}, nil
|
return &ASFollowingData{FullIdType: *id}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func AppendASFollowingData(base BaseApChain, id string) BaseApChain {
|
||||||
|
return &ASFollowingData{FullIdType{base, id}}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ASHrefData struct {
|
type ASHrefData struct {
|
||||||
|
@ -367,7 +372,11 @@ func ParseASHrefData(raw map[string]any, next BaseApChain) (BaseApChain, error)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &ASAttributedToData{FullIdType: *id}, nil
|
return &ASHrefData{FullIdType: *id}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func AppendASHrefData(base BaseApChain, id string) BaseApChain {
|
||||||
|
return &ASHrefData{FullIdType{base, id}}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ASIconData struct {
|
type ASIconData struct {
|
||||||
|
@ -410,6 +419,10 @@ 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
|
||||||
|
@ -454,6 +467,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -474,6 +491,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -494,6 +515,10 @@ 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
|
||||||
}
|
}
|
||||||
|
@ -503,7 +528,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_HREF)
|
return attributedtodata.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_OUTBOX)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseASOutboxData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
func ParseASOutboxData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
|
@ -514,6 +539,10 @@ 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
|
||||||
|
@ -540,6 +569,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -560,6 +593,10 @@ 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
|
||||||
|
@ -607,6 +644,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -627,6 +668,10 @@ 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
|
||||||
}
|
}
|
||||||
|
@ -647,6 +692,10 @@ 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
|
||||||
}
|
}
|
||||||
|
@ -667,6 +716,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -687,6 +740,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -707,6 +764,10 @@ 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
|
||||||
|
@ -750,6 +811,10 @@ 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
|
||||||
|
@ -798,6 +863,10 @@ 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
|
||||||
}
|
}
|
||||||
|
@ -807,7 +876,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_SHAREDINBOX)
|
return object.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseASUrlData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
func ParseASUrlData(raw map[string]any, next BaseApChain) (BaseApChain, error) {
|
||||||
|
@ -818,6 +887,10 @@ 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
|
||||||
|
@ -864,3 +937,176 @@ 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}}
|
||||||
|
}
|
||||||
|
|
25
nsFedibird.go
Normal file
25
nsFedibird.go
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
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,6 +32,10 @@ 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
|
||||||
}
|
}
|
||||||
|
@ -56,3 +60,7 @@ 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,6 +20,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -40,6 +44,10 @@ 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
|
||||||
}
|
}
|
||||||
|
@ -60,6 +68,10 @@ 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
|
||||||
}
|
}
|
||||||
|
@ -80,6 +92,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -100,6 +116,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -119,3 +139,7 @@ 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,6 +22,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -42,6 +46,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -61,3 +69,31 @@ 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,8 +1,7 @@
|
||||||
package goap
|
package goap
|
||||||
|
|
||||||
type OstatusAtomUriData struct {
|
type OstatusAtomUriData struct {
|
||||||
Next BaseApChain
|
FullValueType[string]
|
||||||
Uri ValueValue[string]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (atomurivalue *OstatusAtomUriData) GetSelfOrBase() (BaseApChain, bool) {
|
func (atomurivalue *OstatusAtomUriData) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
|
@ -10,43 +9,23 @@ func (atomurivalue *OstatusAtomUriData) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (atomurivalue *OstatusAtomUriData) MarshalToMap() map[string]any {
|
func (atomurivalue *OstatusAtomUriData) MarshalToMap() map[string]any {
|
||||||
return appendWithKey(
|
return atomurivalue.MarshalToMapWithName(KEY_OSTATUS_ATOMURI)
|
||||||
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) {
|
||||||
rawData1, ok := raw[KEY_OSTATUS_ATOMURI]
|
v, err := ParseValueTypeWithName[string](raw, next, 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
|
||||||
}
|
}
|
||||||
delete(raw, KEY_OSTATUS_ATOMURI)
|
return &OstatusAtomUriData{*v}, nil
|
||||||
return &OstatusAtomUriData{
|
}
|
||||||
Next: next,
|
|
||||||
Uri: *tmp,
|
func AppendOstatusAtomUriData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
||||||
}, nil
|
return &OstatusAtomUriData{FullValueType[string]{base, data}}
|
||||||
}
|
}
|
||||||
|
|
||||||
type OstatusConversationData struct {
|
type OstatusConversationData struct {
|
||||||
Next BaseApChain
|
FullValueType[string]
|
||||||
Uri ValueValue[string]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (atomurivalue *OstatusConversationData) GetSelfOrBase() (BaseApChain, bool) {
|
func (atomurivalue *OstatusConversationData) GetSelfOrBase() (BaseApChain, bool) {
|
||||||
|
@ -54,36 +33,41 @@ func (atomurivalue *OstatusConversationData) GetSelfOrBase() (BaseApChain, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (atomurivalue *OstatusConversationData) MarshalToMap() map[string]any {
|
func (atomurivalue *OstatusConversationData) MarshalToMap() map[string]any {
|
||||||
return appendWithKey(
|
return atomurivalue.MarshalToMapWithName(KEY_OSTATUS_CONVERSATION)
|
||||||
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) {
|
||||||
rawData1, ok := raw[KEY_OSTATUS_CONVERSATION]
|
v, err := ParseValueTypeWithName[string](raw, next, 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
|
||||||
}
|
}
|
||||||
delete(raw, KEY_OSTATUS_CONVERSATION)
|
return &OstatusConversationData{*v}, nil
|
||||||
return &OstatusConversationData{
|
}
|
||||||
Next: next,
|
|
||||||
Uri: *tmp,
|
func AppendOstatusConversationData(base BaseApChain, data ValueValue[string]) BaseApChain {
|
||||||
}, nil
|
return &OstatusConversationData{FullValueType[string]{base, data}}
|
||||||
|
}
|
||||||
|
|
||||||
|
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,3 +19,7 @@ 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,6 +29,10 @@ 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
|
||||||
|
@ -56,3 +60,7 @@ 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,3 +19,7 @@ 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,7 +20,12 @@ 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
|
||||||
|
@ -77,6 +82,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -96,3 +105,7 @@ 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,6 +20,10 @@ 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]
|
||||||
}
|
}
|
||||||
|
@ -39,3 +43,7 @@ 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,6 +1,7 @@
|
||||||
package goap
|
package goap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
|
@ -38,9 +39,16 @@ var allInternalParsersExceptBase []UnmarshalFunc = []UnmarshalFunc{
|
||||||
ParseASToData,
|
ParseASToData,
|
||||||
ParseASUrlData,
|
ParseASUrlData,
|
||||||
ParseASUpdatedData,
|
ParseASUpdatedData,
|
||||||
|
ParseASFirstData,
|
||||||
|
ParseASNextData,
|
||||||
|
ParseASItemsData,
|
||||||
|
ParseASPartOfData,
|
||||||
|
ParseASInReplyToData,
|
||||||
|
ParseASQuoteUrlData,
|
||||||
|
|
||||||
ParseOstatusAtomUriData,
|
ParseOstatusAtomUriData,
|
||||||
ParseOstatusConversationData,
|
ParseOstatusConversationData,
|
||||||
|
ParseOstatusInReplyToAtomUriData,
|
||||||
|
|
||||||
ParseW3InboxData,
|
ParseW3InboxData,
|
||||||
|
|
||||||
|
@ -62,8 +70,11 @@ var allInternalParsersExceptBase []UnmarshalFunc = []UnmarshalFunc{
|
||||||
|
|
||||||
ParseMKIsCatData,
|
ParseMKIsCatData,
|
||||||
ParseMKSummaryData,
|
ParseMKSummaryData,
|
||||||
|
ParseMKQuoteData,
|
||||||
|
|
||||||
ParseFFSpeakAsCatData,
|
ParseFFSpeakAsCatData,
|
||||||
|
|
||||||
|
ParseFedibirdQuoteUriData,
|
||||||
}
|
}
|
||||||
|
|
||||||
func chainParse(
|
func chainParse(
|
||||||
|
@ -129,7 +140,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
|
||||||
|
@ -140,8 +151,26 @@ 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 nil, false
|
return obj, 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,10 +2,7 @@ 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,6 +56,9 @@ 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