Changes
19 changed files (+87/-63)
-
-
@@ -716,7 +716,7 @@ func ActivityNew(id ID, typ ActivityVocabularyType, ob Item) *Activity {return &a } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (a *Activity) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
@@ -753,7 +753,7 @@ func ToActivity(it Item) (*Activity, error) {return nil, errors.New("unable to convert activity") } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (a Activity) MarshalJSON() ([]byte, error) { b := make([]byte, 0) write(&b, '{')
-
-
-
@@ -419,7 +419,7 @@ type Endpoints struct {SharedInbox Item `jsonld:"sharedInbox,omitempty"` } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (e *Endpoints) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
@@ -435,7 +435,7 @@ func (e *Endpoints) UnmarshalJSON(data []byte) error {return nil } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (e Endpoints) MarshalJSON() ([]byte, error) { b := make([]byte, 0) notEmpty := false
-
-
-
@@ -230,7 +230,7 @@ func (c Collection) Contains(r Item) bool {return false } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (c *Collection) UnmarshalJSON(data []byte) error { par := fastjson.Parser{} val, err := par.ParseBytes(data)
-
@@ -240,7 +240,7 @@ func (c *Collection) UnmarshalJSON(data []byte) error {return loadCollection(val, c) } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (c Collection) MarshalJSON() ([]byte, error) { b := make([]byte, 0) notEmpty := false
-
-
-
@@ -185,7 +185,7 @@ func (c CollectionPage) Contains(r Item) bool {return false } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (c *CollectionPage) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
@@ -195,7 +195,7 @@ func (c *CollectionPage) UnmarshalJSON(data []byte) error {return loadCollectionPage(val, c) } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (c CollectionPage) MarshalJSON() ([]byte, error) { b := make([]byte, 0) notEmpty := false
-
-
-
@@ -3,7 +3,6 @@ package activitypubimport ( "bytes" "encoding/gob" "errors" "fmt" "io" "reflect"
-
@@ -66,7 +65,7 @@ func (e *gobEncoder) writeDurationGobProp(p string, d time.Duration) bool {} func writeObjectGobValue(buf io.Writer, o *Object) (int, error) { return 0, errors.New(fmt.Sprintf("writeObjectGobValue is not implemented for %T", *o)) return 0, fmt.Errorf("writeObjectGobValue is not implemented for %T", *o) } /*
-
-
-
@@ -354,7 +354,7 @@ func writeLinkJSONValue(b *[]byte, l Link) (notEmpty bool) {return notEmpty } // MarshalJSON wraps the jsonld.Marshal function // MarshalJSON represents just a wrapper for the jsonld.Marshal function func MarshalJSON(it Item) ([]byte, error) { return jsonld.Marshal(it) }
-
-
-
@@ -4,20 +4,43 @@ import ("fmt" ) // WithLinkFn represents a function type that can be used as a parameter for OnLink helper function type WithLinkFn func(*Link) error // WithObjectFn represents a function type that can be used as a parameter for OnObject helper function type WithObjectFn func(*Object) error // WithActivityFn represents a function type that can be used as a parameter for OnActivity helper function type WithActivityFn func(*Activity) error // WithIntransitiveActivityFn represents a function type that can be used as a parameter for OnIntransitiveActivity helper function type WithIntransitiveActivityFn func(*IntransitiveActivity) error // WithQuestionFn represents a function type that can be used as a parameter for OnQuestion helper function type WithQuestionFn func(*Question) error // WithActorFn represents a function type that can be used as a parameter for OnActor helper function type WithActorFn func(*Actor) error // WithCollectionInterfaceFn represents a function type that can be used as a parameter for OnCollectionIntf helper function type WithCollectionInterfaceFn func(CollectionInterface) error // WithCollectionFn represents a function type that can be used as a parameter for OnCollection helper function type WithCollectionFn func(*Collection) error // WithCollectionPageFn represents a function type that can be used as a parameter for OnCollectionPage helper function type WithCollectionPageFn func(*CollectionPage) error // WithOrderedCollectionFn represents a function type that can be used as a parameter for OnOrderedCollection helper function type WithOrderedCollectionFn func(*OrderedCollection) error // WithOrderedCollectionPageFn represents a function type that can be used as a parameter for OnOrderedCollectionPage helper function type WithOrderedCollectionPageFn func(*OrderedCollectionPage) error // WithItemCollectionFn represents a function type that can be used as a parameter for OnItemCollection helper function type WithItemCollectionFn func(*ItemCollection) error // OnLink // OnLink calls function fn on it Item if it can be asserted to type Link func OnLink(it Item, fn WithLinkFn) error { if it == nil { return nil
-
@@ -29,7 +52,7 @@ func OnLink(it Item, fn WithLinkFn) error {return fn(ob) } // OnObject // OnObject calls function fn on it Item if it can be asserted to type Object func OnObject(it Item, fn WithObjectFn) error { if it == nil { return nil
-
@@ -51,7 +74,7 @@ func OnObject(it Item, fn WithObjectFn) error {return fn(ob) } // OnActivity // OnActivity calls function fn on it Item if it can be asserted to type Activity func OnActivity(it Item, fn WithActivityFn) error { if it == nil { return nil
-
@@ -73,7 +96,7 @@ func OnActivity(it Item, fn WithActivityFn) error {return fn(act) } // OnIntransitiveActivity // OnIntransitiveActivity calls function fn on it Item if it can be asserted to type IntransitiveActivity func OnIntransitiveActivity(it Item, fn WithIntransitiveActivityFn) error { if it == nil { return nil
-
@@ -95,7 +118,7 @@ func OnIntransitiveActivity(it Item, fn WithIntransitiveActivityFn) error {return fn(act) } // OnQuestion // OnQuestion calls function fn on it Item if it can be asserted to type Question func OnQuestion(it Item, fn WithQuestionFn) error { if it == nil { return nil
-
@@ -117,7 +140,7 @@ func OnQuestion(it Item, fn WithQuestionFn) error {return fn(act) } // OnActor // OnActor calls function fn on it Item if it can be asserted to type Actor func OnActor(it Item, fn WithActorFn) error { if it == nil { return nil
-
@@ -139,7 +162,7 @@ func OnActor(it Item, fn WithActorFn) error {return fn(act) } // OnCollection // OnCollection calls function fn on it Item if it can be asserted to type Collection func OnCollection(it Item, fn WithCollectionFn) error { if it == nil { return nil
-
@@ -151,7 +174,7 @@ func OnCollection(it Item, fn WithCollectionFn) error {return fn(col) } // OnCollectionIntf // OnCollectionIntf calls function fn on it Item if it can be asserted to one of the Collection types func OnCollectionIntf(it Item, fn WithCollectionInterfaceFn) error { if it == nil { return nil
-
@@ -192,11 +215,11 @@ func OnCollectionIntf(it Item, fn WithCollectionInterfaceFn) error {return fn(col) }) default: return fmt.Errorf("%T[%s] can't be converted to Collection", it, it.GetType()) return fmt.Errorf("%T[%s] can't be converted to a Collection type", it, it.GetType()) } } // OnCollectionPage // OnCollectionPage calls function fn on it Item if it can be asserted to type CollectionPage func OnCollectionPage(it Item, fn WithCollectionPageFn) error { if it == nil { return nil
-
@@ -208,7 +231,7 @@ func OnCollectionPage(it Item, fn WithCollectionPageFn) error {return fn(col) } // OnOrderedCollection // OnOrderedCollection calls function fn on it Item if it can be asserted to type OrderedCollection func OnOrderedCollection(it Item, fn WithOrderedCollectionFn) error { if it == nil { return nil
-
@@ -220,7 +243,7 @@ func OnOrderedCollection(it Item, fn WithOrderedCollectionFn) error {return fn(col) } // OnOrderedCollectionPage executes a function on an ordered collection page type item // OnOrderedCollectionPage calls function fn on it Item if it can be asserted to type OrderedCollectionPage func OnOrderedCollectionPage(it Item, fn WithOrderedCollectionPageFn) error { if it == nil { return nil
-
@@ -232,7 +255,7 @@ func OnOrderedCollectionPage(it Item, fn WithOrderedCollectionPageFn) error {return fn(col) } // OnItemCollection executes a function on a collection type item // OnItemCollection calls function fn on it Item if it can be asserted to type ItemCollection func OnItemCollection(it Item, fn WithItemCollectionFn) error { if it == nil { return nil
-
@@ -360,7 +383,8 @@ func notEmptyActor(a *Actor) bool {len(a.PublicKey.PublicKeyPem) > 0) } // NotEmpty // NotEmpty tells us if a Item interface value has a non nil value for various types // that implement func NotEmpty(i Item) bool { if IsNil(i) { return false
-
-
-
@@ -177,7 +177,7 @@ func (i IntransitiveActivity) IsCollection() bool {return false } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (i *IntransitiveActivity) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
@@ -187,7 +187,7 @@ func (i *IntransitiveActivity) UnmarshalJSON(data []byte) error {return loadIntransitiveActivity(val, i) } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (i IntransitiveActivity) MarshalJSON() ([]byte, error) { b := make([]byte, 0) write(&b, '{')
-
-
-
@@ -44,13 +44,13 @@ func (i IRI) URL() (*url.URL, error) {return url.Parse(i.String()) } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (i *IRI) UnmarshalJSON(s []byte) error { *i = IRI(strings.Trim(string(s), "\"")) return nil } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (i IRI) MarshalJSON() ([]byte, error) { if i == "" { return nil, nil
-
-
-
@@ -92,7 +92,7 @@ func (l Link) GetType() ActivityVocabularyType {return l.Type } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (l Link) MarshalJSON() ([]byte, error) { b := make([]byte, 0) write(&b, '{')
-
@@ -104,7 +104,7 @@ func (l Link) MarshalJSON() ([]byte, error) {return nil, nil } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (l *Link) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
-
-
@@ -70,7 +70,7 @@ func (n *NaturalLanguageValues) Set(ref LangRef, v Content) error {return nil } // MarshalJSON serializes the NaturalLanguageValues into JSON // MarshalJSON encodes the receiver object to a JSON document. func (n NaturalLanguageValues) MarshalJSON() ([]byte, error) { l := len(n) if l <= 0 {
-
@@ -162,7 +162,7 @@ func (l LangRefValue) String() string {return fmt.Sprintf("%s[%s]", l.Value, l.Ref) } // UnmarshalJSON implements the JsonEncoder interface // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (l *LangRefValue) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
@@ -193,7 +193,7 @@ func (l *LangRefValue) UnmarshalText(data []byte) error {return nil } // MarshalJSON serializes the LangRefValue into JSON // MarshalJSON encodes the receiver object to a JSON document. func (l LangRefValue) MarshalJSON() ([]byte, error) { buf := bytes.Buffer{} if l.Ref != NilLangRef && len(l.Ref) > 0 {
-
@@ -224,7 +224,7 @@ func (l LangRefValue) MarshalText() ([]byte, error) {return buf.Bytes(), nil } // UnmarshalJSON implements the JsonEncoder interface // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (l *LangRef) UnmarshalJSON(data []byte) error { return l.UnmarshalText(data) }
-
@@ -293,7 +293,7 @@ func unescape(b []byte) []byte {return b } // UnmarshalJSON tries to load the NaturalLanguage array from the incoming json value // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (n *NaturalLanguageValues) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
-
-
@@ -278,7 +278,7 @@ func (o Object) IsCollection() bool {return false } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (o *Object) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
@@ -288,7 +288,7 @@ func (o *Object) UnmarshalJSON(data []byte) error {return loadObject(val, o) } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (o Object) MarshalJSON() ([]byte, error) { b := make([]byte, 0) write(&b, '{')
-
@@ -358,13 +358,13 @@ type (Video = Document ) // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (m *MimeType) UnmarshalJSON(data []byte) error { *m = MimeType(strings.Trim(string(data), "\"")) return nil } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (m MimeType) MarshalJSON() ([]byte, error) { if len(m) == 0 { return nil, nil
-
@@ -499,7 +499,7 @@ func GetAPSource(val *fastjson.Value) Source {return s } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (s *Source) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
@@ -510,7 +510,7 @@ func (s *Source) UnmarshalJSON(data []byte) error {return nil } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (s Source) MarshalJSON() ([]byte, error) { b := make([]byte, 0) empty := true
-
-
-
@@ -151,7 +151,7 @@ type (// the contents of the outbox are filtered by the permissions of the person reading it). OutboxStream = Outbox // outbox is a type alias for an Ordered Collection // Outbox is a type alias for an Ordered Collection Outbox = OrderedCollection // SharesCollection is a list of all Announce activities with this object as the object property,
-
@@ -194,12 +194,12 @@ func (o OrderedCollection) Collection() ItemCollection {return o.OrderedItems } // IsCollection returns true for OrderedCollection objects // IsCollection returns true for OrderedCollection objects. func (o OrderedCollection) IsCollection() bool { return true } // Contains verifies if OrderedCollection array contains the received one // Contains verifies if OrderedCollection array contains the received item r. func (o OrderedCollection) Contains(r Item) bool { if len(o.OrderedItems) == 0 { return false
-
@@ -220,13 +220,13 @@ func (o *OrderedCollection) Count() uint {return uint(len(o.OrderedItems)) } // Append adds an element to an OrderedCollection // Append adds an element to an the receiver collection object. func (o *OrderedCollection) Append(ob Item) error { o.OrderedItems = append(o.OrderedItems, ob) return nil } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (o *OrderedCollection) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
@@ -236,7 +236,7 @@ func (o *OrderedCollection) UnmarshalJSON(data []byte) error {return loadOrderedCollection(val, o) } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (o OrderedCollection) MarshalJSON() ([]byte, error) { b := make([]byte, 0) notEmpty := false
-
-
-
@@ -188,7 +188,7 @@ func (o OrderedCollectionPage) Contains(r Item) bool {return false } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (o *OrderedCollectionPage) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
@@ -198,7 +198,7 @@ func (o *OrderedCollectionPage) UnmarshalJSON(data []byte) error {return loadOrderedCollectionPage(val, o) } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (o OrderedCollectionPage) MarshalJSON() ([]byte, error) { b := make([]byte, 0) notEmpty := false
-
-
-
@@ -153,7 +153,7 @@ func (p Place) GetID() ID {return p.ID } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (p *Place) UnmarshalJSON(data []byte) error { par := fastjson.Parser{} val, err := par.ParseBytes(data)
-
@@ -163,7 +163,7 @@ func (p *Place) UnmarshalJSON(data []byte) error {return loadPlace(val, p) } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (p Place) MarshalJSON() ([]byte, error) { b := make([]byte, 0) notEmpty := false
-
-
-
@@ -139,7 +139,7 @@ func (p Profile) GetID() ID {return p.ID } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (p *Profile) UnmarshalJSON(data []byte) error { par := fastjson.Parser{} val, err := par.ParseBytes(data)
-
@@ -149,7 +149,7 @@ func (p *Profile) UnmarshalJSON(data []byte) error {return loadProfile(val, p) } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (p Profile) MarshalJSON() ([]byte, error) { b := make([]byte, 0) notEmpty := false
-
-
-
@@ -164,7 +164,7 @@ func (q Question) IsCollection() bool {return false } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (q *Question) UnmarshalJSON(data []byte) error { p := fastjson.Parser{} val, err := p.ParseBytes(data)
-
@@ -174,6 +174,7 @@ func (q *Question) UnmarshalJSON(data []byte) error {return loadQuestion(val, q) } // MarshalJSON encodes the receiver object to a JSON document. func (q Question) MarshalJSON() ([]byte, error) { b := make([]byte, 0) write(&b, '{')
-
-
-
@@ -149,7 +149,7 @@ func (r Relationship) GetID() ID {return r.ID } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (r *Relationship) UnmarshalJSON(data []byte) error { par := fastjson.Parser{} val, err := par.ParseBytes(data)
-
@@ -159,7 +159,7 @@ func (r *Relationship) UnmarshalJSON(data []byte) error {return loadRelationship(val, r) } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (r Relationship) MarshalJSON() ([]byte, error) { b := make([]byte, 0) notEmpty := false
-
-
-
@@ -141,7 +141,7 @@ func (t Tombstone) GetID() ID {return t.ID } // UnmarshalJSON // UnmarshalJSON decodes an incoming JSON document into the receiver object. func (t *Tombstone) UnmarshalJSON(data []byte) error { par := fastjson.Parser{} val, err := par.ParseBytes(data)
-
@@ -151,7 +151,7 @@ func (t *Tombstone) UnmarshalJSON(data []byte) error {return loadTombstone(val, t) } // MarshalJSON // MarshalJSON encodes the receiver object to a JSON document. func (t Tombstone) MarshalJSON() ([]byte, error) { b := make([]byte, 0) notEmpty := false
-
@@ -179,22 +179,22 @@ func (t Tombstone) MarshalJSON() ([]byte, error) {/* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (t *Tombstone) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *t)) return fmt.Errorf("UnmarshalBinary is not implemented for %T", *t) } // MarshalBinary implements the encoding.BinaryMarshaler interface. func (t Tombstone) MarshalBinary() ([]byte, error) { return nil, errors.New(fmt.Sprintf("MarshalBinary is not implemented for %T", t)) return nil, fmt.Errorf("MarshalBinary is not implemented for %T", t) } // GobEncode func (t Tombstone) GobEncode() ([]byte, error) { return nil, errors.New(fmt.Sprintf("GobEncode is not implemented for %T", t)) return nil, fmt.Errorf("GobEncode is not implemented for %T", t) } // GobDecode func (t *Tombstone) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *t)) return fmt.Errorf("GobDecode is not implemented for %T", *t) } */
-