forked from tangled.org/core
this repo has no description

appview/keys: be a little more http

Changed files
+13 -3
appview
state
knotserver
+8 -3
appview/state/state.go
···
user = strings.TrimPrefix(user, "@")
if user == "" {
-
w.Write([]byte("not found"))
return
}
id, err := auth.ResolveIdent(r.Context(), user)
if err != nil {
-
w.Write([]byte("not found"))
return
}
pubKeys, err := s.db.GetPublicKeys(id.DID.String())
if err != nil {
-
w.Write([]byte("not found"))
return
}
···
user = strings.TrimPrefix(user, "@")
if user == "" {
+
w.WriteHeader(http.StatusBadRequest)
return
}
id, err := auth.ResolveIdent(r.Context(), user)
if err != nil {
+
w.WriteHeader(http.StatusInternalServerError)
return
}
pubKeys, err := s.db.GetPublicKeys(id.DID.String())
if err != nil {
+
w.WriteHeader(http.StatusNotFound)
+
return
+
}
+
+
if len(pubKeys) == 0 {
+
w.WriteHeader(http.StatusNotFound)
return
}
+5
knotserver/jetstream.go
···
}
defer resp.Body.Close()
if ct := resp.Header.Get("Content-Type"); !strings.HasPrefix(ct, "text/plain") {
return fmt.Errorf("unexpected content type: %s", ct)
}
···
}
defer resp.Body.Close()
+
if resp.StatusCode == http.StatusNotFound {
+
l.Info("no keys found for did", "did", did)
+
return nil
+
}
+
if ct := resp.Header.Get("Content-Type"); !strings.HasPrefix(ct, "text/plain") {
return fmt.Errorf("unexpected content type: %s", ct)
}