Skip to content

Commit

Permalink
return 404 in .well-known/webfinger when user does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Oct 1, 2023
1 parent c5e4943 commit ed373f8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fed/webfinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package fed
import (
"database/sql"
"encoding/json"
"errors"
"fmt"
"github.com/dimkr/tootik/cfg"
"log/slog"
Expand Down Expand Up @@ -71,7 +72,10 @@ func (h *webFingerHandler) Handle(w http.ResponseWriter, r *http.Request) {
id := fmt.Sprintf("https://%s/user/%s", cfg.Domain, fields[0])

actorString := ""
if err := h.DB.QueryRowContext(r.Context(), `select actor from persons where id = ?`, id).Scan(&actorString); err != nil {
if err := h.DB.QueryRowContext(r.Context(), `select actor from persons where id = ?`, id).Scan(&actorString); err != nil && errors.Is(err, sql.ErrNoRows) {
w.WriteHeader(http.StatusNotFound)
return
} else if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
Expand Down

0 comments on commit ed373f8

Please sign in to comment.