asns

package module
v0.0.0-...-d312e39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 13 Imported by: 2

README

go-asns

Package act provides an implementation of the ActivityPub and ActivityStreams protocols, as they are used on the Fediverse, for the Go programming language.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/codeberg.org/reiver/go-asns

GoDoc

Import

To import package act use import code like the follownig:

import "codeberg.org/reiver/go-asns"

Installation

To install package act do the following:

GOPROXY=direct go get codeberg.org/reiver/go-asns

Author

Package act was written by Charles Iliya Krempeaux

Documentation

Index

Examples

Constants

View Source
const (
	TypeAccept          = "Accept"
	TypeAdd             = "Add"
	TypeAnnounce        = "Announce"
	TypeArrive          = "Arrive"
	TypeBlock           = "Block"
	TypeCreate          = "Create"
	TypeDelete          = "Delete"
	TypeDislike         = "Dislike"
	TypeFlag            = "Flag"
	TypeFollow          = "Follow"
	TypeIgnore          = "Ignore"
	TypeInvite          = "Invite"
	TypeJoin            = "Join"
	TypeLeave           = "Leave"
	TypeLike            = "Like"
	TypeListen          = "Listen"
	TypeMove            = "Move"
	TypeOffer           = "Offer"
	TypeQuestion        = "Question"
	TypeReject          = "Reject"
	TypeRead            = "Read"
	TypeRemove          = "Remove"
	TypeTentativeReject = "TentativeReject"
	TypeTentativeAccept = "TentativeAccept"
	TypeTravel          = "Travel"
	TypeUndo            = "Undo"
	TypeUpdate          = "Update"
	TypeView            = "View"
)
View Source
const (
	TypeApplication  = "Application"
	TypeFeed         = "Feed"
	TypeGroup        = "Group"
	TypeOrganization = "Organization"
	TypePerson       = "Person"
	TypeService      = "Service"
)
View Source
const (
	TypeArticle      = "Article"
	TypeAudio        = "Audio"
	TypeDocument     = "Document"
	TypeEvent        = "Event"
	TypeImage        = "Image"
	TypeNote         = "Note"
	TypePage         = "Page"
	TypePlace        = "Place"
	TypeProfile      = "Profile"
	TypeRelationship = "Relationship"
	TypeTombstone    = "Tombstone"
	TypeVideo        = "Video"
)
View Source
const ContentType string = "application/activity+json"
View Source
const (
	TypeActivity = "Activity"
)
View Source
const (
	TypeActor = "Actor"
)
View Source
const (
	TypeLink = "Link"
)
View Source
const (
	TypeMention = "Mention"
)
View Source
const (
	TypeObject = "Object"
)

Variables

This section is empty.

Functions

func Marshal

func Marshal(values ...any) ([]byte, error)

Marshal returns the merged JSON-LD of the values passed to it.

Marshal is just a wrapper around jsonld.Marshal.

func ServeActivity

func ServeActivity(responseWriter http.ResponseWriter, request *http.Request, activity []byte)

ServeActivity helps create an http.Handler that serves "application/activity+json".

For example:

func ServeHTTP(responseWriter http.ResponseWriter, request *http.Request) {

	// ...

	asns.ServeActivity(responseWriter, request, data)

	// ...

}

Types

type Actor

type Actor struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	EndPoints opt.Optional[string] `json:"endpoints,omitempty"`
	Following opt.Optional[string] `json:"following,omitempty"`
	Followers opt.Optional[string] `json:"followers,omitempty"`

	// inbox
	//
	// A reference to an ActivityStreams (1) OrderedCollection (2) comprised of all the messages received by the actor; see 5.2 Inbox (3).
	//
	// (1) https://www.w3.org/TR/activitystreams-core/
	//
	// (2) https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollection
	//
	// (3) https://www.w3.org/TR/activitypub/#inbox
	Inbox opt.Optional[string] `json:"inbox,omitempty"`

	Liked                      opt.Optional[string] `json:"liked,omitempty"`
	Shares                     opt.Optional[string] `json:"shares,omitempty"`
	Likes                      opt.Optional[string] `json:"likes,omitempty"`
	OauthAuthorizationEndPoint opt.Optional[string] `json:"oauthAuthorizationEndpoint,omitempty"`
	OauthTokenEndPoint         opt.Optional[string] `json:"oauthTokenEndpoint,omitempty"`

	// outbox
	//
	// An ActivityStreams (1) OrderedCollection (2) comprised of all the messages produced by the actor; see 5.1 Outbox (3).
	//
	// (1) https://www.w3.org/TR/activitystreams-core/
	//
	// (2) https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollection
	//
	// (3) https://www.w3.org/TR/activitypub/#outbox
	Outbox opt.Optional[string] `json:"outbox,omitempty"`

	// preferredUsername
	//
	// A short username which may be used to refer to the actor, with no uniqueness guarantees.
	PreferredUserName opt.Optional[string] `json:"preferredUsername,omitempty"`

	ProvideClientKey opt.Optional[string] `json:"provideClientKey,omitempty"`
	ProxyURL         opt.Optional[string] `json:"proxyUrl,omitempty"`

	// sharedInbox
	//
	// An optional endpoint used for wide delivery of publicly addressed activities and activities sent to followers. (1)
	// sharedInbox endpoints SHOULD also be publicly readable OrderedCollection objects containing objects addressed to the Public (2) special collection. Reading from the sharedInbox endpoint MUST NOT present objects which are not addressed to the Public endpoint.
	//
	// (1) https://www.w3.org/TR/activitypub/#shared-inbox-delivery
	//
	// (2) https://www.w3.org/TR/activitypub/#public-addressing
	SharedInbox opt.Optional[string] `json:"sharedInbox,omitempty"`

	SignClientKey opt.Optional[string] `json:"signClientKey,omitempty"`
	Source        opt.Optional[string] `json:"source,omitempty"`
	Streams       opt.Optional[string] `json:"streams,omitempty"`
	UploadMedia   opt.Optional[string] `json:"uploadMedia,omitempty"`
}

Actor represents the ActivityPub actor object name-space used in a JSON-LD document.

Reference: https://www.w3.org/TR/activitypub/#actor-objects

Example usage:

import (
	"codeberg.org/reiver/go-asns"
	"github.com/reiver/go-jsonld"
)

// ...

var actor asns.Actor

// ...

bytes, err := jsonld.Marshal(actor)

More likely you would mix this with other JSON-LD name-spaces, with code similar to the following:

import (
	"codeberg.org/reiver/go-asns"
	"github.com/reiver/go-tootns"
	"github.com/reiver/go-jsonld"
)

// ...

var actor asns.Actor
var toot tootns.Toot

// ...

bytes, err := jsonld.Marshal(actor, toot)

type Announce

type Announce struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	Actor       jsonld.Strings       `json:"actor,omitempty"`
	AlsoKnownAs []string             `json:"alsoKnownAs,omitempty"`
	Attachment  []Attachment         `json:"attachment,omitempty"`
	Content     opt.Optional[string] `json:"content,omitempty"`
	ID          opt.Optional[string] `json:"id,omitempty"`
	Image       Image                `json:"image,omitempty"`
	Icon        Icon                 `json:"icon,omitempty"`
	MediaType   opt.Optional[string] `json:"mediaType,omitempty"`
	MovedTo     opt.Optional[string] `json:"movedTo,omitempty"`
	Name        opt.Optional[string] `json:"name,omitempty"`
	Object      opt.Optional[string] `json:"object,omitempty"`
	Published   opt.Optional[string] `json:"published,omitempty"`
	Summary     opt.Optional[string] `json:"summary,omitempty"`
	Tag         []HashTag            `json:"tag,omitempty"`
	Target      opt.Optional[string] `json:"target,omitempty"`
	To          []string             `json:"to,omitempty"`
	Type        json.Const[string]   `json:"type" json.value:"Announce"`
	URL         opt.Optional[string] `json:"url,omitempty"`
}
Example
var announcement = asns.Announce{
	ID:        opt.Something("https://mastodon.social/users/reiver/statuses/113962917187191012/activity"),
	Actor:     jsonld.SomeString("acct:reiver@mastodon.social"),
	Published: opt.Something("2025-02-07T14:56:43Z"),
	To:        []string{"https://www.w3.org/ns/activitystreams#Public"},
	Object:    opt.Something("https://example.com/note/0xf1938e3a1a6f4ac790fdf66d1b167858"),
}

bytes, err := jsonld.Marshal(announcement)
if nil != err {
	fmt.Printf("ERROR: %s", err)
	return
}

fmt.Printf("%s", bytes)

type AnyObject

type AnyObject struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	Attachment   []Attachment         `json:"attachment,omitempty"`
	AttributedTo Strings              `json:"attributedTo,omitempty"`
	Audiene      Strings              `json:"audience,omitempty"`
	CC           Strings              `json:"cc,omitempty"`
	Content      opt.Optional[string] `json:"content,omitempty"`
	Duration     opt.Optional[string] `json:"duration,omitempty"`
	EndTime      opt.Optional[string] `json:"endTime,omitempty"`
	Icon         Icon                 `json:"icon,omitempty"`
	ID           opt.Optional[string] `json:"id,omitempty"`
	Image        Image                `json:"image,omitempty"`
	InReplyTo    Strings              `json:"inReplyTo,omitempty"`
	Location     Location             `json:"location,omitempty"`
	MediaType    opt.Optional[string] `json:"mediaType,omitempty"`
	Name         opt.Optional[string] `json:"name,omitempty"`
	Published    opt.Optional[string] `json:"published,omitempty"`
	StartTime    opt.Optional[string] `json:"startTime,omitempty"`
	Summary      opt.Optional[string] `json:"summary,omitempty"`
	Tag          []HashTag            `json:"tag,omitempty"`
	To           Strings              `json:"to,omitempty"`
	Type         Strings              `json:"type,omitempty"`
	Updated      opt.Optional[string] `json:"updated,omitempty"`
	URL          opt.Optional[string] `json:"url,omitempty"`
}

type Article

type Article struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	AlsoKnownAs  Strings              `json:"alsoKnownAs,omitempty"`
	Attachment   []Attachment         `json:"attachment,omitempty"`
	AttributedTo Strings              `json:"attributedTo,omitempty"`
	Audiene      Strings              `json:"audience,omitempty"`
	CC           Strings              `json:"cc,omitempty"`
	Content      opt.Optional[string] `json:"content,omitempty"`
	Duration     opt.Optional[string] `json:"duration,omitempty"`
	EndTime      opt.Optional[string] `json:"endTime,omitempty"`
	Icon         Icon                 `json:"icon,omitempty"`
	ID           opt.Optional[string] `json:"id,omitempty"`
	Image        Image                `json:"image,omitempty"`
	InReplyTo    Strings              `json:"inReplyTo,omitempty"`
	MediaType    opt.Optional[string] `json:"mediaType,omitempty"`
	MovedTo      opt.Optional[string] `json:"movedTo,omitempty"`
	Name         opt.Optional[string] `json:"name,omitempty"`
	Published    opt.Optional[string] `json:"published,omitempty"`
	StartTime    opt.Optional[string] `json:"startTime,omitempty"`
	Summary      opt.Optional[string] `json:"summary,omitempty"`
	Tag          []HashTag            `json:"tag,omitempty"`
	To           Strings              `json:"to,omitempty"`
	Type         json.Const[string]   `json:"type" json.value:"Article"`
	Updated      opt.Optional[string] `json:"updated,omitempty"`
	URL          opt.Optional[string] `json:"url,omitempty"`
}

Article represents an ActivityPub / ActivityStream Object type "Article".

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-article

Article is similar to Object except its `Type` field is hard-coded to "Article".

type Attachment

type Attachment any

type Audience

type Audience struct {
	Name opt.Optional[string] `json:"name,omitempty"`
	Type opt.Optional[string] `json:"type,omitempty"`
	URL  opt.Optional[string] `json:"url,omitempty"`
}

type Generator

type Generator struct {
	Name opt.Optional[string] `json:"name,omitempty"`
	Type opt.Optional[string] `json:"type,omitempty"`
	URL  opt.Optional[string] `json:"url,omitempty"`
}

type HashTag

type HashTag struct {
	HRef opt.Optional[string] `json:"href,omitempty"`
	Name opt.Optional[string] `json:"name,omitempty"`
	Type json.Const[string]   `json:"type,omitempty" json.value:"Hashtag"`
}

type Icon

type Icon = Image

type Image

type Image struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	Audiences []Audience           `json:"audience,omitempty"`
	Generator Generator            `json:"generator,omitempty"`
	Height    opt.Optional[uint64] `json:"height,omitempty"`
	MediaType opt.Optional[string] `json:"mediaType,omitempty"`
	Location  Location             `json:"location,omitempty"`
	Name      opt.Optional[string] `json:"name,omitempty"`
	Published opt.Optional[string] `json:"published,omitempty"`
	Type      json.Const[string]   `json:"type" json.value:"Image"`
	Updated   opt.Optional[string] `json:"updated,omitempty"`
	URL       opt.Optional[string] `json:"url,omitempty"`
	Width     opt.Optional[uint64] `json:"width,omitempty"`
}

func (Image) IsEmpty

func (receiver Image) IsEmpty() bool

type Location

type Location struct {
	Altitude  opt.Optional[string] `json:"altitude,omitempty,bare"`
	Latitude  opt.Optional[string] `json:"latitude,omitempty,bare"`
	Longitude opt.Optional[string] `json:"longitude,omitempty,bare"`
	Name      opt.Optional[string] `json:"name,omitempty"`
	Type      opt.Optional[string] `json:"type,omitempty"`
	Units     opt.Optional[string] `json:"units,omitempty"`
	URL       opt.Optional[string] `json:"url,omitempty"`
}

type Note

type Note struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	AlsoKnownAs  Strings              `json:"alsoKnownAs,omitempty"`
	Attachment   []Attachment         `json:"attachment,omitempty"`
	AttributedTo Strings              `json:"attributedTo,omitempty"`
	Audiene      Strings              `json:"audience,omitempty"`
	CC           Strings              `json:"cc,omitempty"`
	Content      opt.Optional[string] `json:"content,omitempty"`
	Duration     opt.Optional[string] `json:"duration,omitempty"`
	EndTime      opt.Optional[string] `json:"endTime,omitempty"`
	Icon         Icon                 `json:"icon,omitempty"`
	ID           opt.Optional[string] `json:"id,omitempty"`
	Image        Image                `json:"image,omitempty"`
	InReplyTo    Strings              `json:"inReplyTo,omitempty"`
	MediaType    opt.Optional[string] `json:"mediaType,omitempty"`
	MovedTo      opt.Optional[string] `json:"movedTo,omitempty"`
	Name         opt.Optional[string] `json:"name,omitempty"`
	Published    opt.Optional[string] `json:"published,omitempty"`
	StartTime    opt.Optional[string] `json:"startTime,omitempty"`
	Summary      opt.Optional[string] `json:"summary,omitempty"`
	Tag          []HashTag            `json:"tag,omitempty"`
	To           Strings              `json:"to,omitempty"`
	Type         json.Const[string]   `json:"type" json.value:"Note"`
	Updated      opt.Optional[string] `json:"updated,omitempty"`
	URL          opt.Optional[string] `json:"url,omitempty"`
}

Note represents an ActivityPub / ActivityStream Object type "Note".

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-note

Note is similar to Object except its `Type` field is hard-coded to "Note".

type Object

type Object struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	AlsoKnownAs  Strings              `json:"alsoKnownAs,omitempty"`
	Attachment   []Attachment         `json:"attachment,omitempty"`
	AttributedTo Strings              `json:"attributedTo,omitempty"`
	Audiene      Strings              `json:"audience,omitempty"`
	CC           Strings              `json:"cc,omitempty"`
	Content      opt.Optional[string] `json:"content,omitempty"`
	Duration     opt.Optional[string] `json:"duration,omitempty"`
	EndTime      opt.Optional[string] `json:"endTime,omitempty"`
	Icon         Icon                 `json:"icon,omitempty"`
	ID           opt.Optional[string] `json:"id,omitempty"`
	Image        Image                `json:"image,omitempty"`
	InReplyTo    Strings              `json:"inReplyTo,omitempty"`
	MediaType    opt.Optional[string] `json:"mediaType,omitempty"`
	MovedTo      opt.Optional[string] `json:"movedTo,omitempty"`
	Name         opt.Optional[string] `json:"name,omitempty"`
	Published    opt.Optional[string] `json:"published,omitempty"`
	StartTime    opt.Optional[string] `json:"startTime,omitempty"`
	Summary      opt.Optional[string] `json:"summary,omitempty"`
	Tag          []HashTag            `json:"tag,omitempty"`
	To           Strings              `json:"to,omitempty"`
	Type         Strings              `json:"type,omitempty"`
	Updated      opt.Optional[string] `json:"updated,omitempty"`
	URL          opt.Optional[string] `json:"url,omitempty"`
}

Object represents the ActivityStreams object name-space used in a JSON-LD document.

Reference: https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object

Example usage:

import (
	"codeberg.org/reiver/go-asns"
	"github.com/reiver/go-jsonld"
)

// ...

var object asns.Object

// ...

bytes, err := jsonld.Marshal(object)

More likely you would mix this with other JSON-LD name-spaces, with code similar to the following:

import (
	"codeberg.org/reiver/go-asns"
	"github.com/reiver/go-tootns"
	"github.com/reiver/go-jsonld"
)

// ...

var actor asns.Actor
var object asns.Object
var toot tootns.Toot

// ...

bytes, err := jsonld.Marshal(actor, object, toot)

type OrderedCollection

type OrderedCollection struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	Current    opt.Optional[string] `json:"current,omitempty"`                   // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-current
	First      opt.Optional[string] `json:"first,omitempty"`                     // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-first
	Icon       Icon                 `json:"icon,omitempty"`                      // https://www.w3.org/ns/activitystreams#icon
	ID         opt.Optional[string] `json:"id,omitempty"`                        // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-id
	Image      Image                `json:"image,omitempty"`                     // https://www.w3.org/ns/activitystreams#image
	Items      []any                `json:"items,omitempty"`                     // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-items
	Last       opt.Optional[string] `json:"last,omitempty"`                      // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-last
	Name       opt.Optional[string] `json:"name,omitempty"`                      // https://www.w3.org/ns/activitystreams#name
	Summary    opt.Optional[string] `json:"summary,omitempty"`                   // https://www.w3.org/ns/activitystreams#summary
	TotalItems opt.Optional[uint64] `json:"totalItems,omitempty"`                // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-totalitems
	Type       json.Const[string]   `json:"type" json.value:"OrderedCollection"` // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-type
}

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollection

type OrderedCollectionPage

type OrderedCollectionPage struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	Icon         Icon                 `json:"icon,omitempty"`                          // https://www.w3.org/ns/activitystreams#icon
	ID           opt.Optional[string] `json:"id,omitempty"`                            // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-id
	Image        Image                `json:"image,omitempty"`                         // https://www.w3.org/ns/activitystreams#image
	Name         opt.Optional[string] `json:"name,omitempty"`                          // https://www.w3.org/ns/activitystreams#name
	Next         opt.Optional[string] `json:"next,omitempty"`                          // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-next
	OrderedItems []any                `json:"orderedItems"`                            // https://www.w3.org/TR/activitystreams-core/#h-paging
	PartOf       opt.Optional[string] `json:"partOf,omitempty"`                        // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-partof
	Prev         opt.Optional[string] `json:"prev,omitempty"`                          // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-prev
	StartIndex   opt.Optional[uint64] `json:"startIndex,omitempty"`                    // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-startindex
	Summary      opt.Optional[string] `json:"summary,omitempty"`                       // https://www.w3.org/ns/activitystreams#summary
	Type         json.Const[string]   `json:"type" json.value:"OrderedCollectionPage"` // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-type
}

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollectionpage

type Outbox

type Outbox = OrderedCollection

type Page

type Page struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	AlsoKnownAs  Strings              `json:"alsoKnownAs,omitempty"`
	Attachment   []Attachment         `json:"attachment,omitempty"`
	AttributedTo Strings              `json:"attributedTo,omitempty"`
	Audiene      Strings              `json:"audience,omitempty"`
	CC           Strings              `json:"cc,omitempty"`
	Content      opt.Optional[string] `json:"content,omitempty"`
	Duration     opt.Optional[string] `json:"duration,omitempty"`
	EndTime      opt.Optional[string] `json:"endTime,omitempty"`
	Icon         Icon                 `json:"icon,omitempty"`
	ID           opt.Optional[string] `json:"id,omitempty"`
	Image        Image                `json:"image,omitempty"`
	InReplyTo    Strings              `json:"inReplyTo,omitempty"`
	MediaType    opt.Optional[string] `json:"mediaType,omitempty"`
	MovedTo      opt.Optional[string] `json:"movedTo,omitempty"`
	Name         opt.Optional[string] `json:"name,omitempty"`
	Published    opt.Optional[string] `json:"published,omitempty"`
	StartTime    opt.Optional[string] `json:"startTime,omitempty"`
	Summary      opt.Optional[string] `json:"summary,omitempty"`
	Tag          []HashTag            `json:"tag,omitempty"`
	To           Strings              `json:"to,omitempty"`
	Type         json.Const[string]   `json:"type" json.value:"Page"`
	Updated      opt.Optional[string] `json:"updated,omitempty"`
	URL          opt.Optional[string] `json:"url,omitempty"`
}

Page represents an ActivityPub / ActivityStream Object type "Page".

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-page

Page is similar to Object except its `Type` field is hard-coded to "Page".

type Person

type Person struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	AlsoKnownAs []string             `json:"alsoKnownAs,omitempty"`
	Attachments []Attachment         `json:"attachment,omitempty"` // https://www.w3.org/ns/activitystreams#attachment
	ID          opt.Optional[string] `json:"id,omitempty"`
	Image       Image                `json:"image,omitempty"`     // https://www.w3.org/ns/activitystreams#image
	Icon        Icon                 `json:"icon,omitempty"`      // https://www.w3.org/ns/activitystreams#icon
	MediaType   opt.Optional[string] `json:"mediaType,omitempty"` // https://www.w3.org/ns/activitystreams#mediaType
	MovedTo     opt.Optional[string] `json:"movedTo,omitempty"`
	Name        opt.Optional[string] `json:"name,omitempty"`    // https://www.w3.org/ns/activitystreams#name
	Summary     opt.Optional[string] `json:"summary,omitempty"` // https://www.w3.org/ns/activitystreams#summary
	Tag         []HashTag            `json:"tag,omitempty"`     // https://www.w3.org/ns/activitystreams#tag
	Type        json.Const[string]   `json:"type" json.value:"Person"`
	URL         opt.Optional[string] `json:"url,omitempty"` // https://www.w3.org/ns/activitystreams#url
}

https://www.w3.org/ns/activitystreams#Person

func (Person) IsEmpty

func (receiver Person) IsEmpty() bool

type Strings

type Strings struct {
	// contains filtered or unexported fields
}

Strings represents an ActivityStreams "type" field that is zero, one, or many strings.

And, the way it marshals to JSON / JSON-LD is different depending on whether it is zero, one, or many strings.

If its value is NoStrings then its JSON / JSON-LD representation is the JSON / JSON-LD: null.

If its value is SomeString then its JSON / JSON-LD representation is the JSON / JSON-LD: string.

If its value is SomeStrings then its JSON / JSON-LD representation is the JSON / JSON-LD: array (of string).

func NoStrings

func NoStrings() Strings

NoStrings returns a Strings with no strings in it.

This is more-or-less similar to the concept of "none" and "nothing" with optional-types. Note that "optional-types" are also known as 'option-types' and 'maybe-types'.

func SomeString

func SomeString(value string) Strings

SomeString returns a Strings with one string in it.

This is more-or-less similar to the concept of "some" and "something" with optional-types. Note that "optional-types" are also known as 'option-types' and 'maybe-types'.

func SomeStrings

func SomeStrings(values ...string) Strings

SomeStrings returns a Strings with many strings in it.

func (Strings) MarshalJSON

func (receiver Strings) MarshalJSON() ([]byte, error)

MarshalJSON makes Strings fit the json.Marshaler interface.

func (Strings) Strings

func (receiver Strings) Strings() []string

Strings returns the strings within a Strings.

func (*Strings) UnmarshalJSON

func (receiver *Strings) UnmarshalJSON(bytes []byte) error

UnmarshalJSON makes Strings fit the json.Unmarshaler interface.

type Thing

type Thing struct {
	NameSpace jsonld.NameSpace `jsonld:"https://www.w3.org/ns/activitystreams"`
	Prefix    jsonld.Prefix    `jsonld:"as"`

	Type Strings `json:"type,omitempty"`
}

Thing represents something with a "type" field.

It is something more basic than Object.

Directories

Path Synopsis
internal
ns
as

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL