@@ -6,9 +6,10 @@ import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"log"
|
||||
"path"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
|
||||
"github.com/keys-pub/keys"
|
||||
"github.com/oklog/ulid/v2"
|
||||
"github.com/sour-is/ev/pkg/es/event"
|
||||
@@ -52,9 +53,9 @@ func (a *SaltyUser) OnUserRegister(name string, pubkey *keys.EdX25519PublicKey)
|
||||
func (a *SaltyUser) Nick() string { return a.name }
|
||||
func (a *SaltyUser) Inbox() string { return a.inbox.String() }
|
||||
func (a *SaltyUser) Pubkey() string { return a.pubkey.String() }
|
||||
func (s *SaltyUser) Endpoint(ctx context.Context) string {
|
||||
func (s *SaltyUser) Endpoint(ctx context.Context) (string, error) {
|
||||
svc := gql.FromContext[contextKey, *service](ctx, saltyKey)
|
||||
return path.Join(svc.BaseURL(), s.inbox.String())
|
||||
return url.JoinPath(svc.BaseURL(), s.inbox.String())
|
||||
}
|
||||
|
||||
type UserRegistered struct {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"path"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/keys-pub/keys"
|
||||
@@ -124,12 +124,14 @@ func (s *service) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
basePath, _ := url.JoinPath(s.baseURL, a.inbox.String())
|
||||
|
||||
err = json.NewEncoder(w).Encode(
|
||||
struct {
|
||||
Endpoint string `json:"endpoint"`
|
||||
Key string `json:"key"`
|
||||
}{
|
||||
Endpoint: path.Join(s.baseURL, a.inbox.String()),
|
||||
Endpoint: basePath,
|
||||
Key: a.pubkey.ID().String(),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user