Using go1.18 and adding some interface types that can be used for generics
This commit is contained in:
commit
93a9596849
3
Makefile
3
Makefile
|
@ -1,4 +1,5 @@
|
|||
TEST := go test
|
||||
GO ?= go
|
||||
TEST := $(GO) test
|
||||
TEST_FLAGS ?= -v
|
||||
TEST_TARGET ?= .
|
||||
GO111MODULE = on
|
||||
|
|
|
@ -199,6 +199,10 @@ type HasRecipients interface {
|
|||
Clean()
|
||||
}
|
||||
|
||||
type Activities interface {
|
||||
Activity
|
||||
}
|
||||
|
||||
// Activity is a subtype of Object that describes some form of action that may happen,
|
||||
// is currently happening, or has already happened.
|
||||
// The Activity type itself serves as an abstract base type for all types of activities.
|
||||
|
|
4
actor.go
4
actor.go
|
@ -36,6 +36,10 @@ var ActorTypes = ActivityVocabularyTypes{
|
|||
// Like other ActivityStreams objects, actors have an id, which is a URI.
|
||||
type CanReceiveActivities Item
|
||||
|
||||
type Actors interface {
|
||||
Actor
|
||||
}
|
||||
|
||||
// Actor is generally one of the ActivityStreams actor Types, but they don't have to be.
|
||||
// For example, a Profile object might be used as an actor, or a type from an ActivityStreams extension.
|
||||
// Actors are retrieved like any other Object in ActivityPub.
|
||||
|
|
|
@ -21,6 +21,10 @@ var CollectionTypes = ActivityVocabularyTypes{
|
|||
OrderedCollectionPageType,
|
||||
}
|
||||
|
||||
type Collections interface {
|
||||
Collection | CollectionPage | OrderedCollection | OrderedCollectionPage | ItemCollection
|
||||
}
|
||||
|
||||
type CollectionInterface interface {
|
||||
ObjectOrLink
|
||||
Collection() ItemCollection
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
|||
module github.com/go-ap/activitypub
|
||||
|
||||
go 1.13
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20200411073322-f0bcc40f0bf2
|
||||
|
|
|
@ -11,6 +11,10 @@ import (
|
|||
"github.com/valyala/fastjson"
|
||||
)
|
||||
|
||||
type IntransitiveActivities interface {
|
||||
IntransitiveActivity | Question
|
||||
}
|
||||
|
||||
// IntransitiveActivity Instances of IntransitiveActivity are a subtype of Activity representing intransitive actions.
|
||||
// The object property is therefore inappropriate for these activities.
|
||||
type IntransitiveActivity struct {
|
||||
|
|
4
link.go
4
link.go
|
@ -12,6 +12,10 @@ var LinkTypes = ActivityVocabularyTypes{
|
|||
MentionType,
|
||||
}
|
||||
|
||||
type Links interface {
|
||||
Link | IRI
|
||||
}
|
||||
|
||||
// A Link is an indirect, qualified reference to a resource identified by a URL.
|
||||
// The fundamental model for links is established by [ RFC5988].
|
||||
// Many of the properties defined by the Activity Vocabulary allow values that are either instances of APObject or Link.
|
||||
|
|
10
object.go
10
object.go
|
@ -133,6 +133,14 @@ func (a ActivityVocabularyType) MarshalBinary() ([]byte, error) {
|
|||
return a.GobEncode()
|
||||
}
|
||||
|
||||
type Objects interface {
|
||||
Object | Tombstone | Place | Profile | Relationship |
|
||||
Activities |
|
||||
IntransitiveActivities |
|
||||
Collections |
|
||||
IRI
|
||||
}
|
||||
|
||||
// Object describes an ActivityPub object of any kind.
|
||||
// It serves as the base type for most of the other kinds of objects defined in the Activity
|
||||
// Vocabulary, including other Core types such as Activity, IntransitiveActivity, Collection and OrderedCollection.
|
||||
|
@ -203,7 +211,7 @@ type Object struct {
|
|||
// Updated the date and time at which the object was updated
|
||||
Updated time.Time `jsonld:"updated,omitempty"`
|
||||
// URL identifies one or more links to representations of the object
|
||||
URL Item `jsonld:"url,omitempty"`
|
||||
URL LinkOrIRI `jsonld:"url,omitempty"`
|
||||
// To identifies an entity considered to be part of the public primary audience of an Activity Pub Object
|
||||
To ItemCollection `jsonld:"to,omitempty"`
|
||||
// Bto identifies anActivity Pub Object that is part of the private primary audience of this Activity Pub Object.
|
||||
|
|
Reference in a new issue