| 1 | diff --git a/internal/webui/public.html b/internal/webui/public.html |
| 2 | index 5eae294..1337ffc 100644 |
| 3 | --- a/internal/webui/public.html |
| 4 | +++ b/internal/webui/public.html |
| 5 | @@ -20,8 +20,7 @@ |
| 6 | {{end}}<p>{{range index $c "links"}}{{$l := asMap .}}{{if str (index $l "href")}}<a href="{{str (index $l "href")}}">{{str (index $l "label")}}</a> {{else}}<button type="button" data-copy="{{str (index $l "copy")}}">{{str (index $l "label")}}</button> {{end}}{{end}}{{if index $c "hidden"}}<small>sign in for {{str (index $c "hidden")}} more</small>{{end}}<output role="status"></output></p> |
| 7 | {{with str (index $c "qr")}}<details><summary>QR code</summary><img src="/qr.svg?text={{urlquery .}}" alt="QR code" width="200" height="200"></details>{{end}} |
| 8 | </connect-card> |
| 9 | -{{end}}{{end}}<h2>Recent activity</h2> |
| 10 | -{{if .Error}}{{template "alert" .Error}}{{else}}{{template "eventList" .}}{{end}} |
| 11 | +{{end}}{{end}} |
| 12 | </section> |
| 13 | {{end}} |
| 14 | |
| 15 | diff --git a/internal/webui/public_pages.go b/internal/webui/public_pages.go |
| 16 | index c7a00ae..5657e5b 100644 |
| 17 | --- a/internal/webui/public_pages.go |
| 18 | +++ b/internal/webui/public_pages.go |
| 19 | @@ -33,8 +33,6 @@ func (a *App) publicFeed(ctx context.Context, tab, actor string, values url.Valu |
| 20 | filter = map[string]any{"authors": []string{actor}, "limit": 50} |
| 21 | case "articles": |
| 22 | filter = map[string]any{"kinds": []int{30023}, "limit": 50} |
| 23 | - case "home": |
| 24 | - filter = map[string]any{"kinds": []int{1, 30023}, "limit": 12} |
| 25 | case "sites": |
| 26 | filter = map[string]any{"kinds": []int{sites.KindSite, sites.KindNamedSite}, "limit": 100} |
| 27 | default: |
| 28 | diff --git a/internal/webui/public_pages_test.go b/internal/webui/public_pages_test.go |
| 29 | index 583a03e..c88fa48 100644 |
| 30 | --- a/internal/webui/public_pages_test.go |
| 31 | +++ b/internal/webui/public_pages_test.go |
| 32 | @@ -11,15 +11,42 @@ import ( |
| 33 | "github.com/FelineStateMachine/tinyrelay/internal/policy" |
| 34 | ) |
| 35 | |
| 36 | -type publicBackend struct{ fakeBackend } |
| 37 | +type publicBackend struct { |
| 38 | + fakeBackend |
| 39 | + eventQueries int |
| 40 | +} |
| 41 | |
| 42 | func (b *publicBackend) Query(_ context.Context, method string, _ []json.RawMessage, actor string) (any, error) { |
| 43 | if method != "queryevents" { |
| 44 | return b.fakeBackend.Query(context.Background(), method, nil, actor) |
| 45 | } |
| 46 | + b.eventQueries++ |
| 47 | return []map[string]any{{"id": "event-1", "pubkey": actor, "content": "visible result"}}, nil |
| 48 | } |
| 49 | |
| 50 | +func TestHomeShowsRelayInformationWithoutQueryingSocialEvents(t *testing.T) { |
| 51 | + owner := strings.Repeat("a", 64) |
| 52 | + for _, actor := range []string{"", owner} { |
| 53 | + backend := &publicBackend{fakeBackend: fakeBackend{policy: policy.Defaults(owner)}} |
| 54 | + backend.policy.Description = "A place to connect." |
| 55 | + app, err := New(backend, Options{Actor: func(*http.Request) (string, error) { return actor, nil }}) |
| 56 | + if err != nil { |
| 57 | + t.Fatal(err) |
| 58 | + } |
| 59 | + for _, path := range []string{"/", "/?kinds=all"} { |
| 60 | + recorder := httptest.NewRecorder() |
| 61 | + app.ServeHTTP(recorder, httptest.NewRequest(http.MethodGet, path, nil)) |
| 62 | + body := recorder.Body.String() |
| 63 | + if recorder.Code != http.StatusOK || !strings.Contains(body, "A place to connect.") || !strings.Contains(body, `href="/social"`) { |
| 64 | + t.Fatalf("home lost relay information or Social navigation: status=%d", recorder.Code) |
| 65 | + } |
| 66 | + if backend.eventQueries != 0 || strings.Contains(body, "Recent activity") || strings.Contains(body, "visible result") { |
| 67 | + t.Fatalf("home still loads the duplicate feed: queries=%d", backend.eventQueries) |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | type articleBackend struct{ fakeBackend } |
| 74 | |
| 75 | func (b *articleBackend) Query(_ context.Context, method string, _ []json.RawMessage, _ string) (any, error) { |
| 76 | diff --git a/internal/webui/webui.go b/internal/webui/webui.go |
| 77 | index 60858ef..4fb8827 100644 |
| 78 | --- a/internal/webui/webui.go |
| 79 | +++ b/internal/webui/webui.go |
| 80 | @@ -860,7 +860,7 @@ func (a *App) page(writer http.ResponseWriter, request *http.Request) { |
| 81 | actor = "" |
| 82 | } |
| 83 | data := PageData{Tab: tab, Query: request.URL.Query()} |
| 84 | - if tab == "inbox" || tab == "outbox" || tab == "search" || tab == "articles" || tab == "home" || tab == "sites" { |
| 85 | + if tab == "inbox" || tab == "outbox" || tab == "search" || tab == "articles" || tab == "sites" { |
| 86 | feed, feedErr := a.publicFeed(request.Context(), tab, actor, request.URL.Query()) |
| 87 | if feedErr != nil { |
| 88 | data.Error = feedErr.Error() |