From fc31f145078e3c22d7a0aa9de2bca77f6d503469 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Sun, 24 Mar 2024 11:37:01 +0530 Subject: feat: extend webfinger to respond to profile page URIs --- routers/web/webfinger.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'routers') diff --git a/routers/web/webfinger.go b/routers/web/webfinger.go index e4b2aacce8..c620059ec1 100644 --- a/routers/web/webfinger.go +++ b/routers/web/webfinger.go @@ -64,6 +64,19 @@ func WebfingerQuery(ctx *context.Context) { if u != nil && u.KeepEmailPrivate { err = user_model.ErrUserNotExist{} } + case "https", "http": + if resource.Host != appURL.Host { + ctx.Error(http.StatusBadRequest) + return + } + + parts := strings.Split(resource.Path, "/") + if len(parts) < 2 { // fragment[0] is empty space, fragment[1] may be username + ctx.Error(http.StatusBadRequest) + return + } + + u, err = user_model.GetUserByName(ctx, parts[1]) default: ctx.Error(http.StatusBadRequest) return -- cgit v1.2.3