refactor!: working WD-4 user discovery

This commit is contained in:
DevMiner 2024-08-20 22:43:26 +02:00
parent cf0053312d
commit 61891d891a
91 changed files with 12768 additions and 5562 deletions

32
internal/utils/fiber.go Normal file
View file

@ -0,0 +1,32 @@
package utils
import (
"bytes"
"github.com/gofiber/fiber/v2"
"github.com/valyala/fasthttp/fasthttpadaptor"
"io"
"net/http"
)
func ConvertToStdRequest(c *fiber.Ctx) (*http.Request, error) {
stdReq := &http.Request{}
if err := fasthttpadaptor.ConvertRequest(c.Context(), stdReq, true); err != nil {
return nil, err
}
return stdReq, nil
}
func CopyBody(req *http.Request) ([]byte, error) {
body, err := io.ReadAll(req.Body)
if err != nil {
return nil, err
}
if err := req.Body.Close(); err != nil {
return nil, err
}
req.Body = io.NopCloser(bytes.NewBuffer(body))
return body, nil
}

View file

@ -73,3 +73,23 @@ func NoteAPIURL(uuid uuid.UUID) *lysand.URL {
newPath := &url.URL{Path: fmt.Sprintf("/api/notes/%s/", uuid.String())}
return lysand.URLFromStd(config.C.PublicAddress.ResolveReference(newPath))
}
func InstanceMetadataAPIURL() *lysand.URL {
newPath := &url.URL{Path: "/.well-known/versia/"}
return lysand.URLFromStd(config.C.PublicAddress.ResolveReference(newPath))
}
func InstanceMetadataAdminsAPIURL() *lysand.URL {
newPath := &url.URL{Path: "/.well-known/versia/admins/"}
return lysand.URLFromStd(config.C.PublicAddress.ResolveReference(newPath))
}
func InstanceMetadataModeratorsAPIURL() *lysand.URL {
newPath := &url.URL{Path: "/.well-known/versia/moderators/"}
return lysand.URLFromStd(config.C.PublicAddress.ResolveReference(newPath))
}
func SharedInboxAPIURL() *lysand.URL {
newPath := &url.URL{Path: "/api/inbox/"}
return lysand.URLFromStd(config.C.PublicAddress.ResolveReference(newPath))
}