This repository has been archived on 2022-11-27. You can view files and clone it, but cannot push or open issues or pull requests.
activitypub/actors.go

91 lines
2.2 KiB
Go
Raw Normal View History

package activitystreams
2017-09-11 20:45:57 +00:00
2018-03-24 16:54:55 +00:00
// Actor Types
const (
ApplicationType ActivityVocabularyType = "Application"
GroupType ActivityVocabularyType = "Group"
OrganizationType ActivityVocabularyType = "Organization"
PersonType ActivityVocabularyType = "Person"
ServiceType ActivityVocabularyType = "Service"
)
2019-05-16 09:08:27 +00:00
var ActorTypes = ActivityVocabularyTypes{
ApplicationType,
GroupType,
OrganizationType,
PersonType,
ServiceType,
}
2017-09-11 20:45:57 +00:00
// 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.
2018-07-18 15:39:27 +00:00
// Actors are retrieved like any other Object in ActivityPub.
// Like other ActivityStreams objects, actors have an id, which is a URI.
type Actor Item
2017-09-16 17:53:11 +00:00
type (
2018-03-24 16:54:55 +00:00
// Application describes a software application.
Application = Object
2018-03-24 16:54:55 +00:00
// Group represents a formal or informal collective of Actors.
Group = Object
2018-03-24 16:54:55 +00:00
// Organization represents an organization.
Organization = Object
2018-03-24 16:54:55 +00:00
// Person represents an individual person.
Person = Object
2018-03-24 16:54:55 +00:00
// Service represents a service of any kind.
Service = Object
2017-09-16 17:53:11 +00:00
)
2018-03-25 18:54:51 +00:00
// ActorNew initializes an Actor type actor
func ActorNew(id ObjectID, typ ActivityVocabularyType) *Object {
2019-05-16 09:08:27 +00:00
if !ActorTypes.Contains(typ) {
typ = ActorType
2017-09-11 20:45:57 +00:00
}
a := Object{ID: id, Type: typ}
a.Name = NaturalLanguageValuesNew()
a.Content = NaturalLanguageValuesNew()
a.Summary = NaturalLanguageValuesNew()
return &a
2017-09-11 20:45:57 +00:00
}
2018-03-25 18:54:51 +00:00
// ApplicationNew initializes an Application type actor
2018-03-27 13:06:06 +00:00
func ApplicationNew(id ObjectID) *Application {
a := ActorNew(id, ApplicationType)
o := Application(*a)
return &o
2017-09-11 20:45:57 +00:00
}
2018-03-25 18:54:51 +00:00
// GroupNew initializes a Group type actor
2018-03-27 13:06:06 +00:00
func GroupNew(id ObjectID) *Group {
a := ActorNew(id, GroupType)
o := Group(*a)
return &o
2017-09-11 20:45:57 +00:00
}
2018-03-25 18:54:51 +00:00
// OrganizationNew initializes an Organization type actor
2018-03-27 13:06:06 +00:00
func OrganizationNew(id ObjectID) *Organization {
a := ActorNew(id, OrganizationType)
o := Organization(*a)
return &o
2017-09-11 20:45:57 +00:00
}
2018-03-25 18:54:51 +00:00
// PersonNew initializes a Person type actor
2018-03-27 13:06:06 +00:00
func PersonNew(id ObjectID) *Person {
a := ActorNew(id, PersonType)
o := Person(*a)
return &o
2017-09-11 20:45:57 +00:00
}
2018-03-25 18:54:51 +00:00
// ServiceNew initializes a Service type actor
2018-03-27 13:06:06 +00:00
func ServiceNew(id ObjectID) *Service {
a := ActorNew(id, ServiceType)
o := Service(*a)
return &o
2017-09-11 20:45:57 +00:00
}