diff --git a/examples/raw/mk_note_create_dm.json b/examples/raw/mk_note_create_dm.json new file mode 100644 index 0000000..60cd3af --- /dev/null +++ b/examples/raw/mk_note_create_dm.json @@ -0,0 +1,71 @@ +{ + "@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://woem.men/notes/9walk87geegt0051/activity", + "actor": "https://woem.men/users/9n39zo1rfckr00q5", + "type": "Create", + "published": "2024-07-29T13:36:29.068Z", + "object": { + "id": "https://woem.men/notes/9walk87geegt0051", + "type": "Note", + "attributedTo": "https://woem.men/users/9n39zo1rfckr00q5", + "content": "
@melody@transgirl.cafe @dibona_tuladan@activitypub.academy dm test
", + "published": "2024-07-29T13:36:29.068Z", + "to": [ + "https://transgirl.cafe/users/9ujjey44qdrt01g2", + "https://activitypub.academy/users/dibona_tuladan" + ], + "cc": [], + "inReplyTo": null, + "attachment": [], + "sensitive": false, + "tag": [ + { + "type": "Mention", + "href": "https://transgirl.cafe/users/9ujjey44qdrt01g2", + "name": "@melody@transgirl.cafe" + }, + { + "type": "Mention", + "href": "https://activitypub.academy/users/dibona_tuladan", + "name": "@dibona_tuladan@activitypub.academy" + } + ] + }, + "to": [ + "https://transgirl.cafe/users/9ujjey44qdrt01g2", + "https://activitypub.academy/users/dibona_tuladan" + ], + "cc": [] +} diff --git a/examples/raw/mk_note_create_follower_only_with_ping.json b/examples/raw/mk_note_create_follower_only_with_ping.json new file mode 100644 index 0000000..83a2caf --- /dev/null +++ b/examples/raw/mk_note_create_follower_only_with_ping.json @@ -0,0 +1,60 @@ +{ + "@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://woem.men/notes/9wallcddeegt0052/activity", + "actor": "https://woem.men/users/9n39zo1rfckr00q5", + "type": "Create", + "published": "2024-07-29T13:37:21.121Z", + "object": { + "id": "https://woem.men/notes/9wallcddeegt0052", + "type": "Note", + "attributedTo": "https://woem.men/users/9n39zo1rfckr00q5", + "content": "@dibona_tuladan@activitypub.academy test message with ping
", + "published": "2024-07-29T13:37:21.121Z", + "to": ["https://woem.men/users/9n39zo1rfckr00q5/followers"], + "cc": ["https://activitypub.academy/users/dibona_tuladan"], + "inReplyTo": null, + "attachment": [], + "sensitive": false, + "tag": [ + { + "type": "Mention", + "href": "https://activitypub.academy/users/dibona_tuladan", + "name": "@dibona_tuladan@activitypub.academy" + } + ] + }, + "to": ["https://woem.men/users/9n39zo1rfckr00q5/followers"], + "cc": ["https://activitypub.academy/users/dibona_tuladan"] +} diff --git a/nsActivitystreams.go b/nsActivitystreams.go index ad28da2..231809e 100644 --- a/nsActivitystreams.go +++ b/nsActivitystreams.go @@ -7,35 +7,27 @@ import ( ) type ActorData struct { - Next BaseApChain - Actor string + IdType } func (actor *ActorData) GetSelfOrBase() (BaseApChain, bool) { - return actor.Next, true + return actor.IdType.GetSelfOrBase() } func (actor *ActorData) MarshalToMap() map[string]any { - prev := actor.Next.MarshalToMap() - prev[KEY_ACTIVITYSTREAMS_ACTOR] = strToId(actor.Actor) - return prev + return actor.IdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_ACTOR) } type ObjectData struct { - Next BaseApChain - ObjectUrl string + IdType } func (object *ObjectData) GetSelfOrBase() (BaseApChain, bool) { - return object.Next, true + return object.IdType.Next, true } func (object *ObjectData) MarshalToMap() map[string]any { - return appendWithKey( - object.Next.MarshalToMap(), - KEY_ACTIVITYSTREAMS_OBJECT, - strToId(object.ObjectUrl), - ) + return object.IdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_OBJECT) } type CCData struct {