Webfinger might work now
This commit is contained in:
parent
935fc33094
commit
d1e93ad8f0
1 changed files with 19 additions and 5 deletions
|
@ -21,6 +21,7 @@ import (
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
"gitlab.com/mstarongitlab/goutils/other"
|
"gitlab.com/mstarongitlab/goutils/other"
|
||||||
"gitlab.com/mstarongitlab/linstrom/server"
|
"gitlab.com/mstarongitlab/linstrom/server"
|
||||||
|
"gitlab.com/mstarongitlab/linstrom/storage"
|
||||||
"gitlab.com/mstarongitlab/linstrom/types"
|
"gitlab.com/mstarongitlab/linstrom/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -55,12 +56,26 @@ func WebfingerEndpoint(server *server.Server) func(http.ResponseWriter, *http.Re
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
person, err := server.Storage.GetPersonByName(acc.Name)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, storage.ErrNotFound) {
|
||||||
|
http.Error(w, fmt.Sprintf("Account %s not found", acc), http.StatusNotFound)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
http.Error(w, fmt.Sprintf("Internal error: %s, please report", err.Error()), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response := WebfingerResponse{
|
response := WebfingerResponse{
|
||||||
Links: []webfingerLink{
|
Links: []webfingerLink{
|
||||||
{
|
{
|
||||||
Rel: "me",
|
Rel: "me",
|
||||||
Type: "application/activity+json",
|
Type: "application/activity+json",
|
||||||
Target: *other.Must(url.Parse("https://example.com")), // TODO: Replace this with actual link generation
|
Target: *other.Must(url.Parse(fmt.Sprintf(
|
||||||
|
"https://%s/api/ap/user/%s",
|
||||||
|
server.Config.General.Domain,
|
||||||
|
person.Uid,
|
||||||
|
))),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -68,8 +83,7 @@ func WebfingerEndpoint(server *server.Server) func(http.ResponseWriter, *http.Re
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// acct:bugle@bugle.lol
|
// turns "acct:bugle@bugle.lol" into { Name: bugle, Host: bugle.lol }
|
||||||
|
|
||||||
func getAccountFromWebfingerResource(r string) (*types.AccountHandle, error) {
|
func getAccountFromWebfingerResource(r string) (*types.AccountHandle, error) {
|
||||||
acctCheck, acc, found := strings.Cut(r, ":")
|
acctCheck, acc, found := strings.Cut(r, ":")
|
||||||
if !found || acctCheck != "acct" {
|
if !found || acctCheck != "acct" {
|
||||||
|
|
Loading…
Reference in a new issue