From 01d83064daede7270dc6f516e4d239ecb364cd08 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Wed, 12 Jan 2022 19:55:10 -0800 Subject: [PATCH] Make acct webfinger prefix optional. Closes #1662" --- activitypub/controllers/webfinger.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/activitypub/controllers/webfinger.go b/activitypub/controllers/webfinger.go index f3c733a97..22a29a776 100644 --- a/activitypub/controllers/webfinger.go +++ b/activitypub/controllers/webfinger.go @@ -20,7 +20,13 @@ func WebfingerHandler(w http.ResponseWriter, r *http.Request) { resource := r.URL.Query().Get("resource") resourceComponents := strings.Split(resource, ":") - account := resourceComponents[1] + + var account string + if len(resourceComponents) == 2 { + account = resourceComponents[1] + } else { + account = resourceComponents[0] + } userComponents := strings.Split(account, "@") if len(userComponents) < 2 { @@ -32,7 +38,7 @@ func WebfingerHandler(w http.ResponseWriter, r *http.Request) { if _, valid := data.GetFederatedInboxMap()[user]; !valid { // User is not valid w.WriteHeader(http.StatusNotFound) - log.Println("Webfinger request rejected") + log.Errorln("webfinger request rejected for user:", user) return }