Changes
7 changed files (+74/-48)
-
-
@@ -39,8 +39,6 @@ const (ViewType ActivityVocabularyType = "View" ) type ActivityVocabularyTypes []ActivityVocabularyType func (a ActivityVocabularyTypes) Contains(typ ActivityVocabularyType) bool { for _, v := range a { if strings.ToLower(string(v)) == strings.ToLower(string(typ)) {
-
-
-
@@ -14,7 +14,7 @@ const (// SecurityContextURI the URI for the secruity namespace (for an Actor's PublicKey) SecurityContextURI = IRI("https://w3id.org/security/v1") // PublicNs is the reference to the Public entity in the Acitivystreams namespace PublicNS = IRI(ActivityBaseURI + "#Public") PublicNS = ActivityBaseURI + "#Public" ) var JsonLDContext = []IRI{
-
-
-
@@ -1,6 +1,7 @@package activitypub var validLinkTypes = [...]ActivityVocabularyType{ var LinkTypes = ActivityVocabularyTypes{ LinkType, MentionType, }
-
@@ -41,19 +42,9 @@ type Link struct {// Mention is a specialized Link that represents an @mention. type Mention = Link // ValidLinkType validates a type against the valid link types func ValidLinkType(typ ActivityVocabularyType) bool { for _, v := range validLinkTypes { if v == typ { return true } } return false } // LinkNew initializes a new Link func LinkNew(id ID, typ ActivityVocabularyType) *Link { if !ValidLinkType(typ) { if !LinkTypes.Contains(typ) { typ = LinkType } return &Link{ID: id, Type: typ}
-
@@ -66,7 +57,7 @@ func MentionNew(id ID) *Mention {// IsLink validates if current Link is a Link func (l Link) IsLink() bool { return l.Type == LinkType || ValidLinkType(l.Type) return l.Type == LinkType || LinkTypes.Contains(l.Type) } // IsObject validates if current Link is an GetID
-
-
-
@@ -18,22 +18,6 @@ func TestLinkNew(t *testing.T) {} } func TestValidLinkType(t *testing.T) { var invalidType ActivityVocabularyType = "RandomType" if ValidLinkType(LinkType) { t.Errorf("Generic Link Type '%v' should not be valid", LinkType) } if ValidLinkType(invalidType) { t.Errorf("Link Type '%v' should not be valid", invalidType) } for _, validType := range validLinkTypes { if !ValidLinkType(validType) { t.Errorf("Link Type '%v' should be valid", validType) } } } func TestLink_IsLink(t *testing.T) { l := LinkNew("test", LinkType) if !l.IsLink() {
-
-
-
@@ -19,7 +19,7 @@ const (CollectionPageType ActivityVocabularyType = "CollectionPage" OrderedCollectionPageType ActivityVocabularyType = "OrderedCollectionPage" // Activity Pub Object Types // ActivityPub Object Types ArticleType ActivityVocabularyType = "Article" AudioType ActivityVocabularyType = "Audio" DocumentType ActivityVocabularyType = "Document"
-
@@ -37,21 +37,13 @@ const (MentionType ActivityVocabularyType = "Mention" ) var GenericObjectTypes = ActivityVocabularyTypes{ var GenericTypes = ActivityVocabularyTypes{ ActivityType, IntransitiveActivityType, ObjectType, ActorType, CollectionType, OrderedCollectionType, } var GenericLinkTypes = ActivityVocabularyTypes{ LinkType, } var GenericTypes = append(GenericObjectTypes[:], GenericLinkTypes[:]...) var ObjectTypes = ActivityVocabularyTypes{ ArticleType, AudioType,
-
@@ -66,10 +58,6 @@ var ObjectTypes = ActivityVocabularyTypes{TombstoneType, VideoType, } var obTypes = append(ActorTypes, ObjectTypes...) // Types contains all valid types in the ActivityPub vocab var Types = append(ActivityTypes, obTypes...) type ( // ActivityVocabularyType is the data type for an Activity type object
-
-
-
@@ -168,8 +168,8 @@ func TestActivityVocabularyTypes_Contains(t *testing.T) {} } { for _, validType := range GenericObjectTypes { if !GenericObjectTypes.Contains(validType) { for _, validType := range GenericTypes { if !GenericTypes.Contains(validType) { t.Errorf("Generic Type '%v' should be valid", validType) } }
-
-
types.go (new)
-
@@ -0,0 +1,65 @@package activitypub type ActivityVocabularyTypes []ActivityVocabularyType // Types contains all valid types in the ActivityPub vocab var Types = ActivityVocabularyTypes{ LinkType, MentionType, ArticleType, AudioType, DocumentType, EventType, ImageType, NoteType, PageType, PlaceType, ProfileType, RelationshipType, TombstoneType, VideoType, QuestionType, CollectionType, OrderedCollectionType, CollectionPageType, OrderedCollectionPageType, ApplicationType, GroupType, OrganizationType, PersonType, ServiceType, AcceptType, AddType, AnnounceType, BlockType, CreateType, DeleteType, DislikeType, FlagType, FollowType, IgnoreType, InviteType, JoinType, LeaveType, LikeType, ListenType, MoveType, OfferType, RejectType, ReadType, RemoveType, TentativeRejectType, TentativeAcceptType, UndoType, UpdateType, ViewType, ArriveType, TravelType, QuestionType, }
-