diff options
author | Anthony Wang | 2022-03-24 18:44:44 -0500 |
---|---|---|
committer | Anthony Wang | 2022-03-24 18:44:44 -0500 |
commit | 46973f99fac0febd73d04b7a3d8030740a28dc70 (patch) | |
tree | 0201a68818659527d7177060435b5c9cba07f081 | |
parent | ebef7697039f258996eb360ed0ae33b8563fc04a (diff) |
Cleanup, handle invalid usernames for ActivityPub person GET request
Signed-off-by: Anthony Wang <ta180m@pm.me>
-rw-r--r-- | routers/api/v1/activitypub/person.go | 3 | ||||
-rw-r--r-- | routers/api/v1/activitypub/reqsignature.go | 3 | ||||
-rw-r--r-- | routers/api/v1/api.go | 4 |
3 files changed, 6 insertions, 4 deletions
diff --git a/routers/api/v1/activitypub/person.go b/routers/api/v1/activitypub/person.go index 6218286f7..5d919df91 100644 --- a/routers/api/v1/activitypub/person.go +++ b/routers/api/v1/activitypub/person.go @@ -35,6 +35,9 @@ func Person(ctx *context.APIContext) { // "$ref": "#/responses/ActivityPub" user := user.GetUserByParamsName(ctx, "username") + if user == nil { + return + } username := ctx.Params("username") person := streams.NewActivityStreamsPerson() diff --git a/routers/api/v1/activitypub/reqsignature.go b/routers/api/v1/activitypub/reqsignature.go index 7be505d8e..d04225a76 100644 --- a/routers/api/v1/activitypub/reqsignature.go +++ b/routers/api/v1/activitypub/reqsignature.go @@ -13,6 +13,7 @@ import ( "io" "net/http" "net/url" + "time" "code.gitea.io/gitea/modules/activitypub" gitea_context "code.gitea.io/gitea/modules/context" @@ -99,7 +100,7 @@ func fetch(iri *url.URL) (b []byte, err error) { if err != nil { return } - req.Header.Add("Date", fmt.Sprintf("%s GMT", clock.Now().UTC().Format("Mon, 02 Jan 2006 15:04:05"))) + req.Header.Add("Date", fmt.Sprintf("%s GMT", clock.Now().UTC().Format(time.RFC1123))) var resp *http.Response client := &http.Client{} resp, err = client.Do(req) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 4eeefface..fb1af75ec 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -599,9 +599,7 @@ func Routes(sessioner func(http.Handler) http.Handler) *web.Route { if setting.Federation.Enabled { m.Get("/nodeinfo", misc.NodeInfo) m.Group("/activitypub", func() { - m.Group("/user/{username}", func() { - m.Get("", activitypub.Person) - }) + m.Get("/user/{username}", activitypub.Person) m.Post("/user/{username}/inbox", activitypub.ReqSignature(), activitypub.PersonInbox) }) } |