Correctly respond to application/ld+json requests, part 2

This finishes the work started in #766, ensuring that requests to
canonical URLs of blogs and posts (not just at their API endpoints)
respond correctly to `application/ld+json;...` requests.

Fully addresses issue #564
This commit is contained in:
Matt Baer 2023-09-26 14:46:35 -04:00
parent 74f3ded250
commit 2275a288b9
3 changed files with 3 additions and 3 deletions

View File

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

View File

@ -818,7 +818,7 @@ func (h *Handler) handleHTTPError(w http.ResponseWriter, r *http.Request, err er
return
} else if err.Status == http.StatusNotFound {
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
return
}

View File

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