Refactored elements that were of CollectionInterface type to Item type so we can pass IRIs to them
This commit is contained in:
parent
bb530d67be
commit
602911a7db
|
@ -85,13 +85,13 @@ type Activity struct {
|
|||
Name NaturalLanguageValue `jsonld:"name,omitempty,collapsible"`
|
||||
// Identifies a resource attached or related to an object that potentially requires special handling.
|
||||
// The intent is to provide a model that is at least semantically similar to attachments in email.
|
||||
Attachment ObjectOrLink `jsonld:"attachment,omitempty"`
|
||||
Attachment Item `jsonld:"attachment,omitempty"`
|
||||
// Identifies one or more entities to which this object is attributed. The attributed entities might not be Actors.
|
||||
// For instance, an object might be attributed to the completion of another activity.
|
||||
AttributedTo ObjectOrLink `jsonld:"attributedTo,omitempty"`
|
||||
AttributedTo Item `jsonld:"attributedTo,omitempty"`
|
||||
// Identifies one or more entities that represent the total population of entities
|
||||
// for which the object can considered to be relevant.
|
||||
Audience ObjectOrLink `jsonld:"audience,omitempty"`
|
||||
Audience Item `jsonld:"audience,omitempty"`
|
||||
// The content or textual representation of the Activity Pub Object encoded as a JSON string.
|
||||
// By default, the value of content is HTML.
|
||||
// The mediaType property can be used in the object to indicate a different content type.
|
||||
|
@ -101,13 +101,13 @@ type Activity struct {
|
|||
// The notion of "context" used is intentionally vague.
|
||||
// The intended function is to serve as a means of grouping objects and activities that share a
|
||||
// common originating context or purpose. An example could be all activities relating to a common project or event.
|
||||
Context ObjectOrLink `jsonld:"context,omitempty"`
|
||||
Context Item `jsonld:"context,omitempty"`
|
||||
// The date and time describing the actual or expected ending time of the object.
|
||||
// When used with an Activity object, for instance, the endTime property specifies the moment
|
||||
// the activity concluded or is expected to conclude.
|
||||
EndTime time.Time `jsonld:"endTime,omitempty"`
|
||||
// Identifies the entity (e.g. an application) that generated the object.
|
||||
Generator ObjectOrLink `jsonld:"generator,omitempty"`
|
||||
Generator Item `jsonld:"generator,omitempty"`
|
||||
// Indicates an entity that describes an icon for this object.
|
||||
// The image should have an aspect ratio of one (horizontal) to one (vertical)
|
||||
// and should be suitable for presentation at a small size.
|
||||
|
@ -116,15 +116,15 @@ type Activity struct {
|
|||
// Unlike the icon property, there are no aspect ratio or display size limitations assumed.
|
||||
Image ImageOrLink `jsonld:"image,omitempty"`
|
||||
// Indicates one or more entities for which this object is considered a response.
|
||||
InReplyTo ObjectOrLink `jsonld:"inReplyTo,omitempty"`
|
||||
InReplyTo Item `jsonld:"inReplyTo,omitempty"`
|
||||
// Indicates one or more physical or logical locations associated with the object.
|
||||
Location ObjectOrLink `jsonld:"location,omitempty"`
|
||||
Location Item `jsonld:"location,omitempty"`
|
||||
// Identifies an entity that provides a preview of this object.
|
||||
Preview ObjectOrLink `jsonld:"preview,omitempty"`
|
||||
Preview Item `jsonld:"preview,omitempty"`
|
||||
// The date and time at which the object was published
|
||||
Published time.Time `jsonld:"published,omitempty"`
|
||||
// Identifies a Collection containing objects considered to be responses to this object.
|
||||
Replies CollectionInterface `jsonld:"replies,omitempty"`
|
||||
Replies Item `jsonld:"replies,omitempty"`
|
||||
// The date and time describing the actual or expected starting time of the object.
|
||||
// When used with an Activity object, for instance, the startTime property specifies
|
||||
// the moment the activity began or is scheduled to begin.
|
||||
|
@ -135,19 +135,19 @@ type Activity struct {
|
|||
// One or more "tags" that have been associated with an objects. A tag can be any kind of Activity Pub Object.
|
||||
// The key difference between attachment and tag is that the former implies association by inclusion,
|
||||
// while the latter implies associated by reference.
|
||||
Tag ObjectOrLink `jsonld:"tag,omitempty"`
|
||||
Tag Item `jsonld:"tag,omitempty"`
|
||||
// The date and time at which the object was updated
|
||||
Updated time.Time `jsonld:"updated,omitempty"`
|
||||
// Identifies one or more links to representations of the object
|
||||
URL LinkOrURI `jsonld:"url,omitempty"`
|
||||
// Identifies an entity considered to be part of the public primary audience of an Activity Pub Object
|
||||
To ObjectsArr `jsonld:"to,omitempty"`
|
||||
To ItemCollection `jsonld:"to,omitempty"`
|
||||
// Identifies an Activity Pub Object that is part of the private primary audience of this Activity Pub Object.
|
||||
Bto ObjectsArr `jsonld:"bto,omitempty"`
|
||||
Bto ItemCollection `jsonld:"bto,omitempty"`
|
||||
// Identifies an Activity Pub Object that is part of the public secondary audience of this Activity Pub Object.
|
||||
CC ObjectsArr `jsonld:"cc,omitempty"`
|
||||
CC ItemCollection `jsonld:"cc,omitempty"`
|
||||
// Identifies one or more Objects that are part of the private secondary audience of this Activity Pub Object.
|
||||
BCC ObjectsArr `jsonld:"bcc,omitempty"`
|
||||
BCC ItemCollection `jsonld:"bcc,omitempty"`
|
||||
// When the object describes a time-bound resource, such as an audio or video, a meeting, etc,
|
||||
// the duration property indicates the object's approximate duration.
|
||||
// The value must be expressed as an xsd:duration as defined by [ xmlschema11-2],
|
||||
|
@ -155,28 +155,28 @@ type Activity struct {
|
|||
Duration time.Duration `jsonld:"duration,omitempty"`
|
||||
// Describes one or more entities that either performed or are expected to perform the activity.
|
||||
// Any single activity can have multiple actors. The actor may be specified using an indirect Link.
|
||||
Actor ObjectOrLink `jsonld:"actor,omitempty"`
|
||||
Actor Item `jsonld:"actor,omitempty"`
|
||||
// Describes the indirect object, or target, of the activity.
|
||||
// The precise meaning of the target is largely dependent on the type of action being described
|
||||
// but will often be the object of the English preposition "to".
|
||||
// For instance, in the activity "John added a movie to his wishlist",
|
||||
// the target of the activity is John's wishlist. An activity can have more than one target.
|
||||
Target ObjectOrLink `jsonld:"target,omitempty"`
|
||||
Target Item `jsonld:"target,omitempty"`
|
||||
// Describes the result of the activity. For instance, if a particular action results in the creation
|
||||
// of a new resource, the result property can be used to describe that new resource.
|
||||
Result ObjectOrLink `jsonld:"result,omitempty"`
|
||||
Result Item `jsonld:"result,omitempty"`
|
||||
// Describes an indirect object of the activity from which the activity is directed.
|
||||
// The precise meaning of the origin is the object of the English preposition "from".
|
||||
// For instance, in the activity "John moved an item to List B from List A", the origin of the activity is "List A".
|
||||
Origin ObjectOrLink `jsonld:"origin,omitempty"`
|
||||
Origin Item `jsonld:"origin,omitempty"`
|
||||
// Identifies one or more objects used (or to be used) in the completion of an Activity.
|
||||
Instrument ObjectOrLink `jsonld:"instrument,omitempty"`
|
||||
Source Source `jsonld:"source,omitempty"`
|
||||
Instrument Item `jsonld:"instrument,omitempty"`
|
||||
Source Source `jsonld:"source,omitempty"`
|
||||
// When used within an Activity, describes the direct object of the activity.
|
||||
// For instance, in the activity "John added a movie to his wishlist",
|
||||
// the object of the activity is the movie added.
|
||||
// When used within a Relationship describes the entity to which the subject is related.
|
||||
Object ObjectOrLink `jsonld:"object,omitempty"`
|
||||
Object Item `jsonld:"object,omitempty"`
|
||||
}
|
||||
|
||||
// IntransitiveActivity Instances of IntransitiveActivity are a subtype of Activity representing intransitive actions.
|
||||
|
@ -191,13 +191,13 @@ type IntransitiveActivity struct {
|
|||
Name NaturalLanguageValue `jsonld:"name,omitempty,collapsible"`
|
||||
// Identifies a resource attached or related to an object that potentially requires special handling.
|
||||
// The intent is to provide a model that is at least semantically similar to attachments in email.
|
||||
Attachment ObjectOrLink `jsonld:"attachment,omitempty"`
|
||||
Attachment Item `jsonld:"attachment,omitempty"`
|
||||
// Identifies one or more entities to which this object is attributed. The attributed entities might not be Actors.
|
||||
// For instance, an object might be attributed to the completion of another activity.
|
||||
AttributedTo ObjectOrLink `jsonld:"attributedTo,omitempty"`
|
||||
AttributedTo Item `jsonld:"attributedTo,omitempty"`
|
||||
// Identifies one or more entities that represent the total population of entities
|
||||
// for which the object can considered to be relevant.
|
||||
Audience ObjectOrLink `jsonld:"audience,omitempty"`
|
||||
Audience Item `jsonld:"audience,omitempty"`
|
||||
// The content or textual representation of the Activity Pub Object encoded as a JSON string.
|
||||
// By default, the value of content is HTML.
|
||||
// The mediaType property can be used in the object to indicate a different content type.
|
||||
|
@ -207,13 +207,13 @@ type IntransitiveActivity struct {
|
|||
// The notion of "context" used is intentionally vague.
|
||||
// The intended function is to serve as a means of grouping objects and activities that share a
|
||||
// common originating context or purpose. An example could be all activities relating to a common project or event.
|
||||
Context ObjectOrLink `jsonld:"context,omitempty"`
|
||||
Context Item `jsonld:"context,omitempty"`
|
||||
// The date and time describing the actual or expected ending time of the object.
|
||||
// When used with an Activity object, for instance, the endTime property specifies the moment
|
||||
// the activity concluded or is expected to conclude.
|
||||
EndTime time.Time `jsonld:"endTime,omitempty"`
|
||||
// Identifies the entity (e.g. an application) that generated the object.
|
||||
Generator ObjectOrLink `jsonld:"generator,omitempty"`
|
||||
Generator Item `jsonld:"generator,omitempty"`
|
||||
// Indicates an entity that describes an icon for this object.
|
||||
// The image should have an aspect ratio of one (horizontal) to one (vertical)
|
||||
// and should be suitable for presentation at a small size.
|
||||
|
@ -222,15 +222,15 @@ type IntransitiveActivity struct {
|
|||
// Unlike the icon property, there are no aspect ratio or display size limitations assumed.
|
||||
Image ImageOrLink `jsonld:"image,omitempty"`
|
||||
// Indicates one or more entities for which this object is considered a response.
|
||||
InReplyTo ObjectOrLink `jsonld:"inReplyTo,omitempty"`
|
||||
InReplyTo Item `jsonld:"inReplyTo,omitempty"`
|
||||
// Indicates one or more physical or logical locations associated with the object.
|
||||
Location ObjectOrLink `jsonld:"location,omitempty"`
|
||||
Location Item `jsonld:"location,omitempty"`
|
||||
// Identifies an entity that provides a preview of this object.
|
||||
Preview ObjectOrLink `jsonld:"preview,omitempty"`
|
||||
Preview Item `jsonld:"preview,omitempty"`
|
||||
// The date and time at which the object was published
|
||||
Published time.Time `jsonld:"published,omitempty"`
|
||||
// Identifies a Collection containing objects considered to be responses to this object.
|
||||
Replies CollectionInterface `jsonld:"replies,omitempty"`
|
||||
Replies Item `jsonld:"replies,omitempty"`
|
||||
// The date and time describing the actual or expected starting time of the object.
|
||||
// When used with an Activity object, for instance, the startTime property specifies
|
||||
// the moment the activity began or is scheduled to begin.
|
||||
|
@ -241,19 +241,19 @@ type IntransitiveActivity struct {
|
|||
// One or more "tags" that have been associated with an objects. A tag can be any kind of Activity Pub Object.
|
||||
// The key difference between attachment and tag is that the former implies association by inclusion,
|
||||
// while the latter implies associated by reference.
|
||||
Tag ObjectOrLink `jsonld:"tag,omitempty"`
|
||||
Tag Item `jsonld:"tag,omitempty"`
|
||||
// The date and time at which the object was updated
|
||||
Updated time.Time `jsonld:"updated,omitempty"`
|
||||
// Identifies one or more links to representations of the object
|
||||
URL LinkOrURI `jsonld:"url,omitempty"`
|
||||
// Identifies an entity considered to be part of the public primary audience of an Activity Pub Object
|
||||
To ObjectsArr `jsonld:"to,omitempty"`
|
||||
To ItemCollection `jsonld:"to,omitempty"`
|
||||
// Identifies an Activity Pub Object that is part of the private primary audience of this Activity Pub Object.
|
||||
Bto ObjectsArr `jsonld:"bto,omitempty"`
|
||||
Bto ItemCollection `jsonld:"bto,omitempty"`
|
||||
// Identifies an Activity Pub Object that is part of the public secondary audience of this Activity Pub Object.
|
||||
CC ObjectsArr `jsonld:"cc,omitempty"`
|
||||
CC ItemCollection `jsonld:"cc,omitempty"`
|
||||
// Identifies one or more Objects that are part of the private secondary audience of this Activity Pub Object.
|
||||
BCC ObjectsArr `jsonld:"bcc,omitempty"`
|
||||
BCC ItemCollection `jsonld:"bcc,omitempty"`
|
||||
// When the object describes a time-bound resource, such as an audio or video, a meeting, etc,
|
||||
// the duration property indicates the object's approximate duration.
|
||||
// The value must be expressed as an xsd:duration as defined by [ xmlschema11-2],
|
||||
|
@ -267,17 +267,17 @@ type IntransitiveActivity struct {
|
|||
// but will often be the object of the English preposition "to".
|
||||
// For instance, in the activity "John added a movie to his wishlist",
|
||||
// the target of the activity is John's wishlist. An activity can have more than one target.
|
||||
Target ObjectOrLink `jsonld:"target,omitempty"`
|
||||
Target Item `jsonld:"target,omitempty"`
|
||||
// Describes the result of the activity. For instance, if a particular action results in the creation
|
||||
// of a new resource, the result property can be used to describe that new resource.
|
||||
Result ObjectOrLink `jsonld:"result,omitempty"`
|
||||
Result Item `jsonld:"result,omitempty"`
|
||||
// Describes an indirect object of the activity from which the activity is directed.
|
||||
// The precise meaning of the origin is the object of the English preposition "from".
|
||||
// For instance, in the activity "John moved an item to List B from List A", the origin of the activity is "List A".
|
||||
Origin ObjectOrLink `jsonld:"origin,omitempty"`
|
||||
Origin Item `jsonld:"origin,omitempty"`
|
||||
// Identifies one or more objects used (or to be used) in the completion of an Activity.
|
||||
Instrument ObjectOrLink `jsonld:"instrument,omitempty"`
|
||||
Source Source `jsonld:"source,omitempty"`
|
||||
Instrument Item `jsonld:"instrument,omitempty"`
|
||||
Source Source `jsonld:"source,omitempty"`
|
||||
}
|
||||
|
||||
type (
|
||||
|
@ -402,13 +402,13 @@ type Question struct {
|
|||
Name NaturalLanguageValue `jsonld:"name,omitempty,collapsible"`
|
||||
// Identifies a resource attached or related to an object that potentially requires special handling.
|
||||
// The intent is to provide a model that is at least semantically similar to attachments in email.
|
||||
Attachment ObjectOrLink `jsonld:"attachment,omitempty"`
|
||||
Attachment Item `jsonld:"attachment,omitempty"`
|
||||
// Identifies one or more entities to which this object is attributed. The attributed entities might not be Actors.
|
||||
// For instance, an object might be attributed to the completion of another activity.
|
||||
AttributedTo ObjectOrLink `jsonld:"attributedTo,omitempty"`
|
||||
AttributedTo Item `jsonld:"attributedTo,omitempty"`
|
||||
// Identifies one or more entities that represent the total population of entities
|
||||
// for which the object can considered to be relevant.
|
||||
Audience ObjectOrLink `jsonld:"audience,omitempty"`
|
||||
Audience Item `jsonld:"audience,omitempty"`
|
||||
// The content or textual representation of the Activity Pub Object encoded as a JSON string.
|
||||
// By default, the value of content is HTML.
|
||||
// The mediaType property can be used in the object to indicate a different content type.
|
||||
|
@ -418,13 +418,13 @@ type Question struct {
|
|||
// The notion of "context" used is intentionally vague.
|
||||
// The intended function is to serve as a means of grouping objects and activities that share a
|
||||
// common originating context or purpose. An example could be all activities relating to a common project or event.
|
||||
Context ObjectOrLink `jsonld:"context,omitempty"`
|
||||
Context Item `jsonld:"context,omitempty"`
|
||||
// The date and time describing the actual or expected ending time of the object.
|
||||
// When used with an Activity object, for instance, the endTime property specifies the moment
|
||||
// the activity concluded or is expected to conclude.
|
||||
EndTime time.Time `jsonld:"endTime,omitempty"`
|
||||
// Identifies the entity (e.g. an application) that generated the object.
|
||||
Generator ObjectOrLink `jsonld:"generator,omitempty"`
|
||||
Generator Item `jsonld:"generator,omitempty"`
|
||||
// Indicates an entity that describes an icon for this object.
|
||||
// The image should have an aspect ratio of one (horizontal) to one (vertical)
|
||||
// and should be suitable for presentation at a small size.
|
||||
|
@ -433,15 +433,15 @@ type Question struct {
|
|||
// Unlike the icon property, there are no aspect ratio or display size limitations assumed.
|
||||
Image ImageOrLink `jsonld:"image,omitempty"`
|
||||
// Indicates one or more entities for which this object is considered a response.
|
||||
InReplyTo ObjectOrLink `jsonld:"inReplyTo,omitempty"`
|
||||
InReplyTo Item `jsonld:"inReplyTo,omitempty"`
|
||||
// Indicates one or more physical or logical locations associated with the object.
|
||||
Location ObjectOrLink `jsonld:"location,omitempty"`
|
||||
Location Item `jsonld:"location,omitempty"`
|
||||
// Identifies an entity that provides a preview of this object.
|
||||
Preview ObjectOrLink `jsonld:"preview,omitempty"`
|
||||
Preview Item `jsonld:"preview,omitempty"`
|
||||
// The date and time at which the object was published
|
||||
Published time.Time `jsonld:"published,omitempty"`
|
||||
// Identifies a Collection containing objects considered to be responses to this object.
|
||||
Replies CollectionInterface `jsonld:"replies,omitempty"`
|
||||
Replies Item `jsonld:"replies,omitempty"`
|
||||
// The date and time describing the actual or expected starting time of the object.
|
||||
// When used with an Activity object, for instance, the startTime property specifies
|
||||
// the moment the activity began or is scheduled to begin.
|
||||
|
@ -452,19 +452,19 @@ type Question struct {
|
|||
// One or more "tags" that have been associated with an objects. A tag can be any kind of Activity Pub Object.
|
||||
// The key difference between attachment and tag is that the former implies association by inclusion,
|
||||
// while the latter implies associated by reference.
|
||||
Tag ObjectOrLink `jsonld:"tag,omitempty"`
|
||||
Tag Item `jsonld:"tag,omitempty"`
|
||||
// The date and time at which the object was updated
|
||||
Updated time.Time `jsonld:"updated,omitempty"`
|
||||
// Identifies one or more links to representations of the object
|
||||
URL LinkOrURI `jsonld:"url,omitempty"`
|
||||
// Identifies an entity considered to be part of the public primary audience of an Activity Pub Object
|
||||
To ObjectsArr `jsonld:"to,omitempty"`
|
||||
To ItemCollection `jsonld:"to,omitempty"`
|
||||
// Identifies an Activity Pub Object that is part of the private primary audience of this Activity Pub Object.
|
||||
Bto ObjectsArr `jsonld:"bto,omitempty"`
|
||||
Bto ItemCollection `jsonld:"bto,omitempty"`
|
||||
// Identifies an Activity Pub Object that is part of the public secondary audience of this Activity Pub Object.
|
||||
CC ObjectsArr `jsonld:"cc,omitempty"`
|
||||
CC ItemCollection `jsonld:"cc,omitempty"`
|
||||
// Identifies one or more Objects that are part of the private secondary audience of this Activity Pub Object.
|
||||
BCC ObjectsArr `jsonld:"bcc,omitempty"`
|
||||
BCC ItemCollection `jsonld:"bcc,omitempty"`
|
||||
// When the object describes a time-bound resource, such as an audio or video, a meeting, etc,
|
||||
// the duration property indicates the object's approximate duration.
|
||||
// The value must be expressed as an xsd:duration as defined by [ xmlschema11-2],
|
||||
|
@ -478,36 +478,36 @@ type Question struct {
|
|||
// but will often be the object of the English preposition "to".
|
||||
// For instance, in the activity "John added a movie to his wishlist",
|
||||
// the target of the activity is John's wishlist. An activity can have more than one target.
|
||||
Target ObjectOrLink `jsonld:"target,omitempty"`
|
||||
Target Item `jsonld:"target,omitempty"`
|
||||
// Describes the result of the activity. For instance, if a particular action results in the creation
|
||||
// of a new resource, the result property can be used to describe that new resource.
|
||||
Result ObjectOrLink `jsonld:"result,omitempty"`
|
||||
Result Item `jsonld:"result,omitempty"`
|
||||
// Describes an indirect object of the activity from which the activity is directed.
|
||||
// The precise meaning of the origin is the object of the English preposition "from".
|
||||
// For instance, in the activity "John moved an item to List B from List A", the origin of the activity is "List A".
|
||||
Origin ObjectOrLink `jsonld:"origin,omitempty"`
|
||||
Origin Item `jsonld:"origin,omitempty"`
|
||||
// Identifies one or more objects used (or to be used) in the completion of an Activity.
|
||||
Instrument ObjectOrLink `jsonld:"instrument,omitempty"`
|
||||
Source Source `jsonld:"source,omitempty"`
|
||||
Instrument Item `jsonld:"instrument,omitempty"`
|
||||
Source Source `jsonld:"source,omitempty"`
|
||||
// Identifies an exclusive option for a Question. Use of oneOf implies that the Question
|
||||
// can have only a single answer. To indicate that a Question can have multiple answers, use anyOf.
|
||||
OneOf ObjectOrLink `jsonld:"oneOf,omitempty"`
|
||||
OneOf Item `jsonld:"oneOf,omitempty"`
|
||||
// Identifies an inclusive option for a Question. Use of anyOf implies that the Question can have multiple answers.
|
||||
// To indicate that a Question can have only one answer, use oneOf.
|
||||
AnyOf ObjectOrLink `jsonld:"anyOf,omitempty"`
|
||||
AnyOf Item `jsonld:"anyOf,omitempty"`
|
||||
// Indicates that a question has been closed, and answers are no longer accepted.
|
||||
Closed bool `jsonld:"closed,omitempty"`
|
||||
}
|
||||
|
||||
// AcceptNew initializes an Accept activity
|
||||
func AcceptNew(id ObjectID, ob ObjectOrLink) *Accept {
|
||||
func AcceptNew(id ObjectID, ob Item) *Accept {
|
||||
a := ActivityNew(id, AcceptType, ob)
|
||||
o := Accept(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// AddNew initializes an Add activity
|
||||
func AddNew(id ObjectID, ob ObjectOrLink, trgt ObjectOrLink) *Add {
|
||||
func AddNew(id ObjectID, ob Item, trgt Item) *Add {
|
||||
a := ActivityNew(id, AddType, ob)
|
||||
o := Add(*a)
|
||||
o.Target = trgt
|
||||
|
@ -515,7 +515,7 @@ func AddNew(id ObjectID, ob ObjectOrLink, trgt ObjectOrLink) *Add {
|
|||
}
|
||||
|
||||
// AnnounceNew initializes an Announce activity
|
||||
func AnnounceNew(id ObjectID, ob ObjectOrLink) *Announce {
|
||||
func AnnounceNew(id ObjectID, ob Item) *Announce {
|
||||
a := ActivityNew(id, AnnounceType, ob)
|
||||
o := Announce(*a)
|
||||
return &o
|
||||
|
@ -529,119 +529,119 @@ func ArriveNew(id ObjectID) *Arrive {
|
|||
}
|
||||
|
||||
// BlockNew initializes a Block activity
|
||||
func BlockNew(id ObjectID, ob ObjectOrLink) *Block {
|
||||
func BlockNew(id ObjectID, ob Item) *Block {
|
||||
a := ActivityNew(id, BlockType, ob)
|
||||
o := Block(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// CreateNew initializes a Create activity
|
||||
func CreateNew(id ObjectID, ob ObjectOrLink) *Create {
|
||||
func CreateNew(id ObjectID, ob Item) *Create {
|
||||
a := ActivityNew(id, CreateType, ob)
|
||||
o := Create(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// DeleteNew initializes a Delete activity
|
||||
func DeleteNew(id ObjectID, ob ObjectOrLink) *Delete {
|
||||
func DeleteNew(id ObjectID, ob Item) *Delete {
|
||||
a := ActivityNew(id, DeleteType, ob)
|
||||
o := Delete(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// DislikeNew initializes a Dislike activity
|
||||
func DislikeNew(id ObjectID, ob ObjectOrLink) *Dislike {
|
||||
func DislikeNew(id ObjectID, ob Item) *Dislike {
|
||||
a := ActivityNew(id, DislikeType, ob)
|
||||
o := Dislike(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// FlagNew initializes a Flag activity
|
||||
func FlagNew(id ObjectID, ob ObjectOrLink) *Flag {
|
||||
func FlagNew(id ObjectID, ob Item) *Flag {
|
||||
a := ActivityNew(id, FlagType, ob)
|
||||
o := Flag(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// FollowNew initializes a Follow activity
|
||||
func FollowNew(id ObjectID, ob ObjectOrLink) *Follow {
|
||||
func FollowNew(id ObjectID, ob Item) *Follow {
|
||||
a := ActivityNew(id, FollowType, ob)
|
||||
o := Follow(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// IgnoreNew initializes an Ignore activity
|
||||
func IgnoreNew(id ObjectID, ob ObjectOrLink) *Ignore {
|
||||
func IgnoreNew(id ObjectID, ob Item) *Ignore {
|
||||
a := ActivityNew(id, IgnoreType, ob)
|
||||
o := Ignore(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// InviteNew initializes an Invite activity
|
||||
func InviteNew(id ObjectID, ob ObjectOrLink) *Invite {
|
||||
func InviteNew(id ObjectID, ob Item) *Invite {
|
||||
a := ActivityNew(id, InviteType, ob)
|
||||
o := Invite(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// JoinNew initializes a Join activity
|
||||
func JoinNew(id ObjectID, ob ObjectOrLink) *Join {
|
||||
func JoinNew(id ObjectID, ob Item) *Join {
|
||||
a := ActivityNew(id, JoinType, ob)
|
||||
o := Join(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// LeaveNew initializes a Leave activity
|
||||
func LeaveNew(id ObjectID, ob ObjectOrLink) *Leave {
|
||||
func LeaveNew(id ObjectID, ob Item) *Leave {
|
||||
a := ActivityNew(id, LeaveType, ob)
|
||||
o := Leave(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// LikeNew initializes a Like activity
|
||||
func LikeNew(id ObjectID, ob ObjectOrLink) *Like {
|
||||
func LikeNew(id ObjectID, ob Item) *Like {
|
||||
a := ActivityNew(id, LikeType, ob)
|
||||
o := Like(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// ListenNew initializes a Listen activity
|
||||
func ListenNew(id ObjectID, ob ObjectOrLink) *Listen {
|
||||
func ListenNew(id ObjectID, ob Item) *Listen {
|
||||
a := ActivityNew(id, ListenType, ob)
|
||||
o := Listen(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// MoveNew initializes a Move activity
|
||||
func MoveNew(id ObjectID, ob ObjectOrLink) *Move {
|
||||
func MoveNew(id ObjectID, ob Item) *Move {
|
||||
a := ActivityNew(id, MoveType, ob)
|
||||
o := Move(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// OfferNew initializes an Offer activity
|
||||
func OfferNew(id ObjectID, ob ObjectOrLink) *Offer {
|
||||
func OfferNew(id ObjectID, ob Item) *Offer {
|
||||
a := ActivityNew(id, OfferType, ob)
|
||||
o := Offer(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// RejectNew initializes a Reject activity
|
||||
func RejectNew(id ObjectID, ob ObjectOrLink) *Reject {
|
||||
func RejectNew(id ObjectID, ob Item) *Reject {
|
||||
a := ActivityNew(id, RejectType, ob)
|
||||
o := Reject(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// ReadNew initializes a Read activity
|
||||
func ReadNew(id ObjectID, ob ObjectOrLink) *Read {
|
||||
func ReadNew(id ObjectID, ob Item) *Read {
|
||||
a := ActivityNew(id, ReadType, ob)
|
||||
o := Read(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// RemoveNew initializes a Remove activity
|
||||
func RemoveNew(id ObjectID, ob ObjectOrLink, trgt ObjectOrLink) *Remove {
|
||||
func RemoveNew(id ObjectID, ob Item, trgt Item) *Remove {
|
||||
a := ActivityNew(id, RemoveType, ob)
|
||||
o := Remove(*a)
|
||||
o.Target = trgt
|
||||
|
@ -649,14 +649,14 @@ func RemoveNew(id ObjectID, ob ObjectOrLink, trgt ObjectOrLink) *Remove {
|
|||
}
|
||||
|
||||
// TentativeRejectNew initializes a TentativeReject activity
|
||||
func TentativeRejectNew(id ObjectID, ob ObjectOrLink) *TentativeReject {
|
||||
func TentativeRejectNew(id ObjectID, ob Item) *TentativeReject {
|
||||
a := ActivityNew(id, TentativeRejectType, ob)
|
||||
o := TentativeReject(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// TentativeAcceptNew initializes a TentativeAccept activity
|
||||
func TentativeAcceptNew(id ObjectID, ob ObjectOrLink) *TentativeAccept {
|
||||
func TentativeAcceptNew(id ObjectID, ob Item) *TentativeAccept {
|
||||
a := ActivityNew(id, TentativeAcceptType, ob)
|
||||
o := TentativeAccept(*a)
|
||||
return &o
|
||||
|
@ -670,21 +670,21 @@ func TravelNew(id ObjectID) *Travel {
|
|||
}
|
||||
|
||||
// UndoNew initializes an Undo activity
|
||||
func UndoNew(id ObjectID, ob ObjectOrLink) *Undo {
|
||||
func UndoNew(id ObjectID, ob Item) *Undo {
|
||||
a := ActivityNew(id, UndoType, ob)
|
||||
o := Undo(*a)
|
||||
return &o
|
||||
}
|
||||
|
||||
// UpdateNew initializes an Update activity
|
||||
func UpdateNew(id ObjectID, ob ObjectOrLink) *Update {
|
||||
func UpdateNew(id ObjectID, ob Item) *Update {
|
||||
a := ActivityNew(id, UpdateType, ob)
|
||||
u := Update(*a)
|
||||
return &u
|
||||
}
|
||||
|
||||
// ViewNew initializes a View activity
|
||||
func ViewNew(id ObjectID, ob ObjectOrLink) *View {
|
||||
func ViewNew(id ObjectID, ob Item) *View {
|
||||
a := ActivityNew(id, ViewType, ob)
|
||||
o := View(*a)
|
||||
return &o
|
||||
|
@ -710,7 +710,7 @@ func ValidActivityType(typ ActivityVocabularyType) bool {
|
|||
}
|
||||
|
||||
// ActivityNew initializes a basic activity
|
||||
func ActivityNew(id ObjectID, typ ActivityVocabularyType, ob ObjectOrLink) *Activity {
|
||||
func ActivityNew(id ObjectID, typ ActivityVocabularyType, ob Item) *Activity {
|
||||
if !ValidActivityType(typ) {
|
||||
typ = ActivityType
|
||||
}
|
||||
|
@ -739,21 +739,21 @@ func IntransitiveActivityNew(id ObjectID, typ ActivityVocabularyType) *Intransit
|
|||
|
||||
// RecipientsDeduplication
|
||||
func (a *Activity) RecipientsDeduplication() {
|
||||
var actor ObjectsArr
|
||||
var actor ItemCollection
|
||||
actor.Append(a.Actor)
|
||||
recipientsDeduplication(&actor, &a.To, &a.Bto, &a.CC, &a.BCC)
|
||||
}
|
||||
|
||||
// RecipientsDeduplication
|
||||
func (i *IntransitiveActivity) RecipientsDeduplication() {
|
||||
var actor ObjectsArr
|
||||
var actor ItemCollection
|
||||
actor.Append(i.Actor)
|
||||
recipientsDeduplication(&actor, &i.To, &i.Bto, &i.CC, &i.BCC)
|
||||
}
|
||||
|
||||
// RecipientsDeduplication
|
||||
func (b *Block) RecipientsDeduplication() {
|
||||
var dedupObjects ObjectsArr
|
||||
var dedupObjects ItemCollection
|
||||
dedupObjects.Append(b.Actor)
|
||||
dedupObjects.Append(b.Object)
|
||||
recipientsDeduplication(&dedupObjects, &b.To, &b.Bto, &b.CC, &b.BCC)
|
||||
|
@ -761,7 +761,7 @@ func (b *Block) RecipientsDeduplication() {
|
|||
|
||||
// RecipientsDeduplication
|
||||
func (c *Create) RecipientsDeduplication() {
|
||||
var dedupObjects ObjectsArr
|
||||
var dedupObjects ItemCollection
|
||||
dedupObjects.Append(c.Actor)
|
||||
dedupObjects.Append(c.Object)
|
||||
recipientsDeduplication(&dedupObjects, &c.To, &c.Bto, &c.CC, &c.BCC)
|
||||
|
@ -769,7 +769,7 @@ func (c *Create) RecipientsDeduplication() {
|
|||
|
||||
// RecipientsDeduplication
|
||||
func (l *Like) RecipientsDeduplication() {
|
||||
var dedupObjects ObjectsArr
|
||||
var dedupObjects ItemCollection
|
||||
dedupObjects.Append(l.Actor)
|
||||
dedupObjects.Append(l.Object)
|
||||
recipientsDeduplication(&dedupObjects, &l.To, &l.Bto, &l.CC, &l.BCC)
|
||||
|
@ -777,7 +777,7 @@ func (l *Like) RecipientsDeduplication() {
|
|||
|
||||
// RecipientsDeduplication
|
||||
func (d *Dislike) RecipientsDeduplication() {
|
||||
var dedupObjects ObjectsArr
|
||||
var dedupObjects ItemCollection
|
||||
dedupObjects.Append(d.Actor)
|
||||
dedupObjects.Append(d.Object)
|
||||
recipientsDeduplication(&dedupObjects, &d.To, &d.Bto, &d.CC, &d.BCC)
|
||||
|
@ -785,7 +785,7 @@ func (d *Dislike) RecipientsDeduplication() {
|
|||
|
||||
// RecipientsDeduplication
|
||||
func (u *Update) RecipientsDeduplication() {
|
||||
var dedupObjects ObjectsArr
|
||||
var dedupObjects ItemCollection
|
||||
dedupObjects.Append(u.Actor)
|
||||
dedupObjects.Append(u.Object)
|
||||
recipientsDeduplication(&dedupObjects, &u.To, &u.Bto, &u.CC, &u.BCC)
|
||||
|
@ -1410,7 +1410,7 @@ func (a *Activity) UnmarshalJSON(data []byte) error {
|
|||
a.Published = getAPTime(data, "published")
|
||||
a.StartTime = getAPTime(data, "startTime")
|
||||
a.Updated = getAPTime(data, "updated")
|
||||
to := getAPObjectsArr(data, "to")
|
||||
to := getAPItemCollection(data, "to")
|
||||
if to != nil {
|
||||
a.To = to
|
||||
}
|
||||
|
|
|
@ -29,29 +29,29 @@ var validActorTypes = [...]ActivityVocabularyType{
|
|||
// a JSON-LD document with these properties.
|
||||
type Endpoints struct {
|
||||
// Upload endpoint URI for this user for binary data.
|
||||
UploadMedia ObjectOrLink `jsonld:"uploadMedia,omitempty"`
|
||||
UploadMedia Item `jsonld:"uploadMedia,omitempty"`
|
||||
// Endpoint URI so this actor's clients may access remote ActivityStreams objects which require authentication
|
||||
// to access. To use this endpoint, the client posts an x-www-form-urlencoded id parameter with the value being
|
||||
// the id of the requested ActivityStreams object.
|
||||
OauthAuthorizationEndpoint ObjectOrLink `jsonld:"oauthAuthorizationEndpoint,omitempty"`
|
||||
OauthAuthorizationEndpoint Item `jsonld:"oauthAuthorizationEndpoint,omitempty"`
|
||||
// If OAuth 2.0 bearer tokens [RFC6749] [RFC6750] are being used for authenticating client to server interactions,
|
||||
// this endpoint specifies a URI at which a browser-authenticated user may obtain a new authorization grant.
|
||||
OauthTokenEndpoint ObjectOrLink `jsonld:"oauthTokenEndpoint,omitempty"`
|
||||
OauthTokenEndpoint Item `jsonld:"oauthTokenEndpoint,omitempty"`
|
||||
// If OAuth 2.0 bearer tokens [RFC6749] [RFC6750] are being used for authenticating client to server interactions,
|
||||
// this endpoint specifies a URI at which a client may acquire an access token.
|
||||
ProvideClientKey ObjectOrLink `jsonld:"provideClientKey,omitempty"`
|
||||
ProvideClientKey Item `jsonld:"provideClientKey,omitempty"`
|
||||
// If Linked Data Signatures and HTTP Signatures are being used for authentication and authorization,
|
||||
// this endpoint specifies a URI at which browser-authenticated users may authorize a client's public
|
||||
// key for client to server interactions.
|
||||
SignClientKey ObjectOrLink `jsonld:"signClientKey,omitempty"`
|
||||
SignClientKey Item `jsonld:"signClientKey,omitempty"`
|
||||
// If Linked Data Signatures and HTTP Signatures are being used for authentication and authorization,
|
||||
// this endpoint specifies a URI at which a client key may be signed by the actor's key for a time window to
|
||||
// act on behalf of the actor in interacting with foreign servers.
|
||||
SharedInbox ObjectOrLink `jsonld:"sharedInbox,omitempty"`
|
||||
SharedInbox Item `jsonld:"sharedInbox,omitempty"`
|
||||
}
|
||||
|
||||
type CanAct interface {
|
||||
ObjectOrLink
|
||||
Item
|
||||
Actor() Actor
|
||||
}
|
||||
|
||||
|
@ -69,13 +69,13 @@ type Actor struct {
|
|||
Name NaturalLanguageValue `jsonld:"name,omitempty,collapsible"`
|
||||
// Identifies a resource attached or related to an object that potentially requires special handling.
|
||||
// The intent is to provide a model that is at least semantically similar to attachments in email.
|
||||
Attachment ObjectOrLink `jsonld:"attachment,omitempty"`
|
||||
Attachment Item `jsonld:"attachment,omitempty"`
|
||||
// Identifies one or more entities to which this object is attributed. The attributed entities might not be Actors.
|
||||
// For instance, an object might be attributed to the completion of another activity.
|
||||
AttributedTo ObjectOrLink `jsonld:"attributedTo,omitempty"`
|
||||
AttributedTo Item `jsonld:"attributedTo,omitempty"`
|
||||
// Identifies one or more entities that represent the total population of entities
|
||||
// for which the object can considered to be relevant.
|
||||
Audience ObjectOrLink `jsonld:"audience,omitempty"`
|
||||
Audience Item `jsonld:"audience,omitempty"`
|
||||
// The content or textual representation of the Activity Pub Object encoded as a JSON string.
|
||||
// By default, the value of content is HTML.
|
||||
// The mediaType property can be used in the object to indicate a different content type.
|
||||
|
@ -85,13 +85,13 @@ type Actor struct {
|
|||
// The notion of "context" used is intentionally vague.
|
||||
// The intended function is to serve as a means of grouping objects and activities that share a
|
||||
// common originating context or purpose. An example could be all activities relating to a common project or event.
|
||||
Context ObjectOrLink `jsonld:"context,omitempty"`
|
||||
Context Item `jsonld:"context,omitempty"`
|
||||
// The date and time describing the actual or expected ending time of the object.
|
||||
// When used with an Activity object, for instance, the endTime property specifies the moment
|
||||
// the activity concluded or is expected to conclude.
|
||||
EndTime time.Time `jsonld:"endTime,omitempty"`
|
||||
// Identifies the entity (e.g. an application) that generated the object.
|
||||
Generator ObjectOrLink `jsonld:"generator,omitempty"`
|
||||
Generator Item `jsonld:"generator,omitempty"`
|
||||
// Indicates an entity that describes an icon for this object.
|
||||
// The image should have an aspect ratio of one (horizontal) to one (vertical)
|
||||
// and should be suitable for presentation at a small size.
|
||||
|
@ -100,15 +100,15 @@ type Actor struct {
|
|||
// Unlike the icon property, there are no aspect ratio or display size limitations assumed.
|
||||
Image ImageOrLink `jsonld:"image,omitempty"`
|
||||
// Indicates one or more entities for which this object is considered a response.
|
||||
InReplyTo ObjectOrLink `jsonld:"inReplyTo,omitempty"`
|
||||
InReplyTo Item `jsonld:"inReplyTo,omitempty"`
|
||||
// Indicates one or more physical or logical locations associated with the object.
|
||||
Location ObjectOrLink `jsonld:"location,omitempty"`
|
||||
Location Item `jsonld:"location,omitempty"`
|
||||
// Identifies an entity that provides a preview of this object.
|
||||
Preview ObjectOrLink `jsonld:"preview,omitempty"`
|
||||
Preview Item `jsonld:"preview,omitempty"`
|
||||
// The date and time at which the object was published
|
||||
Published time.Time `jsonld:"published,omitempty"`
|
||||
// Identifies a Collection containing objects considered to be responses to this object.
|
||||
Replies CollectionInterface `jsonld:"replies,omitempty"`
|
||||
Replies Item `jsonld:"replies,omitempty"`
|
||||
// The date and time describing the actual or expected starting time of the object.
|
||||
// When used with an Activity object, for instance, the startTime property specifies
|
||||
// the moment the activity began or is scheduled to begin.
|
||||
|
@ -119,19 +119,19 @@ type Actor struct {
|
|||
// One or more "tags" that have been associated with an objects. A tag can be any kind of Activity Pub Object.
|
||||
// The key difference between attachment and tag is that the former implies association by inclusion,
|
||||
// while the latter implies associated by reference.
|
||||
Tag ObjectOrLink `jsonld:"tag,omitempty"`
|
||||
Tag Item `jsonld:"tag,omitempty"`
|
||||
// The date and time at which the object was updated
|
||||
Updated time.Time `jsonld:"updated,omitempty"`
|
||||
// Identifies one or more links to representations of the object
|
||||
URL LinkOrURI `jsonld:"url,omitempty"`
|
||||
// Identifies an entity considered to be part of the public primary audience of an Activity Pub Object
|
||||
To ObjectsArr `jsonld:"to,omitempty"`
|
||||
To ItemCollection `jsonld:"to,omitempty"`
|
||||
// Identifies an Activity Pub Object that is part of the private primary audience of this Activity Pub Object.
|
||||
Bto ObjectsArr `jsonld:"bto,omitempty"`
|
||||
Bto ItemCollection `jsonld:"bto,omitempty"`
|
||||
// Identifies an Activity Pub Object that is part of the public secondary audience of this Activity Pub Object.
|
||||
CC ObjectsArr `jsonld:"cc,omitempty"`
|
||||
CC ItemCollection `jsonld:"cc,omitempty"`
|
||||
// Identifies one or more Objects that are part of the private secondary audience of this Activity Pub Object.
|
||||
BCC ObjectsArr `jsonld:"bcc,omitempty"`
|
||||
BCC ItemCollection `jsonld:"bcc,omitempty"`
|
||||
// When the object describes a time-bound resource, such as an audio or video, a meeting, etc,
|
||||
// the duration property indicates the object's approximate duration.
|
||||
// The value must be expressed as an xsd:duration as defined by [ xmlschema11-2],
|
||||
|
@ -139,19 +139,19 @@ type Actor struct {
|
|||
Duration time.Duration `jsonld:"duration,omitempty"`
|
||||
// A reference to an [ActivityStreams] OrderedCollection comprised of all the messages received by the actor;
|
||||
// see 5.2 Inbox.
|
||||
Inbox CollectionInterface `jsonld:"inbox,omitempty"`
|
||||
Inbox Item `jsonld:"inbox,omitempty"`
|
||||
// An [ActivityStreams] OrderedCollection comprised of all the messages produced by the actor;
|
||||
// see 5.1 Outbox.
|
||||
Outbox CollectionInterface `jsonld:"outbox,omitempty"`
|
||||
Outbox Item `jsonld:"outbox,omitempty"`
|
||||
// A link to an [ActivityStreams] collection of the actors that this actor is following;
|
||||
// see 5.4 Following Collection
|
||||
Following CollectionInterface `jsonld:"following,omitempty"`
|
||||
Following Item `jsonld:"following,omitempty"`
|
||||
// A link to an [ActivityStreams] collection of the actors that follow this actor;
|
||||
// see 5.3 Followers Collection.
|
||||
Followers CollectionInterface `jsonld:"followers,omitempty"`
|
||||
Followers Item `jsonld:"followers,omitempty"`
|
||||
// A link to an [ActivityStreams] collection of the actors that follow this actor;
|
||||
// see 5.3 Followers Collection.
|
||||
Liked CollectionInterface `jsonld:"liked,omitempty"`
|
||||
Liked Item `jsonld:"liked,omitempty"`
|
||||
// A short username which may be used to refer to the actor, with no uniqueness guarantees.
|
||||
PreferredUsername NaturalLanguageValue `jsonld:"preferredUsername,omitempty,collapsible"`
|
||||
// A json object which maps additional (typically server/domain-wide) endpoints which may be useful either
|
||||
|
@ -160,7 +160,7 @@ type Actor struct {
|
|||
// to a JSON-LD document with these properties.
|
||||
Endpoints Endpoints `jsonld:"endpoints,omitempty"`
|
||||
// A list of supplementary Collections which may be of interest.
|
||||
Streams []CollectionInterface `jsonld:"streams,omitempty"`
|
||||
Streams []Item `jsonld:"streams,omitempty"`
|
||||
}
|
||||
|
||||
// ActorInterface
|
||||
|
@ -427,14 +427,17 @@ func (a Application) Actor() Actor {
|
|||
func (g Group) Actor() Actor {
|
||||
return Actor(g)
|
||||
}
|
||||
|
||||
// Actor returns the underlying Actor type
|
||||
func (o Organization) Actor() Actor {
|
||||
return Actor(o)
|
||||
}
|
||||
|
||||
// Actor returns the underlying Actor type
|
||||
func (p Person) Actor() Actor {
|
||||
return Actor(p)
|
||||
}
|
||||
|
||||
// Actor returns the underlying Actor type
|
||||
func (s Service) Actor() Actor {
|
||||
return Actor(s)
|
||||
|
|
|
@ -141,4 +141,3 @@ func TestPerson_IsObject(t *testing.T) {
|
|||
t.Errorf("%T should be a valid object", m)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ import (
|
|||
var validCollectionTypes = [...]ActivityVocabularyType{CollectionType, OrderedCollectionType}
|
||||
|
||||
// Page represents a Web Page.
|
||||
type Page ObjectOrLink
|
||||
type Page Item
|
||||
|
||||
type CollectionInterface interface {
|
||||
ObjectOrLink
|
||||
Collection() CollectionInterface
|
||||
Append(ob ObjectOrLink) error
|
||||
Append(ob Item) error
|
||||
}
|
||||
|
||||
// Collection is a subtype of Activity Pub Object that represents ordered or unordered sets of Activity Pub Object or Link instances.
|
||||
|
@ -26,13 +26,13 @@ type Collection struct {
|
|||
Name NaturalLanguageValue `jsonld:"name,omitempty,collapsible"`
|
||||
// Identifies a resource attached or related to an object that potentially requires special handling.
|
||||
// The intent is to provide a model that is at least semantically similar to attachments in email.
|
||||
Attachment ObjectOrLink `jsonld:"attachment,omitempty"`
|
||||
Attachment Item `jsonld:"attachment,omitempty"`
|
||||
// Identifies one or more entities to which this object is attributed. The attributed entities might not be Actors.
|
||||
// For instance, an object might be attributed to the completion of another activity.
|
||||
AttributedTo ObjectOrLink `jsonld:"attributedTo,omitempty"`
|
||||
AttributedTo Item `jsonld:"attributedTo,omitempty"`
|
||||
// Identifies one or more entities that represent the total population of entities
|
||||
// for which the object can considered to be relevant.
|
||||
Audience ObjectOrLink `jsonld:"audience,omitempty"`
|
||||
Audience Item `jsonld:"audience,omitempty"`
|
||||
// The content or textual representation of the Activity Pub Activity Pub Object encoded as a JSON string.
|
||||
// By default, the value of content is HTML.
|
||||
// The mediaType property can be used in the object to indicate a different content type.
|
||||
|
@ -42,13 +42,13 @@ type Collection struct {
|
|||
// The notion of "context" used is intentionally vague.
|
||||
// The intended function is to serve as a means of grouping objects and activities that share a
|
||||
// common originating context or purpose. An example could be all activities relating to a common project or event.
|
||||
Context ObjectOrLink `jsonld:"context,omitempty"`
|
||||
Context Item `jsonld:"context,omitempty"`
|
||||
// The date and time describing the actual or expected ending time of the object.
|
||||
// When used with an Activity object, for instance, the endTime property specifies the moment
|
||||
// the activity concluded or is expected to conclude.
|
||||
EndTime time.Time `jsonld:"endTime,omitempty"`
|
||||
// Identifies the entity (e.g. an application) that generated the object.
|
||||
Generator ObjectOrLink `jsonld:"generator,omitempty"`
|
||||
Generator Item `jsonld:"generator,omitempty"`
|
||||
// Indicates an entity that describes an icon for this object.
|
||||
// The image should have an aspect ratio of one (horizontal) to one (vertical)
|
||||
// and should be suitable for presentation at a small size.
|
||||
|
@ -57,15 +57,15 @@ type Collection struct {
|
|||
// Unlike the icon property, there are no aspect ratio or display size limitations assumed.
|
||||
Image ImageOrLink `jsonld:"image,omitempty"`
|
||||
// Indicates one or more entities for which this object is considered a response.
|
||||
InReplyTo ObjectOrLink `jsonld:"inReplyTo,omitempty"`
|
||||
InReplyTo Item `jsonld:"inReplyTo,omitempty"`
|
||||
// Indicates one or more physical or logical locations associated with the object.
|
||||
Location ObjectOrLink `jsonld:"location,omitempty"`
|
||||
Location Item `jsonld:"location,omitempty"`
|
||||
// Identifies an entity that provides a preview of this object.
|
||||
Preview ObjectOrLink `jsonld:"preview,omitempty"`
|
||||
Preview Item `jsonld:"preview,omitempty"`
|
||||
// The date and time at which the object was published
|
||||
Published time.Time `jsonld:"published,omitempty"`
|
||||
// Identifies a Collection containing objects considered to be responses to this object.
|
||||
Replies CollectionInterface `jsonld:"replies,omitempty"`
|
||||
Replies Item `jsonld:"replies,omitempty"`
|
||||
// The date and time describing the actual or expected starting time of the object.
|
||||
// When used with an Activity object, for instance, the startTime property specifies
|
||||
// the moment the activity began or is scheduled to begin.
|
||||
|
@ -76,19 +76,19 @@ type Collection struct {
|
|||
// One or more "tags" that have been associated with an objects. A tag can be any kind of Activity Pub Object.
|
||||
// The key difference between attachment and tag is that the former implies association by inclusion,
|
||||
// while the latter implies associated by reference.
|
||||
Tag ObjectOrLink `jsonld:"tag,omitempty"`
|
||||
Tag Item `jsonld:"tag,omitempty"`
|
||||
// The date and time at which the object was updated
|
||||
Updated time.Time `jsonld:"updated,omitempty"`
|
||||
// Identifies one or more links to representations of the object
|
||||
URL LinkOrURI `jsonld:"url,omitempty"`
|
||||
// Identifies an entity considered to be part of the public primary audience of an Activity Pub Object
|
||||
To ObjectsArr `jsonld:"to,omitempty"`
|
||||
To ItemCollection `jsonld:"to,omitempty"`
|
||||
// Identifies an Activity Pub Activity Pub Object that is part of the private primary audience of this Activity Pub Object.
|
||||
Bto ObjectsArr `jsonld:"bto,omitempty"`
|
||||
Bto ItemCollection `jsonld:"bto,omitempty"`
|
||||
// Identifies an Activity Pub Activity Pub Object that is part of the public secondary audience of this Activity Pub Object.
|
||||
CC ObjectsArr `jsonld:"cc,omitempty"`
|
||||
CC ItemCollection `jsonld:"cc,omitempty"`
|
||||
// Identifies one or more Objects that are part of the private secondary audience of this Activity Pub Object.
|
||||
BCC ObjectsArr `jsonld:"bcc,omitempty"`
|
||||
BCC ItemCollection `jsonld:"bcc,omitempty"`
|
||||
// When the object describes a time-bound resource, such as an audio or video, a meeting, etc,
|
||||
// the duration property indicates the object's approximate duration.
|
||||
// The value must be expressed as an xsd:duration as defined by [ xmlschema11-2],
|
||||
|
@ -113,13 +113,13 @@ type OrderedCollection struct {
|
|||
Name NaturalLanguageValue `jsonld:"name,omitempty,collapsible"`
|
||||
// Identifies a resource attached or related to an object that potentially requires special handling.
|
||||
// The intent is to provide a model that is at least semantically similar to attachments in email.
|
||||
Attachment ObjectOrLink `jsonld:"attachment,omitempty"`
|
||||
Attachment Item `jsonld:"attachment,omitempty"`
|
||||
// Identifies one or more entities to which this object is attributed. The attributed entities might not be Actors.
|
||||
// For instance, an object might be attributed to the completion of another activity.
|
||||
AttributedTo ObjectOrLink `jsonld:"attributedTo,omitempty"`
|
||||
AttributedTo Item `jsonld:"attributedTo,omitempty"`
|
||||
// Identifies one or more entities that represent the total population of entities
|
||||
// for which the object can considered to be relevant.
|
||||
Audience ObjectOrLink `jsonld:"audience,omitempty"`
|
||||
Audience Item `jsonld:"audience,omitempty"`
|
||||
// The content or textual representation of the Activity Pub Activity Pub Object encoded as a JSON string.
|
||||
// By default, the value of content is HTML.
|
||||
// The mediaType property can be used in the object to indicate a different content type.
|
||||
|
@ -129,13 +129,13 @@ type OrderedCollection struct {
|
|||
// The notion of "context" used is intentionally vague.
|
||||
// The intended function is to serve as a means of grouping objects and activities that share a
|
||||
// common originating context or purpose. An example could be all activities relating to a common project or event.
|
||||
Context ObjectOrLink `jsonld:"context,omitempty"`
|
||||
Context Item `jsonld:"context,omitempty"`
|
||||
// The date and time describing the actual or expected ending time of the object.
|
||||
// When used with an Activity object, for instance, the endTime property specifies the moment
|
||||
// the activity concluded or is expected to conclude.
|
||||
EndTime time.Time `jsonld:"endTime,omitempty"`
|
||||
// Identifies the entity (e.g. an application) that generated the object.
|
||||
Generator ObjectOrLink `jsonld:"generator,omitempty"`
|
||||
Generator Item `jsonld:"generator,omitempty"`
|
||||
// Indicates an entity that describes an icon for this object.
|
||||
// The image should have an aspect ratio of one (horizontal) to one (vertical)
|
||||
// and should be suitable for presentation at a small size.
|
||||
|
@ -144,15 +144,15 @@ type OrderedCollection struct {
|
|||
// Unlike the icon property, there are no aspect ratio or display size limitations assumed.
|
||||
Image ImageOrLink `jsonld:"image,omitempty"`
|
||||
// Indicates one or more entities for which this object is considered a response.
|
||||
InReplyTo ObjectOrLink `jsonld:"inReplyTo,omitempty"`
|
||||
InReplyTo Item `jsonld:"inReplyTo,omitempty"`
|
||||
// Indicates one or more physical or logical locations associated with the object.
|
||||
Location ObjectOrLink `jsonld:"location,omitempty"`
|
||||
Location Item `jsonld:"location,omitempty"`
|
||||
// Identifies an entity that provides a preview of this object.
|
||||
Preview ObjectOrLink `jsonld:"preview,omitempty"`
|
||||
Preview Item `jsonld:"preview,omitempty"`
|
||||
// The date and time at which the object was published
|
||||
Published time.Time `jsonld:"published,omitempty"`
|
||||
// Identifies a Collection containing objects considered to be responses to this object.
|
||||
Replies CollectionInterface `jsonld:"replies,omitempty"`
|
||||
Replies Item `jsonld:"replies,omitempty"`
|
||||
// The date and time describing the actual or expected starting time of the object.
|
||||
// When used with an Activity object, for instance, the startTime property specifies
|
||||
// the moment the activity began or is scheduled to begin.
|
||||
|
@ -163,19 +163,19 @@ type OrderedCollection struct {
|
|||
// One or more "tags" that have been associated with an objects. A tag can be any kind of Activity Pub Object.
|
||||
// The key difference between attachment and tag is that the former implies association by inclusion,
|
||||
// while the latter implies associated by reference.
|
||||
Tag ObjectOrLink `jsonld:"tag,omitempty"`
|
||||
Tag Item `jsonld:"tag,omitempty"`
|
||||
// The date and time at which the object was updated
|
||||
Updated time.Time `jsonld:"updated,omitempty"`
|
||||
// Identifies one or more links to representations of the object
|
||||
URL LinkOrURI `jsonld:"url,omitempty"`
|
||||
// Identifies an entity considered to be part of the public primary audience of an Activity Pub Object
|
||||
To ObjectsArr `jsonld:"to,omitempty"`
|
||||
To ItemCollection `jsonld:"to,omitempty"`
|
||||
// Identifies an Activity Pub Activity Pub Object that is part of the private primary audience of this Activity Pub Object.
|
||||
Bto ObjectsArr `jsonld:"bto,omitempty"`
|
||||
Bto ItemCollection `jsonld:"bto,omitempty"`
|
||||
// Identifies an Activity Pub Activity Pub Object that is part of the public secondary audience of this Activity Pub Object.
|
||||
CC ObjectsArr `jsonld:"cc,omitempty"`
|
||||
CC ItemCollection `jsonld:"cc,omitempty"`
|
||||
// Identifies one or more Objects that are part of the private secondary audience of this Activity Pub Object.
|
||||
BCC ObjectsArr `jsonld:"bcc,omitempty"`
|
||||
BCC ItemCollection `jsonld:"bcc,omitempty"`
|
||||
// When the object describes a time-bound resource, such as an audio or video, a meeting, etc,
|
||||
// the duration property indicates the object's approximate duration.
|
||||
// The value must be expressed as an xsd:duration as defined by [ xmlschema11-2],
|
||||
|
@ -265,14 +265,14 @@ func OrderedCollectionPageNew(parent *OrderedCollection) *OrderedCollectionPage
|
|||
}
|
||||
|
||||
// Append adds an element to an OrderedCollection
|
||||
func (o *OrderedCollection) Append(ob ObjectOrLink) error {
|
||||
func (o *OrderedCollection) Append(ob Item) error {
|
||||
o.OrderedItems = append(o.OrderedItems, ob)
|
||||
o.TotalItems++
|
||||
return nil
|
||||
}
|
||||
|
||||
// Append adds an element to an Collection
|
||||
func (c *Collection) Append(ob ObjectOrLink) error {
|
||||
func (c *Collection) Append(ob Item) error {
|
||||
c.Items = append(c.Items, ob)
|
||||
c.TotalItems++
|
||||
return nil
|
||||
|
|
|
@ -4,64 +4,91 @@ import "time"
|
|||
|
||||
// CreateActivity is the type for a create activity message
|
||||
type CreateActivity struct {
|
||||
Activity *Create `jsonld:"activity"`
|
||||
Published time.Time `jsonld:"published"`
|
||||
To ObjectsArr `jsonld:"to,omitempty,collapsible"`
|
||||
CC ObjectsArr `jsonld:"cc,omitempty,collapsible"`
|
||||
Activity *Create `jsonld:"activity"`
|
||||
Published time.Time `jsonld:"published"`
|
||||
To ItemCollection `jsonld:"to,omitempty,collapsible"`
|
||||
CC ItemCollection `jsonld:"cc,omitempty,collapsible"`
|
||||
}
|
||||
|
||||
func loadActorWithInboxObject(a ObjectOrLink, o ObjectOrLink) ObjectOrLink {
|
||||
func loadActorWithInboxObject(a Item, o Item) Item {
|
||||
typ := a.GetType()
|
||||
switch typ {
|
||||
case ApplicationType:
|
||||
var app Application
|
||||
app, _ = a.(Application)
|
||||
var inbox *Inbox
|
||||
if app.Inbox == nil {
|
||||
app.Inbox = InboxNew()
|
||||
inbox = InboxNew()
|
||||
} else {
|
||||
inbox = app.Inbox.(*Inbox)
|
||||
}
|
||||
app.Inbox.Append(o)
|
||||
inbox.Append(o)
|
||||
app.Inbox = inbox
|
||||
return app
|
||||
case GroupType:
|
||||
var grp Group
|
||||
grp, _ = a.(Group)
|
||||
var inbox *Inbox
|
||||
if grp.Inbox == nil {
|
||||
grp.Inbox = InboxNew()
|
||||
inbox = InboxNew()
|
||||
} else {
|
||||
inbox = grp.Inbox.(*Inbox)
|
||||
}
|
||||
grp.Inbox.Append(o)
|
||||
inbox.Append(o)
|
||||
grp.Inbox = inbox
|
||||
return grp
|
||||
case OrganizationType:
|
||||
var org Organization
|
||||
org, _ = a.(Organization)
|
||||
var inbox *Inbox
|
||||
if org.Inbox == nil {
|
||||
org.Inbox = InboxNew()
|
||||
inbox = InboxNew()
|
||||
} else {
|
||||
inbox = org.Inbox.(*Inbox)
|
||||
}
|
||||
org.Inbox.Append(o)
|
||||
inbox.Append(o)
|
||||
org.Inbox = inbox
|
||||
return org
|
||||
case PersonType:
|
||||
var pers Person
|
||||
pers, _ = a.(Person)
|
||||
var inbox *Inbox
|
||||
if pers.Inbox == nil {
|
||||
pers.Inbox = InboxNew()
|
||||
inbox = InboxNew()
|
||||
} else {
|
||||
inbox = pers.Inbox.(*Inbox)
|
||||
}
|
||||
pers.Inbox.Append(o)
|
||||
inbox.Append(o)
|
||||
pers.Inbox = inbox
|
||||
return pers
|
||||
case ServiceType:
|
||||
var serv Service
|
||||
serv, _ = a.(Service)
|
||||
serv.Inbox.Append(o)
|
||||
var inbox *Inbox
|
||||
if serv.Inbox == nil {
|
||||
inbox = InboxNew()
|
||||
} else {
|
||||
inbox = serv.Inbox.(*Inbox)
|
||||
}
|
||||
inbox.Append(o)
|
||||
serv.Inbox = inbox
|
||||
return serv
|
||||
default:
|
||||
actor, _ := a.(Actor)
|
||||
var inbox *Inbox
|
||||
if actor.Inbox == nil {
|
||||
actor.Inbox = InboxNew()
|
||||
inbox = InboxNew()
|
||||
} else {
|
||||
inbox = actor.Inbox.(*Inbox)
|
||||
}
|
||||
actor.Inbox.Append(o)
|
||||
inbox.Append(o)
|
||||
actor.Inbox = inbox
|
||||
return actor
|
||||
}
|
||||
}
|
||||
|
||||
// CreateActivityNew initializes a new CreateActivity message
|
||||
func CreateActivityNew(id ObjectID, a ObjectOrLink, o ObjectOrLink) CreateActivity {
|
||||
func CreateActivityNew(id ObjectID, a Item, o Item) CreateActivity {
|
||||
act := CreateNew(id, o)
|
||||
|
||||
if a != nil {
|
||||
|
|
|
@ -29,7 +29,7 @@ func InboxNew() *Inbox {
|
|||
}
|
||||
|
||||
// Append adds an element to an InboxStream
|
||||
func (i *InboxStream) Append(o ObjectOrLink) error {
|
||||
func (i *InboxStream) Append(o Item) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("nil ")
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ func (i *InboxStream) Append(o ObjectOrLink) error {
|
|||
}
|
||||
|
||||
// Append adds an element to an Inbox
|
||||
func (i *Inbox) Append(ob ObjectOrLink) error {
|
||||
func (i *Inbox) Append(ob Item) error {
|
||||
i.OrderedItems = append(i.OrderedItems, ob)
|
||||
i.TotalItems++
|
||||
return nil
|
||||
|
@ -107,12 +107,12 @@ func (i *Inbox) UnmarshalJSON(data []byte) error {
|
|||
|
||||
// Collection returns the underlying Collection type
|
||||
func (i *Inbox) Collection() CollectionInterface {
|
||||
c := OrderedCollection(*i)
|
||||
return &c
|
||||
c := OrderedCollection(*i)
|
||||
return &c
|
||||
}
|
||||
|
||||
// Collection returns the underlying Collection type
|
||||
func (i *InboxStream) Collection() CollectionInterface {
|
||||
c := OrderedCollection(*i)
|
||||
return &c
|
||||
c := OrderedCollection(*i)
|
||||
return &c
|
||||
}
|
||||
|
|
|
@ -25,9 +25,3 @@ func (i ItemCollection) IsLink() bool {
|
|||
func (i ItemCollection) IsObject() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Append adds an element to an Inbox
|
||||
func (i *ItemCollection) Append(ob ObjectOrLink) error {
|
||||
*i = append(*i, ob)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -4,72 +4,99 @@ import "time"
|
|||
|
||||
// LikeActivity is the type for a create activity message
|
||||
type LikeActivity struct {
|
||||
Activity *Like `jsonld:"activity"`
|
||||
Published time.Time `jsonld:"published"`
|
||||
To ObjectsArr `jsonld:"to,omitempty,collapsible"`
|
||||
CC ObjectsArr `jsonld:"cc,omitempty,collapsible"`
|
||||
Activity *Like `jsonld:"activity"`
|
||||
Published time.Time `jsonld:"published"`
|
||||
To ItemCollection `jsonld:"to,omitempty,collapsible"`
|
||||
CC ItemCollection `jsonld:"cc,omitempty,collapsible"`
|
||||
}
|
||||
|
||||
// DislikeActivity is the type for a create activity message
|
||||
type DislikeActivity struct {
|
||||
Activity *Dislike `jsonld:"activity"`
|
||||
Published time.Time `jsonld:"published"`
|
||||
To ObjectsArr `jsonld:"to,omitempty,collapsible"`
|
||||
CC ObjectsArr `jsonld:"cc,omitempty,collapsible"`
|
||||
Activity *Dislike `jsonld:"activity"`
|
||||
Published time.Time `jsonld:"published"`
|
||||
To ItemCollection `jsonld:"to,omitempty,collapsible"`
|
||||
CC ItemCollection `jsonld:"cc,omitempty,collapsible"`
|
||||
}
|
||||
|
||||
func loadActorWithLikedObject(a ObjectOrLink, o ObjectOrLink) ObjectOrLink {
|
||||
func loadActorWithLikedObject(a Item, o Item) Item {
|
||||
typ := a.GetType()
|
||||
switch typ {
|
||||
case ApplicationType:
|
||||
var app Application
|
||||
app, _ = a.(Application)
|
||||
var liked *Liked
|
||||
if app.Liked == nil {
|
||||
app.Liked = LikedNew()
|
||||
liked = LikedNew()
|
||||
} else {
|
||||
liked = app.Liked.(*Liked)
|
||||
}
|
||||
app.Liked.Append(o)
|
||||
liked.Append(o)
|
||||
app.Liked = liked
|
||||
return app
|
||||
case GroupType:
|
||||
var grp Group
|
||||
grp, _ = a.(Group)
|
||||
var liked *Liked
|
||||
if grp.Liked == nil {
|
||||
grp.Liked = LikedNew()
|
||||
liked = LikedNew()
|
||||
} else {
|
||||
liked = grp.Liked.(*Liked)
|
||||
}
|
||||
grp.Liked.Append(o)
|
||||
liked.Append(o)
|
||||
grp.Liked = liked
|
||||
return grp
|
||||
case OrganizationType:
|
||||
var org Organization
|
||||
org, _ = a.(Organization)
|
||||
var liked *Liked
|
||||
if org.Liked == nil {
|
||||
org.Liked = LikedNew()
|
||||
liked = LikedNew()
|
||||
} else {
|
||||
liked = org.Liked.(*Liked)
|
||||
}
|
||||
org.Liked.Append(o)
|
||||
liked.Append(o)
|
||||
org.Liked = liked
|
||||
return org
|
||||
case PersonType:
|
||||
var pers Person
|
||||
pers, _ = a.(Person)
|
||||
var liked *Liked
|
||||
if pers.Liked == nil {
|
||||
pers.Liked = LikedNew()
|
||||
liked = LikedNew()
|
||||
} else {
|
||||
liked = pers.Liked.(*Liked)
|
||||
}
|
||||
pers.Liked.Append(o)
|
||||
liked.Append(o)
|
||||
pers.Liked = liked
|
||||
return pers
|
||||
case ServiceType:
|
||||
var serv Service
|
||||
serv, _ = a.(Service)
|
||||
serv.Liked.Append(o)
|
||||
var liked *Liked
|
||||
if serv.Liked == nil {
|
||||
liked = LikedNew()
|
||||
} else {
|
||||
liked = serv.Liked.(*Liked)
|
||||
}
|
||||
liked.Append(o)
|
||||
serv.Liked = liked
|
||||
return serv
|
||||
default:
|
||||
actor, _ := a.(Actor)
|
||||
var liked *Liked
|
||||
if actor.Liked == nil {
|
||||
actor.Liked = LikedNew()
|
||||
liked = LikedNew()
|
||||
} else {
|
||||
liked = actor.Liked.(*Liked)
|
||||
}
|
||||
actor.Liked.Append(o)
|
||||
liked.Append(o)
|
||||
actor.Liked = liked
|
||||
return actor
|
||||
}
|
||||
}
|
||||
|
||||
// LikeActivityNew initializes a new LikeActivity message
|
||||
func LikeActivityNew(id ObjectID, a ObjectOrLink, o ObjectOrLink) LikeActivity {
|
||||
func LikeActivityNew(id ObjectID, a Item, o Item) LikeActivity {
|
||||
act := LikeNew(id, o)
|
||||
|
||||
if a != nil {
|
||||
|
@ -92,7 +119,7 @@ func LikeActivityNew(id ObjectID, a ObjectOrLink, o ObjectOrLink) LikeActivity {
|
|||
}
|
||||
|
||||
// DislikeActivityNew initializes a new LikeActivity message
|
||||
func DislikeActivityNew(id ObjectID, a ObjectOrLink, o ObjectOrLink) DislikeActivity {
|
||||
func DislikeActivityNew(id ObjectID, a Item, o Item) DislikeActivity {
|
||||
act := DislikeNew(id, o)
|
||||
|
||||
if a != nil {
|
||||
|
|
|
@ -26,14 +26,14 @@ func LikedNew() *Liked {
|
|||
}
|
||||
|
||||
// Append adds an element to an LikedCollection
|
||||
func (l *LikedCollection) Append(o ObjectOrLink) error {
|
||||
func (l *LikedCollection) Append(o Item) error {
|
||||
l.OrderedItems = append(l.OrderedItems, o)
|
||||
l.TotalItems++
|
||||
return nil
|
||||
}
|
||||
|
||||
// Append adds an element to an Outbox
|
||||
func (l *Liked) Append(ob ObjectOrLink) error {
|
||||
func (l *Liked) Append(ob Item) error {
|
||||
l.OrderedItems = append(l.OrderedItems, ob)
|
||||
l.TotalItems++
|
||||
return nil
|
||||
|
@ -81,12 +81,12 @@ func (l Liked) IsObject() bool {
|
|||
|
||||
// Collection returns the underlying Collection type
|
||||
func (l *Liked) Collection() CollectionInterface {
|
||||
c := OrderedCollection(*l)
|
||||
c := OrderedCollection(*l)
|
||||
return &c
|
||||
}
|
||||
|
||||
// Collection returns the underlying Collection type
|
||||
func (l *LikedCollection) Collection() CollectionInterface {
|
||||
c := OrderedCollection(*l)
|
||||
c := OrderedCollection(*l)
|
||||
return &c
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ type Link struct {
|
|||
// On a Link, specifies a hint as to the rendering width in device-independent pixels of the linked resource.
|
||||
Width uint `jsonld:"width,omitempty"`
|
||||
// Identifies an entity that provides a preview of this object.
|
||||
Preview ObjectOrLink `jsonld:"preview,omitempty"`
|
||||
Preview Item `jsonld:"preview,omitempty"`
|
||||
// The target resource pointed to by a Link.
|
||||
Href URI `jsonld:"href,omitempty"`
|
||||
// Hints as to the language used by the target resource.
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
func getAPObjectByType(typ ActivityVocabularyType) (ObjectOrLink, error) {
|
||||
var ret ObjectOrLink
|
||||
func getAPObjectByType(typ ActivityVocabularyType) (Item, error) {
|
||||
var ret Item
|
||||
var err error
|
||||
|
||||
switch typ {
|
||||
|
|
|
@ -95,7 +95,7 @@ type (
|
|||
ActivityObject interface {
|
||||
GetID() *ObjectID
|
||||
}
|
||||
// ObjectOrLink describes an object of any kind.
|
||||
// Item describes an object of any kind.
|
||||
ObjectOrLink interface {
|
||||
ActivityObject
|
||||
GetType() ActivityVocabularyType
|
||||
|
@ -103,8 +103,6 @@ type (
|
|||
IsObject() bool
|
||||
//UnmarshalJSON([]byte) error
|
||||
}
|
||||
// ObjectsArr is a named type for matching an ObjectOrLink slice type to Collection interface
|
||||
ObjectsArr []ObjectOrLink
|
||||
// LinkOrURI is an interface that Object and Link structs implement, and at the same time
|
||||
// they are kept disjointed
|
||||
LinkOrURI interface {
|
||||
|
@ -112,7 +110,7 @@ type (
|
|||
}
|
||||
// ImageOrLink is an interface that Image and Link structs implement
|
||||
ImageOrLink interface {
|
||||
ObjectOrLink
|
||||
Item
|
||||
LinkOrURI
|
||||
}
|
||||
// MimeType is the type for MIME types
|
||||
|
@ -262,13 +260,13 @@ type Object struct {
|
|||
Name NaturalLanguageValue `jsonld:"name,omitempty,collapsible"`
|
||||
// Identifies a resource attached or related to an object that potentially requires special handling.
|
||||
// The intent is to provide a model that is at least semantically similar to attachments in email.
|
||||
Attachment ObjectOrLink `jsonld:"attachment,omitempty"`
|
||||
Attachment Item `jsonld:"attachment,omitempty"`
|
||||
// Identifies one or more entities to which this object is attributed. The attributed entities might not be Actors.
|
||||
// For instance, an object might be attributed to the completion of another activity.
|
||||
AttributedTo ObjectOrLink `jsonld:"attributedTo,omitempty"`
|
||||
AttributedTo Item `jsonld:"attributedTo,omitempty"`
|
||||
// Identifies one or more entities that represent the total population of entities
|
||||
// for which the object can considered to be relevant.
|
||||
Audience ObjectOrLink `jsonld:"audience,omitempty"`
|
||||
Audience Item `jsonld:"audience,omitempty"`
|
||||
// The content or textual representation of the Activity Pub Object encoded as a JSON string.
|
||||
// By default, the value of content is HTML.
|
||||
// The mediaType property can be used in the object to indicate a different content type.
|
||||
|
@ -278,7 +276,7 @@ type Object struct {
|
|||
// The notion of "context" used is intentionally vague.
|
||||
// The intended function is to serve as a means of grouping objects and activities that share a
|
||||
// common originating context or purpose. An example could be all activities relating to a common project or event.
|
||||
Context ObjectOrLink `jsonld:"context,omitempty"`
|
||||
Context Item `jsonld:"context,omitempty"`
|
||||
// When used on an Object, identifies the MIME media type of the value of the content property.
|
||||
// If not specified, the content property is assumed to contain text/html content.
|
||||
MediaType MimeType `jsonld:"mediaType,omitempty"`
|
||||
|
@ -287,7 +285,7 @@ type Object struct {
|
|||
// the activity concluded or is expected to conclude.
|
||||
EndTime time.Time `jsonld:"endTime,omitempty"`
|
||||
// Identifies the entity (e.g. an application) that generated the object.
|
||||
Generator ObjectOrLink `jsonld:"generator,omitempty"`
|
||||
Generator Item `jsonld:"generator,omitempty"`
|
||||
// Indicates an entity that describes an icon for this object.
|
||||
// The image should have an aspect ratio of one (horizontal) to one (vertical)
|
||||
// and should be suitable for presentation at a small size.
|
||||
|
@ -296,15 +294,15 @@ type Object struct {
|
|||
// Unlike the icon property, there are no aspect ratio or display size limitations assumed.
|
||||
Image ImageOrLink `jsonld:"image,omitempty"`
|
||||
// Indicates one or more entities for which this object is considered a response.
|
||||
InReplyTo ObjectOrLink `jsonld:"inReplyTo,omitempty"`
|
||||
InReplyTo Item `jsonld:"inReplyTo,omitempty"`
|
||||
// Indicates one or more physical or logical locations associated with the object.
|
||||
Location ObjectOrLink `jsonld:"location,omitempty"`
|
||||
Location Item `jsonld:"location,omitempty"`
|
||||
// Identifies an entity that provides a preview of this object.
|
||||
Preview ObjectOrLink `jsonld:"preview,omitempty"`
|
||||
Preview Item `jsonld:"preview,omitempty"`
|
||||
// The date and time at which the object was published
|
||||
Published time.Time `jsonld:"published,omitempty"`
|
||||
// Identifies a Collection containing objects considered to be responses to this object.
|
||||
Replies CollectionInterface `jsonld:"replies,omitempty"`
|
||||
Replies Item `jsonld:"replies,omitempty"`
|
||||
// The date and time describing the actual or expected starting time of the object.
|
||||
// When used with an Activity object, for instance, the startTime property specifies
|
||||
// the moment the activity began or is scheduled to begin.
|
||||
|
@ -315,19 +313,19 @@ type Object struct {
|
|||
// One or more "tags" that have been associated with an objects. A tag can be any kind of Activity Pub Object.
|
||||
// The key difference between attachment and tag is that the former implies association by inclusion,
|
||||
// while the latter implies associated by reference.
|
||||
Tag ObjectOrLink `jsonld:"tag,omitempty"`
|
||||
Tag Item `jsonld:"tag,omitempty"`
|
||||
// The date and time at which the object was updated
|
||||
Updated time.Time `jsonld:"updated,omitempty"`
|
||||
// Identifies one or more links to representations of the object
|
||||
URL LinkOrURI `jsonld:"url,omitempty"`
|
||||
// Identifies an entity considered to be part of the public primary audience of an Activity Pub Object
|
||||
To ObjectsArr `jsonld:"to,omitempty"`
|
||||
To ItemCollection `jsonld:"to,omitempty"`
|
||||
// Identifies anActivity Pub Object that is part of the private primary audience of this Activity Pub Object.
|
||||
Bto ObjectsArr `jsonld:"bto,omitempty"`
|
||||
Bto ItemCollection `jsonld:"bto,omitempty"`
|
||||
// Identifies anActivity Pub Object that is part of the public secondary audience of this Activity Pub Object.
|
||||
CC ObjectsArr `jsonld:"cc,omitempty"`
|
||||
CC ItemCollection `jsonld:"cc,omitempty"`
|
||||
// Identifies one or more Objects that are part of the private secondary audience of this Activity Pub Object.
|
||||
BCC ObjectsArr `jsonld:"bcc,omitempty"`
|
||||
BCC ItemCollection `jsonld:"bcc,omitempty"`
|
||||
// When the object describes a time-bound resource, such as an audio or video, a meeting, etc,
|
||||
// the duration property indicates the object's approximate duration.
|
||||
// The value must be expressed as an xsd:duration as defined by [ xmlschema11-2],
|
||||
|
@ -387,21 +385,21 @@ func (o Object) GetType() ActivityVocabularyType {
|
|||
return o.Type
|
||||
}
|
||||
|
||||
// Append facilitates adding elements to ObjectOrLink arrays
|
||||
// and ensures ObjectsArr implements the Collection interface
|
||||
func (c *ObjectsArr) Append(o ObjectOrLink) error {
|
||||
oldLen := len(*c)
|
||||
d := make(ObjectsArr, oldLen+1)
|
||||
for k, it := range *c {
|
||||
// Append facilitates adding elements to Item arrays
|
||||
// and ensures ItemCollection implements the Collection interface
|
||||
func (i *ItemCollection) Append(o Item) error {
|
||||
oldLen := len(*i)
|
||||
d := make(ItemCollection, oldLen+1)
|
||||
for k, it := range *i {
|
||||
d[k] = it
|
||||
}
|
||||
d[oldLen] = o
|
||||
*c = d
|
||||
*i = d
|
||||
return nil
|
||||
}
|
||||
|
||||
// recipientsDeduplication normalizes the received arguments lists
|
||||
func recipientsDeduplication(recArgs ...*ObjectsArr) error {
|
||||
func recipientsDeduplication(recArgs ...*ItemCollection) error {
|
||||
recIds := make([]ObjectID, 0)
|
||||
|
||||
for _, recList := range recArgs {
|
||||
|
@ -473,7 +471,7 @@ func (o *Object) UnmarshalJSON(data []byte) error {
|
|||
o.Published = getAPTime(data, "published")
|
||||
o.StartTime = getAPTime(data, "startTime")
|
||||
o.Updated = getAPTime(data, "updated")
|
||||
to := getAPObjectsArr(data, "to")
|
||||
to := getAPItemCollection(data, "to")
|
||||
if to != nil {
|
||||
o.To = to
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestValidObjectType(t *testing.T) {
|
|||
func TestMarshalJSON(t *testing.T) {
|
||||
m := NaturalLanguageValue{
|
||||
{
|
||||
"en", "test",
|
||||
"en", "test",
|
||||
},
|
||||
{
|
||||
"de", "test",
|
||||
|
@ -102,7 +102,7 @@ func TestNaturalLanguageValue_MarshalJSON(t *testing.T) {
|
|||
if js != string(out) {
|
||||
t.Errorf("Different marshal result '%s', instead of '%s'", out, js)
|
||||
}
|
||||
p1 :=NaturalLanguageValue{
|
||||
p1 := NaturalLanguageValue{
|
||||
{
|
||||
"en", "the test",
|
||||
},
|
||||
|
@ -142,7 +142,7 @@ func TestObject_IsObject(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestObjectsArr_Append(t *testing.T) {
|
||||
d := make(ObjectsArr, 0)
|
||||
d := make(ItemCollection, 0)
|
||||
|
||||
val := Object{ID: ObjectID("grrr")}
|
||||
|
||||
|
@ -162,7 +162,7 @@ func TestRecipientsDeduplication(t *testing.T) {
|
|||
foo := OrganizationNew("foo")
|
||||
bar := GroupNew("bar")
|
||||
|
||||
first := make(ObjectsArr, 0)
|
||||
first := make(ItemCollection, 0)
|
||||
if len(first) != 0 {
|
||||
t.Errorf("Objects array should have exactly an element")
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ func TestRecipientsDeduplication(t *testing.T) {
|
|||
t.Errorf("Objects array should have exactly 4(four) elements, not %d", len(first))
|
||||
}
|
||||
|
||||
second := make(ObjectsArr, 0)
|
||||
second := make(ItemCollection, 0)
|
||||
second.Append(bar)
|
||||
second.Append(foo)
|
||||
|
||||
|
|
|
@ -25,14 +25,14 @@ func OutboxNew() *Outbox {
|
|||
}
|
||||
|
||||
// Append adds an element to an OutboxStream
|
||||
func (o *OutboxStream) Append(ob ObjectOrLink) error {
|
||||
func (o *OutboxStream) Append(ob Item) error {
|
||||
o.OrderedItems = append(o.OrderedItems, ob)
|
||||
o.TotalItems++
|
||||
return nil
|
||||
}
|
||||
|
||||
// Append adds an element to an Outbox
|
||||
func (o *Outbox) Append(ob ObjectOrLink) error {
|
||||
func (o *Outbox) Append(ob Item) error {
|
||||
o.OrderedItems = append(o.OrderedItems, ob)
|
||||
o.TotalItems++
|
||||
return nil
|
||||
|
@ -100,12 +100,12 @@ func (o *Outbox) UnmarshalJSON(data []byte) error {
|
|||
|
||||
// Collection returns the underlying Collection type
|
||||
func (o *Outbox) Collection() CollectionInterface {
|
||||
c := OrderedCollection(*o)
|
||||
c := OrderedCollection(*o)
|
||||
return &c
|
||||
}
|
||||
|
||||
// Collection returns the underlying Collection type
|
||||
func (o *OutboxStream) Collection() CollectionInterface {
|
||||
c := OrderedCollection(*o)
|
||||
c := OrderedCollection(*o)
|
||||
return &c
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
apUnmarshalerType = reflect.TypeOf(new(ObjectOrLink)).Elem()
|
||||
apUnmarshalerType = reflect.TypeOf(new(Item)).Elem()
|
||||
unmarshalerType = reflect.TypeOf(new(jsonld.Unmarshaler)).Elem()
|
||||
textUnmarshalerType = reflect.TypeOf(new(encoding.TextUnmarshaler)).Elem()
|
||||
)
|
||||
|
@ -203,13 +203,13 @@ func getAPItems(data []byte, prop string) ItemCollection {
|
|||
}
|
||||
return it
|
||||
}
|
||||
func getAPObjectsArr(data []byte, prop string) ObjectsArr {
|
||||
func getAPItemCollection(data []byte, prop string) ItemCollection {
|
||||
val, typ, _, err := jsonparser.Get(data, prop)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var it ObjectsArr
|
||||
var it ItemCollection
|
||||
switch typ {
|
||||
case jsonparser.Array:
|
||||
jsonparser.ArrayEach(data, func(value []byte, dataType jsonparser.ValueType, offset int, err error) {
|
||||
|
|
|
@ -4,14 +4,14 @@ import "time"
|
|||
|
||||
// UpdateActivity is the type for a Update activity message
|
||||
type UpdateActivity struct {
|
||||
Activity *Update `jsonld:"activity"`
|
||||
Published time.Time `jsonld:"published"`
|
||||
To ObjectsArr `jsonld:"to,omitempty,collapsible"`
|
||||
CC ObjectsArr `jsonld:"cc,omitempty,collapsible"`
|
||||
Activity *Update `jsonld:"activity"`
|
||||
Published time.Time `jsonld:"published"`
|
||||
To ItemCollection `jsonld:"to,omitempty,collapsible"`
|
||||
CC ItemCollection `jsonld:"cc,omitempty,collapsible"`
|
||||
}
|
||||
|
||||
// UpdateActivityNew initializes a new UpdateActivity message
|
||||
func UpdateActivityNew(id ObjectID, a ObjectOrLink, o ObjectOrLink) UpdateActivity {
|
||||
func UpdateActivityNew(id ObjectID, a Item, o Item) UpdateActivity {
|
||||
act := UpdateNew(id, o)
|
||||
|
||||
if a != nil {
|
||||
|
|
|
@ -43,7 +43,7 @@ func TestAcceptSerialization(t *testing.T) {
|
|||
func TestCreateActivityHTTPSerialization(t *testing.T) {
|
||||
id := a.ObjectID("test_object")
|
||||
obj := a.AcceptNew(id, nil)
|
||||
obj.Name.Set("en","Accept New")
|
||||
obj.Name.Set("en", "Accept New")
|
||||
|
||||
uri := string(a.ActivityBaseURI)
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ S2S Server: Deduplication of recipient list
|
|||
|
||||
c.RecipientsDeduplication()
|
||||
|
||||
checkDedup := func(list a.ObjectsArr, recIds *[]a.ObjectID) error {
|
||||
checkDedup := func(list a.ItemCollection, recIds *[]a.ObjectID) error {
|
||||
for _, rec := range list {
|
||||
for _, id := range *recIds {
|
||||
if *rec.GetID() == id {
|
||||
|
@ -214,7 +214,7 @@ Activity being notified about
|
|||
|
||||
c.RecipientsDeduplication()
|
||||
|
||||
checkActor := func(list a.ObjectsArr, actor a.ObjectOrLink) error {
|
||||
checkActor := func(list a.ItemCollection, actor a.Item) error {
|
||||
for _, rec := range list {
|
||||
if rec.GetID() == actor.GetID() {
|
||||
return fmt.Errorf("%T[%s] Actor of activity should not be in the recipients list", rec, *actor.GetID())
|
||||
|
@ -266,7 +266,7 @@ S2S Server: Do-not-deliver considerations
|
|||
|
||||
b.RecipientsDeduplication()
|
||||
|
||||
checkActor := func(list a.ObjectsArr, ob a.ObjectOrLink) error {
|
||||
checkActor := func(list a.ItemCollection, ob a.Item) error {
|
||||
for _, rec := range list {
|
||||
if rec.GetID() == ob.GetID() {
|
||||
return fmt.Errorf("%T[%s] of activity should not be in the recipients list", rec, *ob.GetID())
|
||||
|
|
|
@ -340,7 +340,7 @@ var allTests = tests{
|
|||
AttributedTo: a.IRI("https://littr.git/api/accounts/anonymous"),
|
||||
InReplyTo: a.IRI("https://littr.git/api/accounts/system/outbox/7ca154ff"),
|
||||
Content: a.NaturalLanguageValue{{a.NilLangRef, "<p>Hello world</p>"}},
|
||||
To: a.ObjectsArr{a.IRI("https://www.w3.org/ns/activitystreams#Public")},
|
||||
To: a.ItemCollection{a.IRI("https://www.w3.org/ns/activitystreams#Public")},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Reference in a new issue