Changes
3 changed files (+22/-8)
-
-
@@ -68,6 +68,19 @@ err := gob.NewEncoder(&b).Encode(tt)return b.Bytes(), err } func gobEncodeItemOrLink(it LinkOrIRI) ([]byte, error) { if ob, ok := it.(Item); ok { return gobEncodeItem(ob) } b := bytes.Buffer{} err := OnLink(it, func(l *Link) error { bytes, err := l.GobEncode() b.Write(bytes) return err }) return b.Bytes(), err } func gobEncodeItem(it Item) ([]byte, error) { if IsIRI(it) { if i, ok := it.(IRI); ok {
-
@@ -97,6 +110,7 @@ b.Write(bytes)return err }) case LinkType, MentionType: // TODO(marius): this shouldn't work, as Link does not implement Item? (or rather, should not) err = OnLink(it, func(l *Link) error { bytes, err := l.GobEncode() b.Write(bytes)
-
@@ -333,7 +347,7 @@ }hasData = true } if o.URL != nil { if mm["url"], err = gobEncodeItem(o.URL); err != nil { if mm["url"], err = gobEncodeItemOrLink(o.URL); err != nil { return hasData, err } hasData = true
-
-
-
@@ -41,7 +41,7 @@ // WithItemCollectionFn represents a function type that can be used as a parameter for OnItemCollection helper functiontype WithItemCollectionFn func(*ItemCollection) error // OnLink calls function fn on it Item if it can be asserted to type Link func OnLink(it Item, fn WithLinkFn) error { func OnLink(it LinkOrIRI, fn WithLinkFn) error { if it == nil { return nil }
-
-
-
@@ -135,10 +135,10 @@ }type Objects interface { Object | Tombstone | Place | Profile | Relationship | Activities | IntransitiveActivities | Collections | IRI Activities | IntransitiveActivities | Collections | IRI } // Object describes an ActivityPub object of any kind.
-
@@ -427,14 +427,14 @@ return m.GobEncode()} // ToLink returns a Link pointer to the data in the current Item func ToLink(it Item) (*Link, error) { func ToLink(it LinkOrIRI) (*Link, error) { switch i := it.(type) { case *Link: return i, nil case Link: return &i, nil } return nil, fmt.Errorf("unable to convert %q", it.GetType()) return nil, fmt.Errorf("unable to convert %T", it) } // ToObject returns an Object pointer to the data in the current Item
-