Using new storage package which allows an IRI to be used as an filter for LoadObject

This commit is contained in:
Marius Orcsik 2019-06-30 19:52:30 +02:00
parent e77b3d5fe7
commit fad811cef1
No known key found for this signature in database
GPG key ID: 889CE8E4FB2D877A
2 changed files with 8 additions and 2 deletions

2
go.mod
View file

@ -6,5 +6,5 @@ require (
github.com/go-ap/activitystreams v0.0.0-20190621152349-7d4dd99336d5 github.com/go-ap/activitystreams v0.0.0-20190621152349-7d4dd99336d5
github.com/go-ap/errors v0.0.0-20190621154420-19e59a62cbd5 github.com/go-ap/errors v0.0.0-20190621154420-19e59a62cbd5
github.com/go-ap/jsonld v0.0.0-20190630153951-3e340483bd9f github.com/go-ap/jsonld v0.0.0-20190630153951-3e340483bd9f
github.com/go-ap/storage v0.0.0-20190621154542-2d70b6c181c4 github.com/go-ap/storage v0.0.0-20190630174915-381f9e8bdbb8
) )

View file

@ -81,9 +81,15 @@ func (a ActivityHandlerFn) ServeHTTP(w http.ResponseWriter, r *http.Request) {
errors.HandleError(err).ServeHTTP(w, r) errors.HandleError(err).ServeHTTP(w, r)
return return
} }
contentType := json.ContentType contentType := json.ContentType
if act, err := as.ToActivity(it); err == nil { if act, err := as.ToActivity(it); err == nil {
if len(it.GetType()) == 0 && len(it.GetLink()) > 0 {
col, cnt, err := st.LoadObjects(it)
if err == nil && cnt == 1 {
act.Object = col[0]
}
}
if dat, err = json.Marshal(act.Object); err != nil { if dat, err = json.Marshal(act.Object); err != nil {
dat = dat[:] dat = dat[:]
contentType = "application/json" contentType = "application/json"