78 lines
1.3 KiB
Go
78 lines
1.3 KiB
Go
|
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)
|
||
|
}
|