From 10e15019aad0e81b3ec4a66954cc9d96f86ed37b Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Sat, 18 Jun 2022 17:16:37 -0500 Subject: [PATCH] Correctly merge feature-activitypub branch --- routers/api/v1/activitypub/person.go | 10 +++++----- routers/api/v1/activitypub/repo.go | 10 +++++----- routers/api/v1/activitypub/response.go | 2 +- routers/web/webfinger.go | 1 + 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/routers/api/v1/activitypub/person.go b/routers/api/v1/activitypub/person.go index 1641dfa51..4302fe60c 100644 --- a/routers/api/v1/activitypub/person.go +++ b/routers/api/v1/activitypub/person.go @@ -104,7 +104,7 @@ func PersonInbox(ctx *context.APIContext) { body, err := io.ReadAll(io.LimitReader(ctx.Req.Body, setting.Federation.MaxSize)) if err != nil { - ctx.Error(http.StatusInternalServerError, "Error reading request body", err) + ctx.ServerError("Error reading request body", err) } var activity ap.Activity @@ -148,7 +148,7 @@ func PersonOutbox(ctx *context.APIContext) { Date: ctx.FormString("date"), }) if err != nil { - ctx.Error(http.StatusInternalServerError, "Couldn't fetch outbox", err) + ctx.ServerError("Couldn't fetch outbox", err) } outbox := ap.OrderedCollectionNew(ap.IRI(link)) @@ -185,7 +185,7 @@ func PersonFollowing(ctx *context.APIContext) { users, err := user_model.GetUserFollowing(ctx.ContextUser, utils.GetListOptions(ctx)) if err != nil { - ctx.Error(http.StatusInternalServerError, "GetUserFollowing", err) + ctx.ServerError("GetUserFollowing", err) return } @@ -222,7 +222,7 @@ func PersonFollowers(ctx *context.APIContext) { users, err := user_model.GetUserFollowers(ctx.ContextUser, utils.GetListOptions(ctx)) if err != nil { - ctx.Error(http.StatusInternalServerError, "GetUserFollowers", err) + ctx.ServerError("GetUserFollowers", err) return } @@ -262,7 +262,7 @@ func PersonLiked(ctx *context.APIContext) { StarredByID: ctx.ContextUser.ID, }) if err != nil { - ctx.Error(http.StatusInternalServerError, "GetUserStarred", err) + ctx.ServerError("GetUserStarred", err) return } diff --git a/routers/api/v1/activitypub/repo.go b/routers/api/v1/activitypub/repo.go index f2abb3977..8a780683d 100644 --- a/routers/api/v1/activitypub/repo.go +++ b/routers/api/v1/activitypub/repo.go @@ -48,7 +48,7 @@ func Repo(ctx *context.APIContext) { repo.Name = ap.NaturalLanguageValuesNew() err := repo.Name.Set("en", ap.Content(ctx.Repo.Repository.Name)) if err != nil { - ctx.Error(http.StatusInternalServerError, "Set Name", err) + ctx.ServerError("Set Name", err) return } @@ -57,7 +57,7 @@ func Repo(ctx *context.APIContext) { repo.Summary = ap.NaturalLanguageValuesNew() err = repo.Summary.Set("en", ap.Content(ctx.Repo.Repository.Description)) if err != nil { - ctx.Error(http.StatusInternalServerError, "Set Description", err) + ctx.ServerError("Set Description", err) return } @@ -93,7 +93,7 @@ func RepoInbox(ctx *context.APIContext) { body, err := io.ReadAll(ctx.Req.Body) if err != nil { - ctx.Error(http.StatusInternalServerError, "Error reading request body", err) + ctx.ServerError("Error reading request body", err) } var activity ap.Activity @@ -140,7 +140,7 @@ func RepoOutbox(ctx *context.APIContext) { Date: ctx.FormString("date"), }) if err != nil { - ctx.Error(http.StatusInternalServerError, "Couldn't fetch outbox", err) + ctx.ServerError("Couldn't fetch outbox", err) } outbox := ap.OrderedCollectionNew(ap.IRI(link)) @@ -182,7 +182,7 @@ func RepoFollowers(ctx *context.APIContext) { users, err := user_model.GetUserFollowers(ctx.ContextUser, utils.GetListOptions(ctx)) if err != nil { - ctx.Error(http.StatusInternalServerError, "GetUserFollowers", err) + ctx.ServerError("GetUserFollowers", err) return } diff --git a/routers/api/v1/activitypub/response.go b/routers/api/v1/activitypub/response.go index 6f3bdf91c..fb1465352 100644 --- a/routers/api/v1/activitypub/response.go +++ b/routers/api/v1/activitypub/response.go @@ -18,7 +18,7 @@ import ( func response(ctx *context.APIContext, v interface{}) { binary, err := jsonld.WithContext(jsonld.IRI(ap.ActivityBaseURI), jsonld.IRI(ap.SecurityContextURI)).Marshal(v) if err != nil { - ctx.Error(http.StatusInternalServerError, "Marshal", err) + ctx.ServerError("Marshal", err) return } ctx.Resp.Header().Add("Content-Type", activitypub.ActivityStreamsContentType) diff --git a/routers/web/webfinger.go b/routers/web/webfinger.go index 9972e9d0e..b52c1879a 100644 --- a/routers/web/webfinger.go +++ b/routers/web/webfinger.go @@ -29,6 +29,7 @@ type webfingerLink struct { Rel string `json:"rel,omitempty"` Type string `json:"type,omitempty"` Href string `json:"href,omitempty"` + Template string `json:"template,omitempty"` Titles map[string]string `json:"titles,omitempty"` Properties map[string]interface{} `json:"properties,omitempty"` }