From 35906118d0f122b92592aa023ebcb586c829a207 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 7 Aug 2019 10:18:40 -0400 Subject: [PATCH] Return only 404 on ActivityPub coll post request Ref T493 --- handle.go | 4 ++++ posts.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/handle.go b/handle.go index 4f137b9..56d5e57 100644 --- a/handle.go +++ b/handle.go @@ -721,6 +721,10 @@ 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") { + // This is a fediverse request; simply return the header + return + } h.errors.NotFound.ExecuteTemplate(w, "base", pageForReq(h.app.App(), r)) return } else if err.Status == http.StatusInternalServerError { diff --git a/posts.go b/posts.go index 518a07e..3811253 100644 --- a/posts.go +++ b/posts.go @@ -1352,7 +1352,7 @@ Are you sure it was ever here?`, fmt.Fprint(w, p.Content) } else if strings.Contains(r.Header.Get("Accept"), "application/activity+json") { if !postFound { - w.WriteHeader(http.StatusNotFound) + return ErrCollectionPageNotFound } p.extractData() ap := p.ActivityObject()