From 092361248dc91e9bdf2aab3b25793af9c5425b30 Mon Sep 17 00:00:00 2001 From: Dima Krasner Date: Mon, 18 Nov 2024 22:38:02 +0200 Subject: [PATCH] apply all gopls fixes --- ap/array_test.go | 6 +- fed/blocklist_test.go | 12 +-- fed/deliver_test.go | 70 +++++++------- fed/followers.go | 2 +- fed/inbox.go | 2 +- fed/resolve_test.go | 210 ++++++++++++++++++++--------------------- fed/verify.go | 3 +- front/cache.go | 3 +- front/finger/finger.go | 4 +- front/gemini/gemini.go | 4 +- front/handler.go | 18 ++-- front/user/create.go | 6 +- icon/generate.go | 10 +- test/fts_test.go | 4 +- 14 files changed, 176 insertions(+), 178 deletions(-) diff --git a/ap/array_test.go b/ap/array_test.go index e3864f63..bb853407 100644 --- a/ap/array_test.go +++ b/ap/array_test.go @@ -122,7 +122,7 @@ func TestArrayMarshal_OneTag(t *testing.T) { }{ ID: "a", Tag: []Tag{ - Tag{ + { Type: Hashtag, Name: "b", }, @@ -140,11 +140,11 @@ func TestArrayMarshal_TwoTags(t *testing.T) { }{ ID: "a", Tag: []Tag{ - Tag{ + { Type: Hashtag, Name: "b", }, - Tag{ + { Type: Emoji, Name: "c", }, diff --git a/fed/blocklist_test.go b/fed/blocklist_test.go index a32f54f6..9fde60d1 100644 --- a/fed/blocklist_test.go +++ b/fed/blocklist_test.go @@ -26,7 +26,7 @@ func TestBlockList_NotBlockedDomain(t *testing.T) { blockList := BlockList{} blockList.domains = map[string]struct{}{ - "0.0.0.0.com": struct{}{}, + "0.0.0.0.com": {}, } assert.False(blockList.Contains("127.0.0.1.com")) @@ -37,7 +37,7 @@ func TestBlockList_BlockedDomain(t *testing.T) { blockList := BlockList{} blockList.domains = map[string]struct{}{ - "0.0.0.0.com": struct{}{}, + "0.0.0.0.com": {}, } assert.True(blockList.Contains("0.0.0.0.com")) @@ -48,7 +48,7 @@ func TestBlockList_BlockedSubdomain(t *testing.T) { blockList := BlockList{} blockList.domains = map[string]struct{}{ - "social.0.0.0.0.com": struct{}{}, + "social.0.0.0.0.com": {}, } assert.True(blockList.Contains("social.0.0.0.0.com")) @@ -59,7 +59,7 @@ func TestBlockList_NotBlockedSubdomain(t *testing.T) { blockList := BlockList{} blockList.domains = map[string]struct{}{ - "social.0.0.0.0.com": struct{}{}, + "social.0.0.0.0.com": {}, } assert.False(blockList.Contains("blog.0.0.0.0.com")) @@ -70,7 +70,7 @@ func TestBlockList_BlockedSubdomainByDomain(t *testing.T) { blockList := BlockList{} blockList.domains = map[string]struct{}{ - "0.0.0.0.com": struct{}{}, + "0.0.0.0.com": {}, } assert.True(blockList.Contains("social.0.0.0.0.com")) @@ -81,7 +81,7 @@ func TestBlockList_BlockedSubdomainByDomainEndsWithDot(t *testing.T) { blockList := BlockList{} blockList.domains = map[string]struct{}{ - "0.0.0.0.com": struct{}{}, + "0.0.0.0.com": {}, } assert.True(blockList.Contains("social.0.0.0.0.com.")) diff --git a/fed/deliver_test.go b/fed/deliver_test.go index 87ea6df7..6370ca76 100644 --- a/fed/deliver_test.go +++ b/fed/deliver_test.go @@ -51,13 +51,13 @@ func TestDeliver_TwoUsersTwoPosts(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/dan": testResponse{ + "https://ip6-allnodes/inbox/dan": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -127,7 +127,7 @@ func TestDeliver_TwoUsersTwoPosts(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -159,13 +159,13 @@ func TestDeliver_ForwardedPost(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/dan": testResponse{ + "https://ip6-allnodes/inbox/dan": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -256,13 +256,13 @@ func TestDeliver_OneFailed(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/dan": testResponse{ + "https://ip6-allnodes/inbox/dan": { Response: &http.Response{ StatusCode: http.StatusInternalServerError, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -332,7 +332,7 @@ func TestDeliver_OneFailed(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -364,13 +364,13 @@ func TestDeliver_OneFailedRetry(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/dan": testResponse{ + "https://ip6-allnodes/inbox/dan": { Response: &http.Response{ StatusCode: http.StatusInternalServerError, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -427,7 +427,7 @@ func TestDeliver_OneFailedRetry(t *testing.T) { cfg.DeliveryRetryInterval = 0 client.Data = map[string]testResponse{ - "https://ip6-allnodes/inbox/dan": testResponse{ + "https://ip6-allnodes/inbox/dan": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -461,7 +461,7 @@ func TestDeliver_OneInvalidURLRetry(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -545,13 +545,13 @@ func TestDeliver_MaxAttempts(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/dan": testResponse{ + "https://ip6-allnodes/inbox/dan": { Response: &http.Response{ StatusCode: http.StatusInternalServerError, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -609,7 +609,7 @@ func TestDeliver_MaxAttempts(t *testing.T) { cfg.MaxDeliveryAttempts = 2 client.Data = map[string]testResponse{ - "https://ip6-allnodes/inbox/dan": testResponse{ + "https://ip6-allnodes/inbox/dan": { Response: &http.Response{ StatusCode: http.StatusInternalServerError, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -643,13 +643,13 @@ func TestDeliver_SharedInbox(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/nobody": testResponse{ + "https://ip6-allnodes/inbox/nobody": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/frank": testResponse{ + "https://ip6-allnodes/inbox/frank": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -734,13 +734,13 @@ func TestDeliver_SharedInboxRetry(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/nobody": testResponse{ + "https://ip6-allnodes/inbox/nobody": { Response: &http.Response{ StatusCode: http.StatusInternalServerError, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/frank": testResponse{ + "https://ip6-allnodes/inbox/frank": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -807,7 +807,7 @@ func TestDeliver_SharedInboxRetry(t *testing.T) { cfg.DeliveryRetryInterval = 0 client.Data = map[string]testResponse{ - "https://ip6-allnodes/inbox/nobody": testResponse{ + "https://ip6-allnodes/inbox/nobody": { Response: &http.Response{ StatusCode: http.StatusInternalServerError, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -839,13 +839,13 @@ func TestDeliver_SharedInboxUnknownActor(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/nobody": testResponse{ + "https://ip6-allnodes/inbox/nobody": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/frank": testResponse{ + "https://ip6-allnodes/inbox/frank": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -931,13 +931,13 @@ func TestDeliver_SharedInboxSingleWorker(t *testing.T) { cfg.DeliveryWorkers = 1 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/nobody": testResponse{ + "https://ip6-allnodes/inbox/nobody": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/frank": testResponse{ + "https://ip6-allnodes/inbox/frank": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -1022,13 +1022,13 @@ func TestDeliver_SameInbox(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/dan": testResponse{ + "https://ip6-allnodes/inbox/dan": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/frank": testResponse{ + "https://ip6-allnodes/inbox/frank": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -1113,13 +1113,13 @@ func TestDeliver_ToAndCCDuplicates(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/dan": testResponse{ + "https://ip6-allnodes/inbox/dan": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -1189,7 +1189,7 @@ func TestDeliver_ToAndCCDuplicates(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -1221,13 +1221,13 @@ func TestDeliver_PublicInTo(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/dan": testResponse{ + "https://ip6-allnodes/inbox/dan": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -1297,7 +1297,7 @@ func TestDeliver_PublicInTo(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -1329,13 +1329,13 @@ func TestDeliver_AuthorInTo(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://ip6-allnodes/inbox/dan": testResponse{ + "https://ip6-allnodes/inbox/dan": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), }, }, - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), @@ -1405,7 +1405,7 @@ func TestDeliver_AuthorInTo(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://ip6-allnodes/inbox/erin": testResponse{ + "https://ip6-allnodes/inbox/erin": { Response: &http.Response{ StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte(`{}`))), diff --git a/fed/followers.go b/fed/followers.go index 7685f5e2..2cd024aa 100644 --- a/fed/followers.go +++ b/fed/followers.go @@ -120,7 +120,7 @@ func (f partialFollowers) Digest(ctx context.Context, db *sql.DB, domain string, func (l *Listener) handleFollowers(w http.ResponseWriter, r *http.Request) { name := r.PathValue("username") - sender, err := l.verify(r.Context(), r, nil, ap.InstanceActor) + sender, err := l.verify(r, nil, ap.InstanceActor) if err != nil { slog.Warn("Failed to verify followers request", "error", err) w.WriteHeader(http.StatusUnauthorized) diff --git a/fed/inbox.go b/fed/inbox.go index 94625a17..ec882a84 100644 --- a/fed/inbox.go +++ b/fed/inbox.go @@ -67,7 +67,7 @@ func (l *Listener) handleInbox(w http.ResponseWriter, r *http.Request) { flags |= ap.Offline } - sender, err := l.verify(r.Context(), r, body, flags) + sender, err := l.verify(r, body, flags) if err != nil { if errors.Is(err, ErrActorGone) { w.WriteHeader(http.StatusOK) diff --git a/fed/resolve_test.go b/fed/resolve_test.go index 6def67c1..22ea4b05 100644 --- a/fed/resolve_test.go +++ b/fed/resolve_test.go @@ -158,7 +158,7 @@ func TestResolve_FederatedInstanceActor(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:0.0.0.0@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:0.0.0.0@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -181,7 +181,7 @@ func TestResolve_FederatedInstanceActor(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -334,7 +334,7 @@ func TestResolve_FederatedActorFirstTime(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -357,7 +357,7 @@ func TestResolve_FederatedActorFirstTime(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -414,7 +414,7 @@ func TestResolve_FederatedActorFirstTimeThroughMention(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -437,7 +437,7 @@ func TestResolve_FederatedActorFirstTimeThroughMention(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -567,7 +567,7 @@ func TestResolve_FederatedActorFirstTimeInvalidWebFingerLink(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -595,7 +595,7 @@ func TestResolve_FederatedActorFirstTimeInvalidWebFingerLink(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -652,7 +652,7 @@ func TestResolve_FederatedActorFirstTimeActorIDMismatch(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -675,7 +675,7 @@ func TestResolve_FederatedActorFirstTimeActorIDMismatch(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -729,7 +729,7 @@ func TestResolve_FederatedActorCached(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -752,7 +752,7 @@ func TestResolve_FederatedActorCached(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -815,7 +815,7 @@ func TestResolve_FederatedActorCachedInvalidActorHost(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -872,7 +872,7 @@ func TestResolve_FederatedActorCachedActorHostWithPort(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -929,7 +929,7 @@ func TestResolve_FederatedActorCachedActorHostSubdomain(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -952,7 +952,7 @@ func TestResolve_FederatedActorCachedActorHostSubdomain(t *testing.T) { }`, ), }, - "https://tootik.0.0.0.0/user/dan": testResponse{ + "https://tootik.0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -992,7 +992,7 @@ func TestResolve_FederatedActorCachedActorHostSubdomain(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1015,7 +1015,7 @@ func TestResolve_FederatedActorCachedActorHostSubdomain(t *testing.T) { }`, ), }, - "https://tootik.0.0.0.0/user/dan": testResponse{ + "https://tootik.0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1065,7 +1065,7 @@ func TestResolve_FederatedActorCachedActorHostSubdomainFetchedRecently(t *testin cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1088,7 +1088,7 @@ func TestResolve_FederatedActorCachedActorHostSubdomainFetchedRecently(t *testin }`, ), }, - "https://tootik.0.0.0.0/user/dan": testResponse{ + "https://tootik.0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1154,7 +1154,7 @@ func TestResolve_FederatedActorCachedActorIDChanged(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1177,7 +1177,7 @@ func TestResolve_FederatedActorCachedActorIDChanged(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1217,7 +1217,7 @@ func TestResolve_FederatedActorCachedActorIDChanged(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1270,7 +1270,7 @@ func TestResolve_FederatedActorCachedButBlocked(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1293,7 +1293,7 @@ func TestResolve_FederatedActorCachedButBlocked(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1336,7 +1336,7 @@ func TestResolve_FederatedActorCachedButBlocked(t *testing.T) { assert.Equal("https://0.0.0.0/inbox/dan", actor.Inbox) blockList.domains = map[string]struct{}{ - "0.0.0.0": struct{}{}, + "0.0.0.0": {}, } _, err = resolver.ResolveID(context.Background(), key, "https://0.0.0.0/user/dan", 0) @@ -1363,7 +1363,7 @@ func TestResolve_FederatedActorOldCache(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1386,7 +1386,7 @@ func TestResolve_FederatedActorOldCache(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1426,7 +1426,7 @@ func TestResolve_FederatedActorOldCache(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1449,7 +1449,7 @@ func TestResolve_FederatedActorOldCache(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1504,7 +1504,7 @@ func TestResolve_FederatedActorOldCacheWasSuspended(t *testing.T) { cfg.FillDefaults() client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1527,7 +1527,7 @@ func TestResolve_FederatedActorOldCacheWasSuspended(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1566,7 +1566,7 @@ func TestResolve_FederatedActorOldCacheWasSuspended(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1589,7 +1589,7 @@ func TestResolve_FederatedActorOldCacheWasSuspended(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1646,7 +1646,7 @@ func TestResolve_FederatedActorOldCacheWasNew(t *testing.T) { cfg.FillDefaults() client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1669,7 +1669,7 @@ func TestResolve_FederatedActorOldCacheWasNew(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1706,7 +1706,7 @@ func TestResolve_FederatedActorOldCacheWasNew(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1729,7 +1729,7 @@ func TestResolve_FederatedActorOldCacheWasNew(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1785,7 +1785,7 @@ func TestResolve_FederatedActorOldCacheUpdateFailed(t *testing.T) { cfg.FillDefaults() client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1808,7 +1808,7 @@ func TestResolve_FederatedActorOldCacheUpdateFailed(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1845,7 +1845,7 @@ func TestResolve_FederatedActorOldCacheUpdateFailed(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1868,7 +1868,7 @@ func TestResolve_FederatedActorOldCacheUpdateFailed(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusInternalServerError, `{}`, @@ -1906,7 +1906,7 @@ func TestResolve_FederatedActorOldCacheStillNew(t *testing.T) { cfg.FillDefaults() client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1929,7 +1929,7 @@ func TestResolve_FederatedActorOldCacheStillNew(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -1966,7 +1966,7 @@ func TestResolve_FederatedActorOldCacheStillNew(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -1989,7 +1989,7 @@ func TestResolve_FederatedActorOldCacheStillNew(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -2035,7 +2035,7 @@ func TestResolve_FederatedActorOldCacheWasOld(t *testing.T) { cfg.FillDefaults() client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2058,7 +2058,7 @@ func TestResolve_FederatedActorOldCacheWasOld(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -2099,7 +2099,7 @@ func TestResolve_FederatedActorOldCacheWasOld(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2122,7 +2122,7 @@ func TestResolve_FederatedActorOldCacheWasOld(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -2169,7 +2169,7 @@ func TestResolve_FederatedActorOldCacheWasNewNowUnknown(t *testing.T) { cfg.FillDefaults() client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2192,7 +2192,7 @@ func TestResolve_FederatedActorOldCacheWasNewNowUnknown(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -2230,7 +2230,7 @@ func TestResolve_FederatedActorOldCacheWasNewNowUnknown(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2253,7 +2253,7 @@ func TestResolve_FederatedActorOldCacheWasNewNowUnknown(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -2300,7 +2300,7 @@ func TestResolve_FederatedActorOldCacheFetchedRecently(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2323,7 +2323,7 @@ func TestResolve_FederatedActorOldCacheFetchedRecently(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -2389,7 +2389,7 @@ func TestResolve_FederatedActorOldCacheButOffline(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2412,7 +2412,7 @@ func TestResolve_FederatedActorOldCacheButOffline(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -2478,7 +2478,7 @@ func TestResolve_FederatedActorOldCacheInvalidID(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2535,7 +2535,7 @@ func TestResolve_FederatedActorOldCacheInvalidWebFingerResponse(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2558,7 +2558,7 @@ func TestResolve_FederatedActorOldCacheInvalidWebFingerResponse(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -2598,7 +2598,7 @@ func TestResolve_FederatedActorOldCacheInvalidWebFingerResponse(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `abc`, @@ -2635,7 +2635,7 @@ func TestResolve_FederatedActorOldCacheBigWebFingerResponse(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2658,7 +2658,7 @@ func TestResolve_FederatedActorOldCacheBigWebFingerResponse(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -2698,7 +2698,7 @@ func TestResolve_FederatedActorOldCacheBigWebFingerResponse(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2753,7 +2753,7 @@ func TestResolve_FederatedActorOldCacheInvalidActor(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2776,7 +2776,7 @@ func TestResolve_FederatedActorOldCacheInvalidActor(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -2816,7 +2816,7 @@ func TestResolve_FederatedActorOldCacheInvalidActor(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2839,7 +2839,7 @@ func TestResolve_FederatedActorOldCacheInvalidActor(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `abc`, @@ -2875,7 +2875,7 @@ func TestResolve_FederatedActorOldCacheBigActor(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2898,7 +2898,7 @@ func TestResolve_FederatedActorOldCacheBigActor(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -2938,7 +2938,7 @@ func TestResolve_FederatedActorOldCacheBigActor(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -2961,7 +2961,7 @@ func TestResolve_FederatedActorOldCacheBigActor(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -3013,7 +3013,7 @@ func TestResolve_FederatedActorNoProfileLink(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3036,7 +3036,7 @@ func TestResolve_FederatedActorNoProfileLink(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -3076,7 +3076,7 @@ func TestResolve_FederatedActorNoProfileLink(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3135,7 +3135,7 @@ func TestResolve_FederatedActorOldCacheWebFingerError(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3158,7 +3158,7 @@ func TestResolve_FederatedActorOldCacheWebFingerError(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -3198,7 +3198,7 @@ func TestResolve_FederatedActorOldCacheWebFingerError(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Error: errors.New("a"), }, } @@ -3237,7 +3237,7 @@ func TestResolve_FederatedActorOldCacheActorError(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3260,7 +3260,7 @@ func TestResolve_FederatedActorOldCacheActorError(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -3300,7 +3300,7 @@ func TestResolve_FederatedActorOldCacheActorError(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3323,7 +3323,7 @@ func TestResolve_FederatedActorOldCacheActorError(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Error: errors.New("a"), }, } @@ -3362,7 +3362,7 @@ func TestResolve_FederatedActorOldCacheActorDeleted(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3385,7 +3385,7 @@ func TestResolve_FederatedActorOldCacheActorDeleted(t *testing.T) { }`, ), }, - "https://0.0.0.0/user/dan": testResponse{ + "https://0.0.0.0/user/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -3444,7 +3444,7 @@ func TestResolve_FederatedActorOldCacheActorDeleted(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusGone, `{ @@ -3498,7 +3498,7 @@ func TestResolve_FederatedActorFirstTimeWrongID(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3521,7 +3521,7 @@ func TestResolve_FederatedActorFirstTimeWrongID(t *testing.T) { }`, ), }, - "https://0.0.0.0/users/dan": testResponse{ + "https://0.0.0.0/users/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -3578,7 +3578,7 @@ func TestResolve_FederatedActorFirstTimeDeleted(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusGone, `{ @@ -3657,7 +3657,7 @@ func TestResolve_FederatedActorFirstTimeTooYoung(t *testing.T) { cfg.FillDefaults() client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3680,7 +3680,7 @@ func TestResolve_FederatedActorFirstTimeTooYoung(t *testing.T) { }`, ), }, - "https://0.0.0.0/users/dan": testResponse{ + "https://0.0.0.0/users/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -3733,7 +3733,7 @@ func TestResolve_FederatedActorFirstTimeSuspended(t *testing.T) { cfg.FillDefaults() client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3756,7 +3756,7 @@ func TestResolve_FederatedActorFirstTimeSuspended(t *testing.T) { }`, ), }, - "https://0.0.0.0/users/dan": testResponse{ + "https://0.0.0.0/users/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -3812,7 +3812,7 @@ func TestResolve_FederatedActorWrongIDCached(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3835,7 +3835,7 @@ func TestResolve_FederatedActorWrongIDCached(t *testing.T) { }`, ), }, - "https://0.0.0.0/users/dan": testResponse{ + "https://0.0.0.0/users/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -3898,7 +3898,7 @@ func TestResolve_FederatedActorWrongIDCachedOldCache(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3921,7 +3921,7 @@ func TestResolve_FederatedActorWrongIDCachedOldCache(t *testing.T) { }`, ), }, - "https://0.0.0.0/users/dan": testResponse{ + "https://0.0.0.0/users/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -3961,7 +3961,7 @@ func TestResolve_FederatedActorWrongIDCachedOldCache(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -3984,7 +3984,7 @@ func TestResolve_FederatedActorWrongIDCachedOldCache(t *testing.T) { }`, ), }, - "https://0.0.0.0/users/dan": testResponse{ + "https://0.0.0.0/users/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -4034,7 +4034,7 @@ func TestResolve_FederatedActorWrongIDOldCache(t *testing.T) { cfg.MinActorAge = 0 client := newTestClient(map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -4057,7 +4057,7 @@ func TestResolve_FederatedActorWrongIDOldCache(t *testing.T) { }`, ), }, - "https://0.0.0.0/users/dan": testResponse{ + "https://0.0.0.0/users/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -4097,7 +4097,7 @@ func TestResolve_FederatedActorWrongIDOldCache(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -4120,7 +4120,7 @@ func TestResolve_FederatedActorWrongIDOldCache(t *testing.T) { }`, ), }, - "https://0.0.0.0/users/dan": testResponse{ + "https://0.0.0.0/users/dan": { Response: newTestResponse( http.StatusOK, `{ @@ -4159,7 +4159,7 @@ func TestResolve_FederatedActorWrongIDOldCache(t *testing.T) { assert.NoError(err) client.Data = map[string]testResponse{ - "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": testResponse{ + "https://0.0.0.0/.well-known/webfinger?resource=acct:dan@0.0.0.0": { Response: newTestResponse( http.StatusOK, `{ @@ -4182,7 +4182,7 @@ func TestResolve_FederatedActorWrongIDOldCache(t *testing.T) { }`, ), }, - "https://0.0.0.0/users/dan": testResponse{ + "https://0.0.0.0/users/dan": { Response: newTestResponse( http.StatusOK, `{ diff --git a/fed/verify.go b/fed/verify.go index cffe0fbb..7c9629f7 100644 --- a/fed/verify.go +++ b/fed/verify.go @@ -17,7 +17,6 @@ limitations under the License. package fed import ( - "context" "crypto/x509" "encoding/pem" "fmt" @@ -27,7 +26,7 @@ import ( "time" ) -func (l *Listener) verify(ctx context.Context, r *http.Request, body []byte, flags ap.ResolverFlag) (*ap.Actor, error) { +func (l *Listener) verify(r *http.Request, body []byte, flags ap.ResolverFlag) (*ap.Actor, error) { sig, err := httpsig.Extract(r, body, l.Domain, time.Now(), l.Config.MaxRequestAge) if err != nil { return nil, fmt.Errorf("failed to verify message: %w", err) diff --git a/front/cache.go b/front/cache.go index 8a3a38a3..294092fb 100644 --- a/front/cache.go +++ b/front/cache.go @@ -19,7 +19,6 @@ package front import ( "bytes" "context" - "github.com/dimkr/tootik/cfg" "github.com/dimkr/tootik/front/text" "slices" "sync" @@ -94,7 +93,7 @@ func callAndCache(r *Request, w text.Writer, args []string, f func(text.Writer, cache.Store(key, cacheEntry{buf.Bytes(), now}) } -func withCache(f func(text.Writer, *Request, ...string), d time.Duration, cache *sync.Map, cfg *cfg.Config) func(text.Writer, *Request, ...string) { +func withCache(f func(text.Writer, *Request, ...string), d time.Duration, cache *sync.Map) func(text.Writer, *Request, ...string) { return func(w text.Writer, r *Request, args ...string) { key := r.URL.String() now := time.Now() diff --git a/front/finger/finger.go b/front/finger/finger.go index 1dd36822..109f2782 100644 --- a/front/finger/finger.go +++ b/front/finger/finger.go @@ -42,7 +42,7 @@ type Listener struct { Addr string } -func (fl *Listener) handle(ctx context.Context, conn net.Conn, wg *sync.WaitGroup) { +func (fl *Listener) handle(ctx context.Context, conn net.Conn) { if err := conn.SetDeadline(time.Now().Add(fl.Config.GuppyRequestTimeout)); err != nil { slog.Warn("Failed to set deadline", "error", err) return @@ -222,7 +222,7 @@ func (fl *Listener) ListenAndServe(ctx context.Context) error { wg.Add(1) go func() { - fl.handle(requestCtx, conn, &wg) + fl.handle(requestCtx, conn) conn.Close() timer.Stop() cancelRequest() diff --git a/front/gemini/gemini.go b/front/gemini/gemini.go index f4e0fccf..b9272455 100644 --- a/front/gemini/gemini.go +++ b/front/gemini/gemini.go @@ -48,7 +48,7 @@ type Listener struct { KeyPath string } -func (gl *Listener) getUser(ctx context.Context, conn net.Conn, tlsConn *tls.Conn) (*ap.Actor, httpsig.Key, error) { +func (gl *Listener) getUser(ctx context.Context, tlsConn *tls.Conn) (*ap.Actor, httpsig.Key, error) { state := tlsConn.ConnectionState() if len(state.PeerCertificates) == 0 { @@ -136,7 +136,7 @@ func (gl *Listener) Handle(ctx context.Context, conn net.Conn) { w := gmi.Wrap(conn) defer w.Flush() - r.User, r.Key, err = gl.getUser(ctx, conn, tlsConn) + r.User, r.Key, err = gl.getUser(ctx, tlsConn) if err != nil && errors.Is(err, front.ErrNotRegistered) && r.URL.Path == "/users" { slog.Info("Redirecting new user") w.Redirect("/users/register") diff --git a/front/handler.go b/front/handler.go index db5b35e8..cf4b2f4b 100644 --- a/front/handler.go +++ b/front/handler.go @@ -40,7 +40,7 @@ type Handler struct { var ErrNotRegistered = errors.New("user is not registered") -func serveStaticFile(lines []string, w text.Writer, r *Request, args ...string) { +func serveStaticFile(lines []string, w text.Writer, _ *Request, _ ...string) { w.OK() for _, line := range lines { @@ -72,8 +72,8 @@ func NewHandler(domain string, closed bool, cfg *cfg.Config, resolver ap.Resolve h.handlers[regexp.MustCompile(`^/users/mentions$`)] = withUserMenu(h.mentions) - h.handlers[regexp.MustCompile(`^/local$`)] = withCache(withUserMenu(h.local), time.Minute*15, &cache, cfg) - h.handlers[regexp.MustCompile(`^/users/local$`)] = withCache(withUserMenu(h.local), time.Minute*15, &cache, cfg) + h.handlers[regexp.MustCompile(`^/local$`)] = withCache(withUserMenu(h.local), time.Minute*15, &cache) + h.handlers[regexp.MustCompile(`^/users/local$`)] = withCache(withUserMenu(h.local), time.Minute*15, &cache) h.handlers[regexp.MustCompile(`^/outbox/(\S+)$`)] = withUserMenu(h.userOutbox) h.handlers[regexp.MustCompile(`^/users/outbox/(\S+)$`)] = withUserMenu(h.userOutbox) @@ -124,11 +124,11 @@ func NewHandler(domain string, closed bool, cfg *cfg.Config, resolver ap.Resolve h.handlers[regexp.MustCompile(`^/communities$`)] = withUserMenu(h.communities) h.handlers[regexp.MustCompile(`^/users/communities$`)] = withUserMenu(h.communities) - h.handlers[regexp.MustCompile(`^/hashtag/([a-zA-Z0-9]+)$`)] = withCache(withUserMenu(h.hashtag), time.Minute*5, &cache, cfg) - h.handlers[regexp.MustCompile(`^/users/hashtag/([a-zA-Z0-9]+)$`)] = withCache(withUserMenu(h.hashtag), time.Minute*5, &cache, cfg) + h.handlers[regexp.MustCompile(`^/hashtag/([a-zA-Z0-9]+)$`)] = withCache(withUserMenu(h.hashtag), time.Minute*5, &cache) + h.handlers[regexp.MustCompile(`^/users/hashtag/([a-zA-Z0-9]+)$`)] = withCache(withUserMenu(h.hashtag), time.Minute*5, &cache) - h.handlers[regexp.MustCompile(`^/hashtags$`)] = withCache(withUserMenu(h.hashtags), time.Minute*30, &cache, cfg) - h.handlers[regexp.MustCompile(`^/users/hashtags$`)] = withCache(withUserMenu(h.hashtags), time.Minute*30, &cache, cfg) + h.handlers[regexp.MustCompile(`^/hashtags$`)] = withCache(withUserMenu(h.hashtags), time.Minute*30, &cache) + h.handlers[regexp.MustCompile(`^/users/hashtags$`)] = withCache(withUserMenu(h.hashtags), time.Minute*30, &cache) h.handlers[regexp.MustCompile(`^/search$`)] = withUserMenu(search) h.handlers[regexp.MustCompile(`^/users/search$`)] = withUserMenu(search) @@ -136,8 +136,8 @@ func NewHandler(domain string, closed bool, cfg *cfg.Config, resolver ap.Resolve h.handlers[regexp.MustCompile(`^/fts$`)] = withUserMenu(h.fts) h.handlers[regexp.MustCompile(`^/users/fts$`)] = withUserMenu(h.fts) - h.handlers[regexp.MustCompile(`^/status$`)] = withCache(withUserMenu(h.status), time.Minute*5, &cache, cfg) - h.handlers[regexp.MustCompile(`^/users/status$`)] = withCache(withUserMenu(h.status), time.Minute*5, &cache, cfg) + h.handlers[regexp.MustCompile(`^/status$`)] = withCache(withUserMenu(h.status), time.Minute*5, &cache) + h.handlers[regexp.MustCompile(`^/users/status$`)] = withCache(withUserMenu(h.status), time.Minute*5, &cache) h.handlers[regexp.MustCompile(`^/oops`)] = withUserMenu(oops) h.handlers[regexp.MustCompile(`^/users/oops`)] = withUserMenu(oops) diff --git a/front/user/create.go b/front/user/create.go index 76e0f08c..108efca3 100644 --- a/front/user/create.go +++ b/front/user/create.go @@ -31,7 +31,7 @@ import ( "time" ) -func gen(ctx context.Context) (*rsa.PrivateKey, []byte, []byte, error) { +func gen() (*rsa.PrivateKey, []byte, []byte, error) { priv, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { return nil, nil, nil, fmt.Errorf("failed to generate private key: %w", err) @@ -64,7 +64,7 @@ func gen(ctx context.Context) (*rsa.PrivateKey, []byte, []byte, error) { // Create creates a new user. func Create(ctx context.Context, domain string, db *sql.DB, name string, actorType ap.ActorType, certHash *string) (*ap.Actor, httpsig.Key, error) { - priv, privPem, pubPem, err := gen(ctx) + priv, privPem, pubPem, err := gen() if err != nil { return nil, httpsig.Key{}, fmt.Errorf("failed to generate key pair: %w", err) } @@ -79,7 +79,7 @@ func Create(ctx context.Context, domain string, db *sql.DB, name string, actorTy Type: actorType, PreferredUsername: name, Icon: []ap.Attachment{ - ap.Attachment{ + { Type: ap.Image, MediaType: icon.MediaType, URL: fmt.Sprintf("https://%s/icon/%s%s", domain, name, icon.FileNameExtension), diff --git a/icon/generate.go b/icon/generate.go index 0d436274..4f3d6e8c 100644 --- a/icon/generate.go +++ b/icon/generate.go @@ -31,11 +31,11 @@ func Generate(s string) ([]byte, error) { fg := color.RGBA{128 + (hash[0]^hash[29])%128, 128 + (hash[1]^hash[30])%128, 128 + (hash[2]^hash[31])%128, 255} alt := []color.RGBA{ - color.RGBA{fg.R, fg.B, fg.G, 255}, - color.RGBA{fg.G, fg.B, fg.R, 255}, - color.RGBA{fg.G, fg.R, fg.B, 255}, - color.RGBA{fg.B, fg.R, fg.G, 255}, - color.RGBA{fg.B, fg.G, fg.R, 255}, + {fg.R, fg.B, fg.G, 255}, + {fg.G, fg.B, fg.R, 255}, + {fg.G, fg.R, fg.B, 255}, + {fg.B, fg.R, fg.G, 255}, + {fg.B, fg.G, fg.R, 255}, }[hash[0]%5] bg := color.RGBA{255 - fg.R, 255 - fg.G, 255 - fg.B, 255} diff --git a/test/fts_test.go b/test/fts_test.go index 72092dda..21e2f5ee 100644 --- a/test/fts_test.go +++ b/test/fts_test.go @@ -195,7 +195,7 @@ func TestFTS_SearchByMentionUserName(t *testing.T) { Content: "Hello @abc", To: to, Tag: []ap.Tag{ - ap.Tag{ + { Type: ap.Mention, Name: "@abc@localhost.localdomain:8443", Href: server.Bob.ID, @@ -235,7 +235,7 @@ func TestFTS_SearchByMentionID(t *testing.T) { Content: "Hello @abc", To: to, Tag: []ap.Tag{ - ap.Tag{ + { Type: ap.Mention, Name: "@abc@localhost.localdomain:8443", Href: server.Bob.ID,