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

78 lines
1.3 KiB
Go
Raw Normal View History

2017-09-11 20:45:57 +00:00
package activitypub
type ActorCollection = []Actor
type Actor struct {
BaseObject
Inbox InboxStream
Outbox OutboxStream
Following FollowingCollection
Followers FollowersCollection
Liked LikedCollection
PreferredUsername NaturalLanguageValue
Url Url
Summary NaturalLanguageValue
Icon Url
/*/
streams
preferredUsername
endpoints {
uploadMedia
oauthAuthorizationEndpoint
oauthTokenEndpoint
provideClientKey
signClientKey
sharedInbox
}
/**/
}
var validActorTypes = [...]string{
ApplicationType,
GroupType,
OrganizationType,
PersonType,
ServiceType,
}
func ValidActorType(_type string) bool {
for _, v := range validActorTypes {
if v == _type {
return true
}
}
return false
}
func ActorNew(id ObjectId, _type string) Actor {
if !ValidActorType(_type) {
_type = ActorType
}
o := BaseObject{Id: id, Type: _type}
return Actor{BaseObject: o}
}
func ApplicationNew(id ObjectId) Actor {
return ActorNew(id, ApplicationType)
}
func GroupNew(id ObjectId) Actor {
return ActorNew(id, GroupType)
}
func OrganizationNew(id ObjectId) Actor {
return ActorNew(id, OrganizationType)
}
func PersonNew(id ObjectId) Actor {
return ActorNew(id, PersonType)
}
func ServiceNew(id ObjectId) Actor {
return ActorNew(id, ServiceType)
}