Monorepo for Tangled tangled.org

appview/keys: be a little more http

Changed files
+13 -3
appview
state
knotserver
+8 -3
appview/state/state.go
··· 160 user = strings.TrimPrefix(user, "@") 161 162 if user == "" { 163 - w.Write([]byte("not found")) 164 return 165 } 166 167 id, err := auth.ResolveIdent(r.Context(), user) 168 if err != nil { 169 - w.Write([]byte("not found")) 170 return 171 } 172 173 pubKeys, err := s.db.GetPublicKeys(id.DID.String()) 174 if err != nil { 175 - w.Write([]byte("not found")) 176 return 177 } 178
··· 160 user = strings.TrimPrefix(user, "@") 161 162 if user == "" { 163 + w.WriteHeader(http.StatusBadRequest) 164 return 165 } 166 167 id, err := auth.ResolveIdent(r.Context(), user) 168 if err != nil { 169 + w.WriteHeader(http.StatusInternalServerError) 170 return 171 } 172 173 pubKeys, err := s.db.GetPublicKeys(id.DID.String()) 174 if err != nil { 175 + w.WriteHeader(http.StatusNotFound) 176 + return 177 + } 178 + 179 + if len(pubKeys) == 0 { 180 + w.WriteHeader(http.StatusNotFound) 181 return 182 } 183
+5
knotserver/jetstream.go
··· 177 } 178 defer resp.Body.Close() 179 180 if ct := resp.Header.Get("Content-Type"); !strings.HasPrefix(ct, "text/plain") { 181 return fmt.Errorf("unexpected content type: %s", ct) 182 }
··· 177 } 178 defer resp.Body.Close() 179 180 + if resp.StatusCode == http.StatusNotFound { 181 + l.Info("no keys found for did", "did", did) 182 + return nil 183 + } 184 + 185 if ct := resp.Header.Get("Content-Type"); !strings.HasPrefix(ct, "text/plain") { 186 return fmt.Errorf("unexpected content type: %s", ct) 187 }