diff options
author | FChannel <> | 2022-05-22 14:08:36 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | a66b676481d273508927e64a22e388dc302890ba (patch) | |
tree | 7c67b04dd8b39125526567ae6f08a39d0346d260 /routes/webfinger.go | |
parent | 6a0f664b565716ad08301e7699d6c0393dbba977 (diff) |
route organization
Diffstat (limited to 'routes/webfinger.go')
-rw-r--r-- | routes/webfinger.go | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/routes/webfinger.go b/routes/webfinger.go deleted file mode 100644 index 3d5fa63..0000000 --- a/routes/webfinger.go +++ /dev/null @@ -1,58 +0,0 @@ -package routes - -import ( - "encoding/json" - "strings" - - "github.com/FChannel0/FChannel-Server/activitypub" - "github.com/FChannel0/FChannel-Server/config" - "github.com/FChannel0/FChannel-Server/util" - "github.com/gofiber/fiber/v2" -) - -func Webfinger(c *fiber.Ctx) error { - acct := c.Query("resource") - - if len(acct) < 1 { - c.Status(fiber.StatusBadRequest) - return c.Send([]byte("resource needs a value")) - } - - acct = strings.Replace(acct, "acct:", "", -1) - - actorDomain := strings.Split(acct, "@") - - if len(actorDomain) < 2 { - c.Status(fiber.StatusBadRequest) - return c.Send([]byte("accepts only subject form of acct:board@instance")) - } - - if actorDomain[0] == "main" { - actorDomain[0] = "" - } else { - actorDomain[0] = "/" + actorDomain[0] - } - - actor := activitypub.Actor{Id: config.TP + "" + actorDomain[1] + "" + actorDomain[0]} - if res, err := actor.IsLocal(); err == nil && !res { - c.Status(fiber.StatusBadRequest) - return c.Send([]byte("actor not local")) - } else if err != nil { - return util.MakeError(err, "Webfinger") - } - - var finger activitypub.Webfinger - var link activitypub.WebfingerLink - - finger.Subject = "acct:" + actorDomain[0] + "@" + actorDomain[1] - link.Rel = "self" - link.Type = "application/activity+json" - link.Href = config.TP + "" + actorDomain[1] + "" + actorDomain[0] - - finger.Links = append(finger.Links, link) - - enc, _ := json.Marshal(finger) - - c.Set("Content-Type", config.ActivityStreams) - return c.Send(enc) -} |