Renamed ObjectID to ID

This commit is contained in:
Marius Orcsik 2019-12-05 19:02:15 +01:00
parent 0a9945a0d9
commit b89c9ee68c
No known key found for this signature in database
GPG key ID: 889CE8E4FB2D877A
43 changed files with 216 additions and 216 deletions

View file

@ -202,7 +202,7 @@ type HasRecipients interface {
// about the kind of action being taken.
type Activity struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -328,8 +328,8 @@ func (a Activity) IsLink() bool {
return false
}
// GetID returns the ObjectID corresponding to the Activity object
func (a Activity) GetID() ObjectID {
// GetID returns the ID corresponding to the Activity object
func (a Activity) GetID() ID {
return a.ID
}
@ -507,14 +507,14 @@ type (
)
// AcceptNew initializes an Accept activity
func AcceptNew(id ObjectID, ob Item) *Accept {
func AcceptNew(id ID, ob Item) *Accept {
a := ActivityNew(id, AcceptType, ob)
o := Accept(*a)
return &o
}
// AddNew initializes an Add activity
func AddNew(id ObjectID, ob Item, trgt Item) *Add {
func AddNew(id ID, ob Item, trgt Item) *Add {
a := ActivityNew(id, AddType, ob)
o := Add(*a)
o.Target = trgt
@ -522,126 +522,126 @@ func AddNew(id ObjectID, ob Item, trgt Item) *Add {
}
// AnnounceNew initializes an Announce activity
func AnnounceNew(id ObjectID, ob Item) *Announce {
func AnnounceNew(id ID, ob Item) *Announce {
a := ActivityNew(id, AnnounceType, ob)
o := Announce(*a)
return &o
}
// BlockNew initializes a Block activity
func BlockNew(id ObjectID, ob Item) *Block {
func BlockNew(id ID, ob Item) *Block {
a := ActivityNew(id, BlockType, ob)
o := Block(*a)
return &o
}
// CreateNew initializes a Create activity
func CreateNew(id ObjectID, ob Item) *Create {
func CreateNew(id ID, ob Item) *Create {
a := ActivityNew(id, CreateType, ob)
o := Create(*a)
return &o
}
// DeleteNew initializes a Delete activity
func DeleteNew(id ObjectID, ob Item) *Delete {
func DeleteNew(id ID, ob Item) *Delete {
a := ActivityNew(id, DeleteType, ob)
o := Delete(*a)
return &o
}
// DislikeNew initializes a Dislike activity
func DislikeNew(id ObjectID, ob Item) *Dislike {
func DislikeNew(id ID, ob Item) *Dislike {
a := ActivityNew(id, DislikeType, ob)
o := Dislike(*a)
return &o
}
// FlagNew initializes a Flag activity
func FlagNew(id ObjectID, ob Item) *Flag {
func FlagNew(id ID, ob Item) *Flag {
a := ActivityNew(id, FlagType, ob)
o := Flag(*a)
return &o
}
// FollowNew initializes a Follow activity
func FollowNew(id ObjectID, ob Item) *Follow {
func FollowNew(id ID, ob Item) *Follow {
a := ActivityNew(id, FollowType, ob)
o := Follow(*a)
return &o
}
// IgnoreNew initializes an Ignore activity
func IgnoreNew(id ObjectID, ob Item) *Ignore {
func IgnoreNew(id ID, ob Item) *Ignore {
a := ActivityNew(id, IgnoreType, ob)
o := Ignore(*a)
return &o
}
// InviteNew initializes an Invite activity
func InviteNew(id ObjectID, ob Item) *Invite {
func InviteNew(id ID, ob Item) *Invite {
a := ActivityNew(id, InviteType, ob)
o := Invite(*a)
return &o
}
// JoinNew initializes a Join activity
func JoinNew(id ObjectID, ob Item) *Join {
func JoinNew(id ID, ob Item) *Join {
a := ActivityNew(id, JoinType, ob)
o := Join(*a)
return &o
}
// LeaveNew initializes a Leave activity
func LeaveNew(id ObjectID, ob Item) *Leave {
func LeaveNew(id ID, ob Item) *Leave {
a := ActivityNew(id, LeaveType, ob)
o := Leave(*a)
return &o
}
// LikeNew initializes a Like activity
func LikeNew(id ObjectID, ob Item) *Like {
func LikeNew(id ID, ob Item) *Like {
a := ActivityNew(id, LikeType, ob)
o := Like(*a)
return &o
}
// ListenNew initializes a Listen activity
func ListenNew(id ObjectID, ob Item) *Listen {
func ListenNew(id ID, ob Item) *Listen {
a := ActivityNew(id, ListenType, ob)
o := Listen(*a)
return &o
}
// MoveNew initializes a Move activity
func MoveNew(id ObjectID, ob Item) *Move {
func MoveNew(id ID, ob Item) *Move {
a := ActivityNew(id, MoveType, ob)
o := Move(*a)
return &o
}
// OfferNew initializes an Offer activity
func OfferNew(id ObjectID, ob Item) *Offer {
func OfferNew(id ID, ob Item) *Offer {
a := ActivityNew(id, OfferType, ob)
o := Offer(*a)
return &o
}
// RejectNew initializes a Reject activity
func RejectNew(id ObjectID, ob Item) *Reject {
func RejectNew(id ID, ob Item) *Reject {
a := ActivityNew(id, RejectType, ob)
o := Reject(*a)
return &o
}
// ReadNew initializes a Read activity
func ReadNew(id ObjectID, ob Item) *Read {
func ReadNew(id ID, ob Item) *Read {
a := ActivityNew(id, ReadType, ob)
o := Read(*a)
return &o
}
// RemoveNew initializes a Remove activity
func RemoveNew(id ObjectID, ob Item, trgt Item) *Remove {
func RemoveNew(id ID, ob Item, trgt Item) *Remove {
a := ActivityNew(id, RemoveType, ob)
o := Remove(*a)
o.Target = trgt
@ -649,42 +649,42 @@ func RemoveNew(id ObjectID, ob Item, trgt Item) *Remove {
}
// TentativeRejectNew initializes a TentativeReject activity
func TentativeRejectNew(id ObjectID, ob Item) *TentativeReject {
func TentativeRejectNew(id ID, ob Item) *TentativeReject {
a := ActivityNew(id, TentativeRejectType, ob)
o := TentativeReject(*a)
return &o
}
// TentativeAcceptNew initializes a TentativeAccept activity
func TentativeAcceptNew(id ObjectID, ob Item) *TentativeAccept {
func TentativeAcceptNew(id ID, ob Item) *TentativeAccept {
a := ActivityNew(id, TentativeAcceptType, ob)
o := TentativeAccept(*a)
return &o
}
// UndoNew initializes an Undo activity
func UndoNew(id ObjectID, ob Item) *Undo {
func UndoNew(id ID, ob Item) *Undo {
a := ActivityNew(id, UndoType, ob)
o := Undo(*a)
return &o
}
// UpdateNew initializes an Update activity
func UpdateNew(id ObjectID, ob Item) *Update {
func UpdateNew(id ID, ob Item) *Update {
a := ActivityNew(id, UpdateType, ob)
u := Update(*a)
return &u
}
// ViewNew initializes a View activity
func ViewNew(id ObjectID, ob Item) *View {
func ViewNew(id ID, ob Item) *View {
a := ActivityNew(id, ViewType, ob)
o := View(*a)
return &o
}
// ActivityNew initializes a basic activity
func ActivityNew(id ObjectID, typ ActivityVocabularyType, ob Item) *Activity {
func ActivityNew(id ID, typ ActivityVocabularyType, ob Item) *Activity {
if !ActivityTypes.Contains(typ) {
typ = ActivityType
}

View file

@ -6,7 +6,7 @@ import (
)
func TestActivityNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
var testType ActivityVocabularyType = "Accept"
a := ActivityNew(testValue, testType, nil)
@ -28,7 +28,7 @@ func TestActivityNew(t *testing.T) {
}
func TestAcceptNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := AcceptNew(testValue, nil)
@ -41,7 +41,7 @@ func TestAcceptNew(t *testing.T) {
}
func TestAddNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := AddNew(testValue, nil, nil)
@ -54,7 +54,7 @@ func TestAddNew(t *testing.T) {
}
func TestAnnounceNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := AnnounceNew(testValue, nil)
@ -67,7 +67,7 @@ func TestAnnounceNew(t *testing.T) {
}
func TestBlockNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := BlockNew(testValue, nil)
@ -80,7 +80,7 @@ func TestBlockNew(t *testing.T) {
}
func TestCreateNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := CreateNew(testValue, nil)
@ -93,7 +93,7 @@ func TestCreateNew(t *testing.T) {
}
func TestDeleteNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := DeleteNew(testValue, nil)
@ -106,7 +106,7 @@ func TestDeleteNew(t *testing.T) {
}
func TestDislikeNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := DislikeNew(testValue, nil)
@ -119,7 +119,7 @@ func TestDislikeNew(t *testing.T) {
}
func TestFlagNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := FlagNew(testValue, nil)
@ -132,7 +132,7 @@ func TestFlagNew(t *testing.T) {
}
func TestFollowNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := FollowNew(testValue, nil)
@ -145,7 +145,7 @@ func TestFollowNew(t *testing.T) {
}
func TestIgnoreNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := IgnoreNew(testValue, nil)
@ -158,7 +158,7 @@ func TestIgnoreNew(t *testing.T) {
}
func TestInviteNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := InviteNew(testValue, nil)
@ -171,7 +171,7 @@ func TestInviteNew(t *testing.T) {
}
func TestJoinNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := JoinNew(testValue, nil)
@ -184,7 +184,7 @@ func TestJoinNew(t *testing.T) {
}
func TestLeaveNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := LeaveNew(testValue, nil)
@ -197,7 +197,7 @@ func TestLeaveNew(t *testing.T) {
}
func TestLikeNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := LikeNew(testValue, nil)
@ -210,7 +210,7 @@ func TestLikeNew(t *testing.T) {
}
func TestListenNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := ListenNew(testValue, nil)
@ -223,7 +223,7 @@ func TestListenNew(t *testing.T) {
}
func TestMoveNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := MoveNew(testValue, nil)
@ -236,7 +236,7 @@ func TestMoveNew(t *testing.T) {
}
func TestOfferNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := OfferNew(testValue, nil)
@ -249,7 +249,7 @@ func TestOfferNew(t *testing.T) {
}
func TestRejectNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := RejectNew(testValue, nil)
@ -262,7 +262,7 @@ func TestRejectNew(t *testing.T) {
}
func TestReadNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := ReadNew(testValue, nil)
@ -275,7 +275,7 @@ func TestReadNew(t *testing.T) {
}
func TestRemoveNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := RemoveNew(testValue, nil, nil)
@ -288,7 +288,7 @@ func TestRemoveNew(t *testing.T) {
}
func TestTentativeRejectNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := TentativeRejectNew(testValue, nil)
@ -301,7 +301,7 @@ func TestTentativeRejectNew(t *testing.T) {
}
func TestTentativeAcceptNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := TentativeAcceptNew(testValue, nil)
@ -314,7 +314,7 @@ func TestTentativeAcceptNew(t *testing.T) {
}
func TestUndoNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := UndoNew(testValue, nil)
@ -327,7 +327,7 @@ func TestUndoNew(t *testing.T) {
}
func TestUpdateNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := UpdateNew(testValue, nil)
@ -340,7 +340,7 @@ func TestUpdateNew(t *testing.T) {
}
func TestViewNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := ViewNew(testValue, nil)
@ -477,7 +477,7 @@ func TestBlockRecipients(t *testing.T) {
t.Errorf("%T.BCC should have exactly 0(zero) elements, not %d", b, len(b.BCC))
}
var err error
recIds := make([]ObjectID, 0)
recIds := make([]ID, 0)
err = checkDedup(b.To, &recIds)
if err != nil {
t.Error(err)
@ -511,7 +511,7 @@ func TestCreate_Recipients(t *testing.T) {
c.Recipients()
var err error
recIds := make([]ObjectID, 0)
recIds := make([]ID, 0)
err = checkDedup(c.To, &recIds)
if err != nil {
t.Error(err)
@ -545,7 +545,7 @@ func TestDislike_Recipients(t *testing.T) {
d.Recipients()
var err error
recIds := make([]ObjectID, 0)
recIds := make([]ID, 0)
err = checkDedup(d.To, &recIds)
if err != nil {
t.Error(err)
@ -579,7 +579,7 @@ func TestLike_Recipients(t *testing.T) {
l.Recipients()
var err error
recIds := make([]ObjectID, 0)
recIds := make([]ID, 0)
err = checkDedup(l.To, &recIds)
if err != nil {
t.Error(err)
@ -613,7 +613,7 @@ func TestUpdate_Recipients(t *testing.T) {
u.Recipients()
var err error
recIds := make([]ObjectID, 0)
recIds := make([]ID, 0)
err = checkDedup(u.To, &recIds)
if err != nil {
t.Error(err)
@ -661,7 +661,7 @@ func TestActivity_IsObject(t *testing.T) {
}
}
func checkDedup(list ItemCollection, recIds *[]ObjectID) error {
func checkDedup(list ItemCollection, recIds *[]ID) error {
for _, rec := range list {
for _, id := range *recIds {
if rec.GetID() == id {
@ -688,7 +688,7 @@ func TestActivity_Recipients(t *testing.T) {
c.Recipients()
var err error
recIds := make([]ObjectID, 0)
recIds := make([]ID, 0)
err = checkDedup(c.To, &recIds)
if err != nil {
t.Error(err)
@ -722,7 +722,7 @@ func TestBlock_Recipients(t *testing.T) {
b.Recipients()
var err error
recIds := make([]ObjectID, 0)
recIds := make([]ID, 0)
err = checkDedup(b.To, &recIds)
if err != nil {
t.Error(err)
@ -928,7 +928,7 @@ func TestUpdate_UnmarshalJSON(t *testing.T) {
func TestToActivity(t *testing.T) {
var it Item
act := ActivityNew(ObjectID("test"), CreateType, nil)
act := ActivityNew(ID("test"), CreateType, nil)
it = act
a, err := ToActivity(it)

View file

@ -36,7 +36,7 @@ type CanReceiveActivities Item
// Like other ActivityStreams objects, actors have an id, which is a URI.
type Actor struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -154,8 +154,8 @@ type Actor struct {
PublicKey PublicKey `jsonld:"publicKey,omitempty"`
}
// GetID returns the ObjectID corresponding to the current Actor
func (a Actor) GetID() ObjectID {
// GetID returns the ID corresponding to the current Actor
func (a Actor) GetID() ID {
return a.ID
}
@ -186,14 +186,14 @@ func (a Actor) IsCollection() bool {
// PublicKey holds the ActivityPub compatible public key data
type PublicKey struct {
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
Owner ObjectOrLink `jsonld:"owner,omitempty"`
PublicKeyPem string `jsonld:"publicKeyPem,omitempty"`
}
func (p *PublicKey) UnmarshalJSON(data []byte) error {
if id, err := jsonparser.GetString(data, "id"); err == nil {
p.ID = ObjectID(id)
p.ID = ID(id)
} else {
return err
}
@ -227,7 +227,7 @@ type (
)
// ActorNew initializes an CanReceiveActivities type actor
func ActorNew(id ObjectID, typ ActivityVocabularyType) *Actor {
func ActorNew(id ID, typ ActivityVocabularyType) *Actor {
if !ActorTypes.Contains(typ) {
typ = ActorType
}
@ -236,9 +236,9 @@ func ActorNew(id ObjectID, typ ActivityVocabularyType) *Actor {
a.Name = NaturalLanguageValuesNew()
a.Content = NaturalLanguageValuesNew()
a.Summary = NaturalLanguageValuesNew()
in := OrderedCollectionNew(ObjectID("test-inbox"))
out := OrderedCollectionNew(ObjectID("test-outbox"))
liked := OrderedCollectionNew(ObjectID("test-liked"))
in := OrderedCollectionNew(ID("test-inbox"))
out := OrderedCollectionNew(ID("test-outbox"))
liked := OrderedCollectionNew(ID("test-liked"))
a.Inbox = in
a.Outbox = out
@ -249,35 +249,35 @@ func ActorNew(id ObjectID, typ ActivityVocabularyType) *Actor {
}
// ApplicationNew initializes an Application type actor
func ApplicationNew(id ObjectID) *Application {
func ApplicationNew(id ID) *Application {
a := ActorNew(id, ApplicationType)
o := Application(*a)
return &o
}
// GroupNew initializes a Group type actor
func GroupNew(id ObjectID) *Group {
func GroupNew(id ID) *Group {
a := ActorNew(id, GroupType)
o := Group(*a)
return &o
}
// OrganizationNew initializes an Organization type actor
func OrganizationNew(id ObjectID) *Organization {
func OrganizationNew(id ID) *Organization {
a := ActorNew(id, OrganizationType)
o := Organization(*a)
return &o
}
// PersonNew initializes a Person type actor
func PersonNew(id ObjectID) *Person {
func PersonNew(id ID) *Person {
a := ActorNew(id, PersonType)
o := Person(*a)
return &o
}
// ServiceNew initializes a Service type actor
func ServiceNew(id ObjectID) *Service {
func ServiceNew(id ID) *Service {
a := ActorNew(id, ServiceType)
o := Service(*a)
return &o

View file

@ -6,7 +6,7 @@ import (
)
func TestActorNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
var testType = ApplicationType
o := ActorNew(testValue, testType)
@ -28,7 +28,7 @@ func TestActorNew(t *testing.T) {
}
func TestPersonNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
o := PersonNew(testValue)
if o.ID != testValue {
@ -40,7 +40,7 @@ func TestPersonNew(t *testing.T) {
}
func TestApplicationNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
o := ApplicationNew(testValue)
if o.ID != testValue {
@ -52,7 +52,7 @@ func TestApplicationNew(t *testing.T) {
}
func TestGroupNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
o := GroupNew(testValue)
if o.ID != testValue {
@ -64,7 +64,7 @@ func TestGroupNew(t *testing.T) {
}
func TestOrganizationNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
o := OrganizationNew(testValue)
if o.ID != testValue {
@ -76,7 +76,7 @@ func TestOrganizationNew(t *testing.T) {
}
func TestServiceNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
o := ServiceNew(testValue)
if o.ID != testValue {
@ -103,7 +103,7 @@ func TestActor_IsObject(t *testing.T) {
func TestActor_Object(t *testing.T) {
m := ActorNew("test", ActorType)
if reflect.DeepEqual(ObjectID(""), m.GetID()) {
if reflect.DeepEqual(ID(""), m.GetID()) {
t.Errorf("%#v should not be an empty activity pub object", m.GetID())
}
}

View file

@ -27,7 +27,7 @@ type CollectionInterface interface {
// Collection is a subtype of Activity Pub Object that represents ordered or unordered sets of Activity Pub Object or Link instances.
type Collection struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -132,7 +132,7 @@ type Collection struct {
}
// CollectionNew initializes a new Collection
func CollectionNew(id ObjectID) *Collection {
func CollectionNew(id ID) *Collection {
c := Collection{ID: id, Type: CollectionType}
c.Name = NaturalLanguageValuesNew()
c.Content = NaturalLanguageValuesNew()
@ -141,7 +141,7 @@ func CollectionNew(id ObjectID) *Collection {
}
// OrderedCollectionNew initializes a new OrderedCollection
func OrderedCollectionNew(id ObjectID) *OrderedCollection {
func OrderedCollectionNew(id ID) *OrderedCollection {
o := OrderedCollection{ID: id, Type: OrderedCollectionType}
o.Name = NaturalLanguageValuesNew()
o.Content = NaturalLanguageValuesNew()
@ -149,8 +149,8 @@ func OrderedCollectionNew(id ObjectID) *OrderedCollection {
return &o
}
// GetID returns the ObjectID corresponding to the Collection object
func (c Collection) GetID() ObjectID {
// GetID returns the ID corresponding to the Collection object
func (c Collection) GetID() ID {
return c.ID
}

View file

@ -10,7 +10,7 @@ import (
// property alone. In such cases, the items within a Collection can be divided into distinct subsets or "pages".
type CollectionPage struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -120,8 +120,8 @@ type CollectionPage struct {
Prev Item `jsonld:"prev,omitempty"`
}
// GetID returns the ObjectID corresponding to the CollectionPage object
func (c CollectionPage) GetID() ObjectID {
// GetID returns the ID corresponding to the CollectionPage object
func (c CollectionPage) GetID() ID {
return c.ID
}

View file

@ -6,7 +6,7 @@ import (
)
func TestCollectionPageNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
c := CollectionNew(testValue)
p := CollectionPageNew(c)
@ -19,9 +19,9 @@ func TestCollectionPageNew(t *testing.T) {
}
func TestCollectionPage_Append(t *testing.T) {
id := ObjectID("test")
id := ID("test")
val := Object{ID: ObjectID("grrr")}
val := Object{ID: ID("grrr")}
c := CollectionNew(id)
@ -101,7 +101,7 @@ func TestCollectionPage_UnmarshalJSON(t *testing.T) {
}
func TestCollectionPage_Collection(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := CollectionNew(id)
p := CollectionPageNew(c)
@ -112,7 +112,7 @@ func TestCollectionPage_Collection(t *testing.T) {
}
func TestCollectionPage_Count(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := CollectionNew(id)
p := CollectionPageNew(c)

View file

@ -6,7 +6,7 @@ import (
)
func TestCollectionNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
c := CollectionNew(testValue)
@ -19,9 +19,9 @@ func TestCollectionNew(t *testing.T) {
}
func TestCollection_Append(t *testing.T) {
id := ObjectID("test")
id := ID("test")
val := Object{ID: ObjectID("grrr")}
val := Object{ID: ID("grrr")}
c := CollectionNew(id)
c.Append(val)
@ -35,7 +35,7 @@ func TestCollection_Append(t *testing.T) {
}
func TestCollection_Collection(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := CollectionNew(id)
@ -45,7 +45,7 @@ func TestCollection_Collection(t *testing.T) {
}
func TestCollection_GetID(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := CollectionNew(id)
@ -55,7 +55,7 @@ func TestCollection_GetID(t *testing.T) {
}
func TestCollection_GetLink(t *testing.T) {
id := ObjectID("test")
id := ID("test")
link := IRI(id)
c := CollectionNew(id)
@ -66,7 +66,7 @@ func TestCollection_GetLink(t *testing.T) {
}
func TestCollection_GetType(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := CollectionNew(id)
@ -76,7 +76,7 @@ func TestCollection_GetType(t *testing.T) {
}
func TestCollection_IsLink(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := CollectionNew(id)
@ -86,7 +86,7 @@ func TestCollection_IsLink(t *testing.T) {
}
func TestCollection_IsObject(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := CollectionNew(id)
@ -139,7 +139,7 @@ func TestCollection_UnmarshalJSON(t *testing.T) {
}
func TestCollection_Count(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := CollectionNew(id)

View file

@ -12,7 +12,7 @@ type (
// FollowingNew initializes a new Following
func FollowingNew() *Following {
id := ObjectID("following")
id := ID("following")
i := Following{ID: id, Type: CollectionType}
i.Name = NaturalLanguageValuesNew()

View file

@ -14,7 +14,7 @@ type (
// InboxNew initializes a new Inbox
func InboxNew() *OrderedCollection {
id := ObjectID("inbox")
id := ID("inbox")
i := OrderedCollection{ID: id, Type: CollectionType}
i.Name = NaturalLanguageValuesNew()

View file

@ -7,7 +7,7 @@ import (
func TestInboxNew(t *testing.T) {
i := InboxNew()
id := ObjectID("inbox")
id := ID("inbox")
if i.ID != id {
t.Errorf("%T should be initialized with %q as %T", i, id, id)
}

View file

@ -9,7 +9,7 @@ import (
// The object property is therefore inappropriate for these activities.
type IntransitiveActivity struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -156,8 +156,8 @@ func (i IntransitiveActivity) IsLink() bool {
return false
}
// GetID returns the ObjectID corresponding to the IntransitiveActivity object
func (i IntransitiveActivity) GetID() ObjectID {
// GetID returns the ID corresponding to the IntransitiveActivity object
func (i IntransitiveActivity) GetID() ID {
return i.ID
}
@ -242,7 +242,7 @@ func (i *IntransitiveActivity) UnmarshalJSON(data []byte) error {
}
// IntransitiveActivityNew initializes a intransitive activity
func IntransitiveActivityNew(id ObjectID, typ ActivityVocabularyType) *IntransitiveActivity {
func IntransitiveActivityNew(id ID, typ ActivityVocabularyType) *IntransitiveActivity {
if !IntransitiveActivityTypes.Contains(typ) {
typ = IntransitiveActivityType
}
@ -276,14 +276,14 @@ func FlattenIntransitiveActivityProperties(act *IntransitiveActivity) *Intransit
}
// ArriveNew initializes an Arrive activity
func ArriveNew(id ObjectID) *Arrive {
func ArriveNew(id ID) *Arrive {
a := IntransitiveActivityNew(id, ArriveType)
o := Arrive(*a)
return &o
}
// TravelNew initializes a Travel activity
func TravelNew(id ObjectID) *Travel {
func TravelNew(id ID) *Travel {
a := IntransitiveActivityNew(id, TravelType)
o := Travel(*a)
return &o

View file

@ -3,7 +3,7 @@ package activitypub
import "testing"
func TestIntransitiveActivityNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
var testType ActivityVocabularyType = "Arrive"
a := IntransitiveActivityNew(testValue, testType)
@ -87,7 +87,7 @@ func TestIntransitiveActivityRecipients(t *testing.T) {
t.Errorf("%T.BCC should have exactly 0(zero) elements, not %d", b, len(b.BCC))
}
var err error
recIds := make([]ObjectID, 0)
recIds := make([]ID, 0)
err = checkDedup(b.To, &recIds)
if err != nil {
t.Error(err)
@ -148,7 +148,7 @@ func TestIntransitiveActivity_Recipients(t *testing.T) {
c.Recipients()
var err error
recIds := make([]ObjectID, 0)
recIds := make([]ID, 0)
err = checkDedup(c.To, &recIds)
if err != nil {
t.Error(err)
@ -238,7 +238,7 @@ func TestIntransitiveActivity_UnmarshalJSON(t *testing.T) {
}
func TestArriveNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := ArriveNew(testValue)
@ -251,7 +251,7 @@ func TestArriveNew(t *testing.T) {
}
func TestTravelNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := TravelNew(testValue)

4
iri.go
View file

@ -48,8 +48,8 @@ func (i *IRI) UnmarshalJSON(s []byte) error {
}
// GetID
func (i IRI) GetID() ObjectID {
return ObjectID(i)
func (i IRI) GetID() ID {
return ID(i)
}
// GetType

View file

@ -20,8 +20,8 @@ func TestIRI_String(t *testing.T) {
func TestIRI_GetID(t *testing.T) {
i := IRI("http://example.com")
if id := i.GetID(); !id.IsValid() || id != ObjectID(i) {
t.Errorf("ObjectID %q (%T) should equal %q (%T)", id, id, i, ObjectID(i))
if id := i.GetID(); !id.IsValid() || id != ID(i) {
t.Errorf("ID %q (%T) should equal %q (%T)", id, id, i, ID(i))
}
}

View file

@ -3,7 +3,7 @@ package activitypub
// Item struct
type Item ObjectOrLink
const EmptyObjectID = ObjectID("")
const EmptyObjectID = ID("")
const EmptyIRI = IRI("")
// Flatten checks if Item can be flatten to an IRI or array of IRIs and returns it if so

View file

@ -8,8 +8,8 @@ import (
// ItemCollection represents an array of items
type ItemCollection []Item
// GetID returns the ObjectID corresponding to ItemCollection
func (i ItemCollection) GetID() ObjectID {
// GetID returns the ID corresponding to ItemCollection
func (i ItemCollection) GetID() ID {
return EmptyObjectID
}
@ -51,7 +51,7 @@ func (i *ItemCollection) Count() uint {
return uint(len(*i))
}
// First returns the ObjectID corresponding to ItemCollection
// First returns the ID corresponding to ItemCollection
func (i ItemCollection) First() Item {
if len(i) == 0 {
return nil

View file

@ -13,7 +13,7 @@ type (
// LikedCollection initializes a new Outbox
func LikedNew() *OrderedCollection {
id := ObjectID("liked")
id := ID("liked")
l := OrderedCollection{ID: id, Type: CollectionType}
l.Name = NaturalLanguageValuesNew()

View file

@ -7,7 +7,7 @@ import (
func TestLikedNew(t *testing.T) {
l := LikedNew()
id := ObjectID("liked")
id := ID("liked")
if l.ID != id {
t.Errorf("%T should be initialized with %q as %T", l, id, id)
}

View file

@ -13,7 +13,7 @@ type (
// LikesCollection initializes a new Outbox
func LikesNew() *Likes {
id := ObjectID("likes")
id := ID("likes")
l := Likes{ID: id, Type: CollectionType}
l.Name = NaturalLanguageValuesNew()

10
link.go
View file

@ -12,7 +12,7 @@ var validLinkTypes = [...]ActivityVocabularyType{
// Properties of the Link are properties of the reference as opposed to properties of the resource.
type Link struct {
// Provides the globally unique identifier for an APObject or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Identifies the APObject or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// A simple, human-readable, plain-text name for the object.
@ -52,7 +52,7 @@ func ValidLinkType(typ ActivityVocabularyType) bool {
}
// LinkNew initializes a new Link
func LinkNew(id ObjectID, typ ActivityVocabularyType) *Link {
func LinkNew(id ID, typ ActivityVocabularyType) *Link {
if !ValidLinkType(typ) {
typ = LinkType
}
@ -60,7 +60,7 @@ func LinkNew(id ObjectID, typ ActivityVocabularyType) *Link {
}
// MentionNew initializes a new Mention
func MentionNew(id ObjectID) *Mention {
func MentionNew(id ID) *Mention {
return &Mention{ID: id, Type: MentionType}
}
@ -79,8 +79,8 @@ func (l Link) IsCollection() bool {
return false
}
// GetID returns the ObjectID corresponding to the Link object
func (l Link) GetID() ObjectID {
// GetID returns the ID corresponding to the Link object
func (l Link) GetID() ID {
return l.ID
}

View file

@ -5,7 +5,7 @@ import (
)
func TestLinkNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
var testType ActivityVocabularyType
l := LinkNew(testValue, testType)

View file

@ -74,7 +74,7 @@ type (
// is currently happening, or has already happened
ActivityObject interface {
// GetID returns the dereferenceable ActivityStreams object id
GetID() ObjectID
GetID() ID
// GetType returns the ActivityStreams type
GetType() ActivityVocabularyType
}
@ -111,7 +111,7 @@ type (
// Vocabulary, including other Core types such as Activity, IntransitiveActivity, Collection and OrderedCollection.
type Object struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -215,8 +215,8 @@ func ObjectNew(typ ActivityVocabularyType) *Object {
return &o
}
// GetID returns the ObjectID corresponding to the current Object
func (o Object) GetID() ObjectID {
// GetID returns the ID corresponding to the current Object
func (o Object) GetID() ID {
return o.ID
}

View file

@ -2,7 +2,7 @@ package activitypub
import "strings"
// ObjectID designates an unique global identifier.
// ID designates an unique global identifier.
// All Objects in [ActivityStreams] should have unique global identifiers.
// ActivityPub extends this requirement; all objects distributed by the ActivityPub protocol MUST
// have unique global identifiers, unless they are intentionally transient
@ -14,14 +14,14 @@ import "strings"
// to that of their originating server. (Publicly facing content SHOULD use HTTPS URIs).
// 2. An ID explicitly specified as the JSON null object, which implies an anonymous object
// (a part of its parent context)
type ObjectID IRI
type ID IRI
// UnmarshalJSON
func (i *ObjectID) UnmarshalJSON(data []byte) error {
*i = ObjectID(strings.Trim(string(data), "\""))
func (i *ID) UnmarshalJSON(data []byte) error {
*i = ID(strings.Trim(string(data), "\""))
return nil
}
func (i *ObjectID) IsValid() bool {
func (i *ID) IsValid() bool {
return i != nil && len(*i) > 0
}

View file

@ -3,7 +3,7 @@ package activitypub
import "testing"
func TestObjectID_UnmarshalJSON(t *testing.T) {
o := ObjectID("")
o := ID("")
dataEmpty := []byte("")
o.UnmarshalJSON(dataEmpty)

View file

@ -6,7 +6,7 @@ import (
)
func TestObjectNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
var testType = ArticleType
o := ObjectNew(testType)
@ -216,7 +216,7 @@ func TestObject_IsObject(t *testing.T) {
func TestObjectsArr_Append(t *testing.T) {
d := make(ItemCollection, 0)
val := Object{ID: ObjectID("grrr")}
val := Object{ID: ID("grrr")}
d.Append(val)
@ -388,7 +388,7 @@ func TestLangRef_UnmarshalText(t *testing.T) {
func TestObject_GetID(t *testing.T) {
a := Object{}
testVal := "crash$"
a.ID = ObjectID(testVal)
a.ID = ID(testVal)
if string(a.GetID()) != testVal {
t.Errorf("%T should return %q, Received %q", a.GetID, testVal, a.GetID())
}
@ -397,7 +397,7 @@ func TestObject_GetID(t *testing.T) {
func TestObject_GetLink(t *testing.T) {
a := Object{}
testVal := "crash$"
a.ID = ObjectID(testVal)
a.ID = ID(testVal)
if string(a.GetLink()) != testVal {
t.Errorf("%T should return %q, Received %q", a.GetLink, testVal, a.GetLink())
}

View file

@ -10,7 +10,7 @@ import (
// collection are assumed to always be strictly ordered.
type OrderedCollection struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -124,8 +124,8 @@ func (o OrderedCollection) IsLink() bool {
return false
}
// GetID returns the ObjectID corresponding to the OrderedCollection
func (o OrderedCollection) GetID() ObjectID {
// GetID returns the ID corresponding to the OrderedCollection
func (o OrderedCollection) GetID() ID {
return o.ID
}

View file

@ -12,7 +12,7 @@ import (
// of the first item contained by the page within the OrderedCollection to which the page belongs.
type OrderedCollectionPage struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -124,8 +124,8 @@ type OrderedCollectionPage struct {
StartIndex uint `jsonld:"startIndex,omitempty"`
}
// GetID returns the ObjectID corresponding to the OrderedCollectionPage object
func (o OrderedCollectionPage) GetID() ObjectID {
// GetID returns the ID corresponding to the OrderedCollectionPage object
func (o OrderedCollectionPage) GetID() ID {
return o.ID
}

View file

@ -6,7 +6,7 @@ import (
)
func TestOrderedCollectionPageNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
c := OrderedCollectionNew(testValue)
p := OrderedCollectionPageNew(c)
@ -80,9 +80,9 @@ func TestOrderedCollectionPage_UnmarshalJSON(t *testing.T) {
}
func TestOrderedCollectionPage_Append(t *testing.T) {
id := ObjectID("test")
id := ID("test")
val := Object{ID: ObjectID("grrr")}
val := Object{ID: ID("grrr")}
c := OrderedCollectionNew(id)
@ -101,7 +101,7 @@ func TestOrderedCollectionPage_Append(t *testing.T) {
}
func TestOrderedCollectionPage_Collection(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := OrderedCollectionNew(id)
p := OrderedCollectionPageNew(c)

View file

@ -6,7 +6,7 @@ import (
)
func TestOrderedCollectionNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
c := OrderedCollectionNew(testValue)
@ -19,9 +19,9 @@ func TestOrderedCollectionNew(t *testing.T) {
}
func Test_OrderedCollection_Append(t *testing.T) {
id := ObjectID("test")
id := ID("test")
val := Object{ID: ObjectID("grrr")}
val := Object{ID: ID("grrr")}
c := OrderedCollectionNew(id)
c.Append(val)
@ -35,9 +35,9 @@ func Test_OrderedCollection_Append(t *testing.T) {
}
func TestOrderedCollection_Append(t *testing.T) {
id := ObjectID("test")
id := ID("test")
val := Object{ID: ObjectID("grrr")}
val := Object{ID: ID("grrr")}
c := OrderedCollectionNew(id)
@ -56,7 +56,7 @@ func TestOrderedCollection_Append(t *testing.T) {
}
func TestOrderedCollection_Collection(t *testing.T) {
id := ObjectID("test")
id := ID("test")
o := OrderedCollectionNew(id)
@ -66,7 +66,7 @@ func TestOrderedCollection_Collection(t *testing.T) {
}
func TestOrderedCollection_GetID(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := OrderedCollectionNew(id)
@ -76,7 +76,7 @@ func TestOrderedCollection_GetID(t *testing.T) {
}
func TestOrderedCollection_GetLink(t *testing.T) {
id := ObjectID("test")
id := ID("test")
link := IRI(id)
c := OrderedCollectionNew(id)
@ -87,7 +87,7 @@ func TestOrderedCollection_GetLink(t *testing.T) {
}
func TestOrderedCollection_GetType(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := OrderedCollectionNew(id)
@ -97,7 +97,7 @@ func TestOrderedCollection_GetType(t *testing.T) {
}
func TestOrderedCollection_IsLink(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := OrderedCollectionNew(id)
@ -107,7 +107,7 @@ func TestOrderedCollection_IsLink(t *testing.T) {
}
func TestOrderedCollection_IsObject(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := OrderedCollectionNew(id)
@ -160,7 +160,7 @@ func TestOrderedCollection_UnmarshalJSON(t *testing.T) {
}
func TestOrderedCollection_Count(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := OrderedCollectionNew(id)
@ -184,7 +184,7 @@ func TestOrderedCollection_Count(t *testing.T) {
}
func TestOrderedCollectionPage_Count(t *testing.T) {
id := ObjectID("test")
id := ID("test")
c := OrderedCollectionNew(id)
p := OrderedCollectionPageNew(c)

View file

@ -12,7 +12,7 @@ type (
// OutboxNew initializes a new Outbox
func OutboxNew() *Outbox {
id := ObjectID("outbox")
id := ID("outbox")
i := Outbox{ID: id, Type: OrderedCollectionType}
i.Name = NaturalLanguageValuesNew()

View file

@ -8,7 +8,7 @@ import (
func TestOutboxNew(t *testing.T) {
o := OutboxNew()
id := ObjectID("outbox")
id := ID("outbox")
if o.ID != id {
t.Errorf("%T should be initialized with %q as %T", o, id, id)
}
@ -31,7 +31,7 @@ func TestOutboxStream_GetID(t *testing.T) {
if o.GetID() != "" {
t.Errorf("%T should be initialized with empty %T", o, o.GetID())
}
id := ObjectID("test_out_stream")
id := ID("test_out_stream")
o.ID = id
if o.GetID() != id {
t.Errorf("%T should have %T as %q", o, id, id)
@ -54,7 +54,7 @@ func TestOutboxStream_GetType(t *testing.T) {
func TestOutboxStream_Append(t *testing.T) {
o := OutboxStream{}
val := Object{ID: ObjectID("grrr")}
val := Object{ID: ID("grrr")}
o.Append(val)
if !reflect.DeepEqual(o.OrderedItems[0], val) {
@ -65,7 +65,7 @@ func TestOutboxStream_Append(t *testing.T) {
func TestOutbox_Append(t *testing.T) {
o := OutboxNew()
val := Object{ID: ObjectID("grrr")}
val := Object{ID: ID("grrr")}
o.Append(val)
if !reflect.DeepEqual(o.OrderedItems[0], val) {

View file

@ -9,7 +9,7 @@ import (
// Place represents a logical or physical location. See 5.3 Representing Places for additional information.
type Place struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -146,7 +146,7 @@ func (p Place) GetType() ActivityVocabularyType {
}
// GetID returns the ID corresponding to the current Place
func (p Place) GetID() ObjectID {
func (p Place) GetID() ID {
return p.ID
}

View file

@ -11,7 +11,7 @@ import (
// The describes property is used to reference the object being described by the profile.
type Profile struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -132,7 +132,7 @@ func (p Profile) GetType() ActivityVocabularyType {
}
// GetID returns the ID corresponding to the current Profile
func (p Profile) GetID() ObjectID {
func (p Profile) GetID() ID {
return p.ID
}

View file

@ -12,7 +12,7 @@ import (
// but a Question object must not have both properties.
type Question struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -131,8 +131,8 @@ type Question struct {
Closed bool `jsonld:"closed,omitempty"`
}
// GetID returns the ObjectID corresponding to the Question object
func (q Question) GetID() ObjectID {
// GetID returns the ID corresponding to the Question object
func (q Question) GetID() ID {
return q.ID
}
@ -230,7 +230,7 @@ func (q *Question) UnmarshalJSON(data []byte) error {
}
// QuestionNew initializes a Question activity
func QuestionNew(id ObjectID) *Question {
func QuestionNew(id ID) *Question {
q := Question{ID: id, Type: QuestionType}
q.Name = NaturalLanguageValuesNew()
q.Content = NaturalLanguageValuesNew()

View file

@ -3,7 +3,7 @@ package activitypub
import "testing"
func TestQuestionNew(t *testing.T) {
var testValue = ObjectID("test")
var testValue = ID("test")
a := QuestionNew(testValue)

View file

@ -15,7 +15,7 @@ import (
// and object identifies the object.
type Relationship struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -142,7 +142,7 @@ func (r Relationship) GetType() ActivityVocabularyType {
}
// GetID returns the ID corresponding to the current Relationship
func (r Relationship) GetID() ObjectID {
func (r Relationship) GetID() ID {
return r.ID
}

View file

@ -13,7 +13,7 @@ type (
// SharesNew initializes a new Shares
func SharesNew() *Shares {
id := ObjectID("Shares")
id := ID("Shares")
i := Shares{ID: id, Type: CollectionType}
i.Name = NaturalLanguageValuesNew()

View file

@ -41,7 +41,7 @@ func TestAcceptSerialization(t *testing.T) {
}
func TestCreateActivityHTTPSerialization(t *testing.T) {
id := pub.ObjectID("test_object")
id := pub.ID("test_object")
obj := pub.AcceptNew(id, nil)
obj.Name.Set("en", "Accept New")

View file

@ -153,7 +153,7 @@ S2S Server: Deduplication of recipient list
c.Recipients()
checkDedup := func(list pub.ItemCollection, recIds *[]pub.ObjectID) error {
checkDedup := func(list pub.ItemCollection, recIds *[]pub.ID) error {
for _, rec := range list {
for _, id := range *recIds {
if rec.GetID() == id {
@ -166,7 +166,7 @@ S2S Server: Deduplication of recipient list
}
var err error
recIds := make([]pub.ObjectID, 0)
recIds := make([]pub.ID, 0)
err = checkDedup(c.To, &recIds)
if err != nil {
t.Error(err)

View file

@ -233,7 +233,7 @@ var allTests = testMaps{
blank: &pub.Object{},
result: &pub.Object{
Type: pub.ObjectType,
ID: pub.ObjectID("http://www.test.example/object/1"),
ID: pub.ID("http://www.test.example/object/1"),
Name: pub.NaturalLanguageValues{{
pub.NilLangRef, "A Simple, non-specific object",
}},
@ -244,7 +244,7 @@ var allTests = testMaps{
blank: &pub.Object{},
result: &pub.Object{
Type: pub.ObjectType,
ID: pub.ObjectID("http://www.test.example/object/1"),
ID: pub.ID("http://www.test.example/object/1"),
Name: pub.NaturalLanguageValues{{
pub.NilLangRef, "A Simple, non-specific object",
}},
@ -254,14 +254,14 @@ var allTests = testMaps{
pub.NilLangRef, "#my_tag",
}},
Type: pub.MentionType,
ID: pub.ObjectID("http://example.com/tag/my_tag"),
ID: pub.ID("http://example.com/tag/my_tag"),
},
&pub.Mention{
Name: pub.NaturalLanguageValues{{
pub.NilLangRef, "@ana",
}},
Type: pub.MentionType,
ID: pub.ObjectID("http://example.com/users/ana"),
ID: pub.ID("http://example.com/users/ana"),
},
},
},
@ -271,14 +271,14 @@ var allTests = testMaps{
blank: &pub.Object{},
result: &pub.Object{
Type: pub.ObjectType,
ID: pub.ObjectID("http://www.test.example/object/1"),
ID: pub.ID("http://www.test.example/object/1"),
Replies: &pub.Collection{
ID: pub.ObjectID("http://www.test.example/object/1/replies"),
ID: pub.ID("http://www.test.example/object/1/replies"),
Type: pub.CollectionType,
TotalItems: 1,
Items: pub.ItemCollection{
&pub.Object{
ID: pub.ObjectID("http://www.test.example/object/1/replies/2"),
ID: pub.ID("http://www.test.example/object/1/replies/2"),
Type: pub.ArticleType,
Name: pub.NaturalLanguageValues{{
pub.NilLangRef, "Example title",
@ -310,7 +310,7 @@ var allTests = testMaps{
expected: true,
blank: &pub.Person{},
result: &pub.Person{
ID: pub.ObjectID("http://example.com/accounts/ana"),
ID: pub.ID("http://example.com/accounts/ana"),
Type: pub.PersonType,
Name: pub.NaturalLanguageValues{{pub.NilLangRef, "ana"}},
PreferredUsername: pub.NaturalLanguageValues{{pub.NilLangRef, "ana"}},
@ -326,13 +326,13 @@ var allTests = testMaps{
expected: true,
blank: &pub.OrderedCollection{},
result: &pub.OrderedCollection{
ID: pub.ObjectID("http://example.com/outbox"),
ID: pub.ID("http://example.com/outbox"),
Type: pub.OrderedCollectionType,
URL: pub.IRI("http://example.com/outbox"),
TotalItems: 1,
OrderedItems: pub.ItemCollection{
&pub.Object{
ID: pub.ObjectID("http://example.com/outbox/53c6fb47"),
ID: pub.ID("http://example.com/outbox/53c6fb47"),
Type: pub.ArticleType,
Name: pub.NaturalLanguageValues{{pub.NilLangRef, "Example title"}},
Content: pub.NaturalLanguageValues{{pub.NilLangRef, "Example content!"}},
@ -352,14 +352,14 @@ var allTests = testMaps{
PartOf: pub.IRI("http://example.com/outbox"),
Next: pub.IRI("http://example.com/outbox?page=3"),
Prev: pub.IRI("http://example.com/outbox?page=1"),
ID: pub.ObjectID("http://example.com/outbox?page=2"),
ID: pub.ID("http://example.com/outbox?page=2"),
Type: pub.OrderedCollectionPageType,
URL: pub.IRI("http://example.com/outbox?page=2"),
Current: pub.IRI("http://example.com/outbox?page=2"),
TotalItems: 1,
OrderedItems: pub.ItemCollection{
&pub.Object{
ID: pub.ObjectID("http://example.com/outbox/53c6fb47"),
ID: pub.ID("http://example.com/outbox/53c6fb47"),
Type: pub.ArticleType,
Name: pub.NaturalLanguageValues{{pub.NilLangRef, "Example title"}},
Content: pub.NaturalLanguageValues{{pub.NilLangRef, "Example content!"}},
@ -416,7 +416,7 @@ var allTests = testMaps{
},
&pub.Article{
Type: pub.ArticleType,
ID: pub.ObjectID("http://www.test.example/article/1"),
ID: pub.ID("http://www.test.example/article/1"),
Name: pub.NaturalLanguageValues{
{
pub.NilLangRef,
@ -436,7 +436,7 @@ var allTests = testMaps{
blank: &pub.Object{},
result: &pub.Object{
Type: pub.ObjectType,
ID: pub.ObjectID("http://www.test.example/object/1"),
ID: pub.ID("http://www.test.example/object/1"),
To: pub.ItemCollection{
pub.IRI("https://www.w3.org/ns/activitystreams#Public"),
},
@ -457,7 +457,7 @@ var allTests = testMaps{
blank: &pub.Article{},
result: &pub.Article{
Type: pub.ArticleType,
ID: pub.ObjectID("http://www.test.example/article/1"),
ID: pub.ID("http://www.test.example/article/1"),
Name: pub.NaturalLanguageValues{
{
pub.NilLangRef,

View file

@ -11,7 +11,7 @@ import (
// but it has been deleted.
type Tombstone struct {
// ID provides the globally unique identifier for anActivity Pub Object or Link.
ID ObjectID `jsonld:"id,omitempty"`
ID ID `jsonld:"id,omitempty"`
// Type identifies the Activity Pub Object or Link type. Multiple values may be specified.
Type ActivityVocabularyType `jsonld:"type,omitempty"`
// Name a simple, human-readable, plain-text name for the object.
@ -134,7 +134,7 @@ func (t Tombstone) GetType() ActivityVocabularyType {
}
// GetID returns the ID corresponding to the current Tombstone
func (t Tombstone) GetID() ObjectID {
func (t Tombstone) GetID() ID {
return t.ID
}

View file

@ -25,12 +25,12 @@ var ItemTyperFunc TyperFn
// for a specific ActivityVocabularyType
type TyperFn func(ActivityVocabularyType) (Item, error)
func JSONGetObjectID(data []byte) ObjectID {
func JSONGetObjectID(data []byte) ID {
i, err := jsonparser.GetString(data, "id")
if err != nil {
return ObjectID("")
return ID("")
}
return ObjectID(i)
return ID(i)
}
func JSONGetType(data []byte) ActivityVocabularyType {