Changes
17 changed files (+92/-50)
-
-
@@ -2,7 +2,6 @@ package activitypubimport ( "errors" "fmt" "reflect" "strings" "time"
-
@@ -759,6 +758,7 @@ func (a Activity) MarshalJSON() ([]byte, error) {return b, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (a *Activity) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *a))
-
@@ -778,6 +778,7 @@ func (a Activity) GobEncode() ([]byte, error) {func (a *Activity) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *a)) } */ // Equals verifies if our receiver Object is equals with the "with" Object func (a Activity) Equals(with Item) bool {
-
-
-
@@ -1,7 +1,6 @@package activitypub import ( "errors" "fmt" "github.com/buger/jsonparser" "reflect"
-
@@ -233,6 +232,7 @@ func (p PublicKey) MarshalJSON() ([]byte, error) {return nil, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (a *Actor) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *a))
-
@@ -250,6 +250,7 @@ func (a Actor) GobEncode() ([]byte, error) {func (a *Actor) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *a)) } */ type ( // Application describes a software application.
-
-
-
@@ -2,7 +2,6 @@ package activitypubimport ( "errors" "fmt" "reflect" "time" "unsafe"
-
@@ -264,6 +263,7 @@ func (c Collection) MarshalJSON() ([]byte, error) {return nil, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (c *Collection) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *c))
-
@@ -281,6 +281,7 @@ func (c Collection) GobEncode() ([]byte, error) {func (c *Collection) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *c)) } */ // ToCollection func ToCollection(it Item) (*Collection, error) {
-
-
-
@@ -2,7 +2,6 @@ package activitypubimport ( "errors" "fmt" "reflect" "time" )
-
@@ -228,6 +227,7 @@ func (c CollectionPage) MarshalJSON() ([]byte, error) {return nil, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (c *CollectionPage) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *c))
-
@@ -245,6 +245,7 @@ func (c CollectionPage) GobEncode() ([]byte, error) {func (c *CollectionPage) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *c)) } */ // CollectionNew initializes a new CollectionPage func CollectionPageNew(parent CollectionInterface) *CollectionPage {
-
-
-
@@ -6,10 +6,14 @@ import ("errors" "fmt" "io" "reflect" "time" ) type typeId int32 type gobEncoder struct { sent map[reflect.Type]typeId // which types we've already sent w *bytes.Buffer enc *gob.Encoder }
-
@@ -33,15 +37,18 @@ func (e *gobEncoder) encode (it Item) ([]byte, error) {// return enc.encode(it) //} func (e *gobEncoder) writeIRIProp(i IRI) (bool, error) { if len(i) == 0 { return true, nil } return false, e.enc.Encode(i) func (e *gobEncoder) writeS(s string) error { return e.enc.Encode(s) } func (e *gobEncoder)writeGobProp (p string, b []byte) bool { return true func (e *gobEncoder) writeIRIProp(i IRI) error { return e.enc.Encode(i.String()) } func (e *gobEncoder) writeGobProp (p string, b []byte) bool { c, _ := e.w.Write([]byte(p)) d, _ := e.w.Write(b) return c+d > 0 } func (e *gobEncoder)writeItemGobProp (p string, it Item) bool { return true
-
@@ -59,14 +66,11 @@ func (e *gobEncoder)writeDurationGobProp (p string, d time.Duration) bool {return true } func writeIRIGobProp(buf io.Writer, i IRI) (int, error) { return 0, errors.New(fmt.Sprintf("writeIRIGobProp is not implemented for %T", i)) } func writeObjectGobValue(buf io.Writer, o *Object) (int, error) { return 0, errors.New(fmt.Sprintf("writeObjectGobValue is not implemented for %T", *o)) } /* func (e *gobEncoder) writeObjectGobValue(o Object) (bool, error) { notEmpty := true if v, err := o.ID.GobEncode(); err == nil && len(v) > 0 {
-
@@ -166,3 +170,4 @@ func (e *gobEncoder) writeObjectGobValue(o Object) (bool, error) {} return notEmpty, nil } */
-
-
-
@@ -3,7 +3,7 @@ package activitypubimport ( "bytes" "encoding/gob" "reflect" "errors" "testing" )
-
@@ -12,7 +12,7 @@ func TestMarshalGob(t *testing.T) {name string it Item want []byte wantErr bool wantErr error }{ { name: "empty object",
-
@@ -20,28 +20,28 @@ func TestMarshalGob(t *testing.T) {ID: "test", }, want: []byte{}, wantErr: true, wantErr: nil, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { //got, err := MarshalGob(tt.it) buf := bytes.NewBuffer(make([]byte,0)) err := gob.NewEncoder(buf).Encode(tt.it) got := buf.Bytes() it := new(Object) gob.NewDecoder(bytes.NewReader(got)).Decode(it) if it.ID == tt.it.GetID() { t.Logf("Yay!") } if (err != nil) != tt.wantErr { if !errors.Is(err, tt.wantErr){ t.Errorf("MarshalGob() error = %s, wantErr %v", err, tt.wantErr) return } if !tt.wantErr && !reflect.DeepEqual(got, tt.want) { t.Errorf("MarshalGob() got = %#v, want %#v", got, tt.want) it := new(Object) got := buf.Bytes() if err := gob.NewDecoder(bytes.NewReader(got)).Decode(it); err != nil { t.Errorf("Gob Decoding failed for previously generated output %v", err) } if tt.wantErr == nil { if !assertDeepEquals(t.Errorf, it, tt.it) { t.Errorf("Gob Decoded value is different got = %#v, want %#v", it, tt.it) } } }) }
-
-
-
@@ -2,7 +2,6 @@ package activitypubimport ( "errors" "fmt" "reflect" "time" "unsafe"
-
@@ -193,6 +192,7 @@ func (i IntransitiveActivity) MarshalJSON() ([]byte, error) {return b, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (i *IntransitiveActivity) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *i))
-
@@ -210,6 +210,7 @@ func (i IntransitiveActivity) GobEncode() ([]byte, error) {func (i *IntransitiveActivity) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *i)) } */ // IntransitiveActivityNew initializes a intransitive activity func IntransitiveActivityNew(id ID, typ ActivityVocabularyType) *IntransitiveActivity {
-
-
-
@@ -1,8 +1,6 @@package activitypub import ( "bytes" "errors" "fmt" "github.com/buger/jsonparser" "net/url"
-
@@ -63,7 +61,7 @@ func (i IRI) MarshalJSON() ([]byte, error) {return b, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (i *IRI) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *i))
-
@@ -71,22 +69,27 @@ func (i *IRI) UnmarshalBinary(data []byte) error {// MarshalBinary implements the encoding.BinaryMarshaler interface. func (i IRI) MarshalBinary() ([]byte, error) { return nil, errors.New(fmt.Sprintf("MarshalBinary is not implemented for %T", i)) if len(i) == 0 { return nil, nil } w := &bytes.Buffer{} enc := gobEncoder{ w: w, enc: gob.NewEncoder(w) } if err := enc.writeS(i.String()); err != nil { return nil, err } return w.Bytes(), nil } // GobEncode func (i IRI) GobEncode() ([]byte, error) { buf := bytes.NewBuffer(make([]byte, 0)) if _, err := writeIRIGobProp(buf, i); err != nil { return nil, err } return buf.Bytes(), nil return i.MarshalBinary() } // GobDecode func (i *IRI) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *i)) } */ // AddPath concatenates el elements as a path to i func (i IRI) AddPath(el ...string) IRI {
-
-
-
@@ -112,6 +112,7 @@ func (l *Link) UnmarshalBinary(data []byte) error {return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *l)) } /* // MarshalBinary implements the encoding.BinaryMarshaler interface. func (l Link) MarshalBinary() ([]byte, error) { return nil, errors.New(fmt.Sprintf("MarshalBinary is not implemented for %T", l))
-
@@ -124,3 +125,4 @@ func (l Link) GobEncode() ([]byte, error) {func (l *Link) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *l)) } */
-
-
-
@@ -1,7 +1,6 @@package activitypub import ( "errors" "fmt" "github.com/buger/jsonparser" "reflect"
-
@@ -109,6 +108,7 @@ func (a ActivityVocabularyType) MarshalJSON() ([]byte, error) {return b, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (a *ActivityVocabularyType) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *a))
-
@@ -121,13 +121,22 @@ func (a ActivityVocabularyType) MarshalBinary() ([]byte, error) {// GobEncode func (a ActivityVocabularyType) GobEncode() ([]byte, error) { return nil, errors.New(fmt.Sprintf("GobEncode is not implemented for %T", a)) if len(a) == 0 { return nil, nil } w := &bytes.Buffer{} enc := gobEncoder{ w: w, enc: gob.NewEncoder(w) } if err := enc.writeS(string(a)); err != nil { return nil, err } return w.Bytes(), nil } // GobDecode func (a *ActivityVocabularyType) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *a)) } */ // Object describes an ActivityPub object of any kind. // It serves as the base type for most of the other kinds of objects defined in the Activity
-
@@ -285,6 +294,7 @@ func (o Object) MarshalJSON() ([]byte, error) {return nil, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (o *Object) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *o))
-
@@ -292,7 +302,12 @@ func (o *Object) UnmarshalBinary(data []byte) error {// MarshalBinary implements the encoding.BinaryMarshaler interface. func (o Object) MarshalBinary() ([]byte, error) { return nil, errors.New(fmt.Sprintf("MarshalBinary is not implemented for %T", o)) w := &bytes.Buffer{} enc := gobEncoder{ w: w, enc: gob.NewEncoder(w) } if _, err := enc.writeObjectGobValue(o); err != nil { return nil, err } return w.Bytes(), nil } // GobEncode
-
@@ -304,6 +319,7 @@ func (o Object) GobEncode() ([]byte, error) {func (o *Object) GobDecode(data []byte) error { return o.UnmarshalBinary(data) } */ // Recipients performs recipient de-duplication on the Object's To, Bto, CC and BCC properties func (o *Object) Recipients() ItemCollection {
-
@@ -352,6 +368,7 @@ func (m MimeType) MarshalJSON() ([]byte, error) {return b, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (m *MimeType) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *m))
-
@@ -369,6 +386,7 @@ func (m MimeType) GobEncode() ([]byte, error) {} return nil, errors.New(fmt.Sprintf("GobEncode is not implemented for %T", m)) } */ // ToLink returns a Link pointer to the data in the current Item func ToLink(it Item) (*Link, error) {
-
@@ -498,6 +516,7 @@ func (s Source) MarshalJSON() ([]byte, error) {return nil, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (s *Source) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *s))
-
@@ -517,6 +536,7 @@ func (s *Source) GobDecode([]byte) error {func (s Source) GobEncode() ([]byte, error) { return nil, errors.New(fmt.Sprintf("GobEncode is not implemented for %T", s)) } */ // Equals verifies if our receiver Object is equals with the "with" Object func (o Object) Equals(with Item) bool {
-
-
-
@@ -2,7 +2,6 @@ package activitypubimport ( "errors" "fmt" "reflect" "time" "unsafe"
-
@@ -260,6 +259,7 @@ func (o OrderedCollection) MarshalJSON() ([]byte, error) {return nil, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (o *OrderedCollection) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *o))
-
@@ -279,6 +279,7 @@ func (o OrderedCollection) GobEncode() ([]byte, error) {func (o *OrderedCollection) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *o)) } */ // OrderedCollectionPageNew initializes a new OrderedCollectionPage func OrderedCollectionPageNew(parent CollectionInterface) *OrderedCollectionPage {
-
-
-
@@ -2,7 +2,6 @@ package activitypubimport ( "errors" "fmt" "reflect" "time" )
-
@@ -231,6 +230,7 @@ func (o OrderedCollectionPage) MarshalJSON() ([]byte, error) {return nil, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (o *OrderedCollectionPage) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *o))
-
@@ -250,6 +250,7 @@ func (o OrderedCollectionPage) GobEncode() ([]byte, error) {func (o *OrderedCollectionPage) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *o)) } */ // ToOrderedCollectionPage func ToOrderedCollectionPage(it Item) (*OrderedCollectionPage, error) {
-
-
-
@@ -1,7 +1,6 @@package activitypub import ( "errors" "fmt" "reflect" "time"
-
@@ -192,6 +191,7 @@ func (p Place) MarshalJSON() ([]byte, error) {return nil, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (p *Place) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *p))
-
@@ -211,6 +211,7 @@ func (p Place) GobEncode() ([]byte, error) {func (p *Place) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *p)) } */ // Recipients performs recipient de-duplication on the Place object's To, Bto, CC and BCC properties func (p *Place) Recipients() ItemCollection {
-
-
-
@@ -1,7 +1,6 @@package activitypub import ( "errors" "fmt" "reflect" "time"
-
@@ -164,6 +163,7 @@ func (p Profile) MarshalJSON() ([]byte, error) {return nil, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (p *Profile) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *p))
-
@@ -183,6 +183,7 @@ func (p Profile) GobEncode() ([]byte, error) {func (p *Profile) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *p)) } */ // Recipients performs recipient de-duplication on the Profile object's To, Bto, CC and BCC properties func (p *Profile) Recipients() ItemCollection {
-
-
-
@@ -2,7 +2,6 @@ package activitypubimport ( "errors" "fmt" "reflect" "time" )
-
@@ -179,6 +178,7 @@ func (q Question) MarshalJSON() ([]byte, error) {return b, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (q *Question) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *q))
-
@@ -198,6 +198,7 @@ func (q Question) GobEncode() ([]byte, error) {func (q *Question) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *q)) } */ // QuestionNew initializes a Question activity func QuestionNew(id ID) *Question {
-
-
-
@@ -1,7 +1,6 @@package activitypub import ( "errors" "fmt" "reflect" "time"
-
@@ -181,6 +180,7 @@ func (r Relationship) MarshalJSON() ([]byte, error) {return nil, nil } /* // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. func (r *Relationship) UnmarshalBinary(data []byte) error { return errors.New(fmt.Sprintf("UnmarshalBinary is not implemented for %T", *r))
-
@@ -200,6 +200,7 @@ func (r Relationship) GobEncode() ([]byte, error) {func (r *Relationship) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *r)) } */ // Recipients performs recipient de-duplication on the Relationship object's To, Bto, CC and BCC properties func (r *Relationship) Recipients() ItemCollection {
-
-
-
@@ -1,7 +1,6 @@package activitypub import ( "errors" "fmt" "reflect" "time"
-
@@ -170,6 +169,7 @@ func (t Tombstone) MarshalJSON() ([]byte, error) {return nil, nil } /* // 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))
-
@@ -189,6 +189,7 @@ func (t Tombstone) GobEncode() ([]byte, error) {func (t *Tombstone) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *t)) } */ // Recipients performs recipient de-duplication on the Tombstone object's To, Bto, CC and BCC properties func (t *Tombstone) Recipients() ItemCollection {
-