Merge pull request #779 from writefreely/fix-ld-json-response-2

Correctly respond to application/ld+json requests, part 2
pull/785/head
Matt Baer 1 year ago committed by GitHub
commit 4aad0338bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      collections.go
  2. 2
      handle.go
  3. 2
      posts.go

@ -874,7 +874,7 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro
} }
// Serve ActivityStreams data now, if requested // Serve ActivityStreams data now, if requested
if strings.Contains(r.Header.Get("Accept"), "application/activity+json") { if IsActivityPubRequest(r) {
ac := c.PersonObject() ac := c.PersonObject()
ac.Context = []interface{}{activitystreams.Namespace} ac.Context = []interface{}{activitystreams.Namespace}
setCacheControl(w, apCacheTime) setCacheControl(w, apCacheTime)

@ -818,7 +818,7 @@ func (h *Handler) handleHTTPError(w http.ResponseWriter, r *http.Request, err er
return return
} else if err.Status == http.StatusNotFound { } else if err.Status == http.StatusNotFound {
w.WriteHeader(err.Status) w.WriteHeader(err.Status)
if strings.Contains(r.Header.Get("Accept"), "application/activity+json") { if IsActivityPubRequest(r) {
// This is a fediverse request; simply return the header // This is a fediverse request; simply return the header
return return
} }

@ -1546,7 +1546,7 @@ Are you sure it was ever here?`,
fmt.Fprintf(w, "# %s\n\n", p.Title.String) fmt.Fprintf(w, "# %s\n\n", p.Title.String)
} }
fmt.Fprint(w, p.Content) fmt.Fprint(w, p.Content)
} else if strings.Contains(r.Header.Get("Accept"), "application/activity+json") { } else if IsActivityPubRequest(r) {
if !postFound { if !postFound {
return ErrCollectionPageNotFound return ErrCollectionPageNotFound
} }

Loading…
Cancel
Save