From 2cb7a8bf2ace93ff8e648d45d21e658769c2968b Mon Sep 17 00:00:00 2001 From: Vyr Cossont Date: Sat, 30 Nov 2024 20:18:56 -0800 Subject: [PATCH] Linter fixes --- .../api/client/push/pushsubscriptionpost.go | 8 ++++---- internal/db/bundb/webpush.go | 20 +++++++++++++++++++ internal/webpush/realsender.go | 6 +++--- internal/webpush/sender.go | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/internal/api/client/push/pushsubscriptionpost.go b/internal/api/client/push/pushsubscriptionpost.go index dd565230c..78b61ca15 100644 --- a/internal/api/client/push/pushsubscriptionpost.go +++ b/internal/api/client/push/pushsubscriptionpost.go @@ -224,18 +224,18 @@ func validateNormalizeCreate(request *apimodel.WebPushSubscriptionCreateRequest) if request.Subscription.Endpoint == "" { return errors.New("endpoint is required") } - endpointUrl, err := url.Parse(request.Subscription.Endpoint) + endpointURL, err := url.Parse(request.Subscription.Endpoint) if err != nil { return errors.New("endpoint must be a valid URL") } // TODO: (Vyr) remove http option after testing - if endpointUrl.Scheme != "https" && endpointUrl.Scheme != "http" { + if endpointURL.Scheme != "https" && endpointURL.Scheme != "http" { return errors.New("endpoint must be an https:// URL") } - if endpointUrl.Host == "" { + if endpointURL.Host == "" { return errors.New("endpoint URL must have a host") } - if endpointUrl.Fragment != "" { + if endpointURL.Fragment != "" { return errors.New("endpoint URL must not have a fragment") } diff --git a/internal/db/bundb/webpush.go b/internal/db/bundb/webpush.go index 3f215c9c4..d259466d8 100644 --- a/internal/db/bundb/webpush.go +++ b/internal/db/bundb/webpush.go @@ -1,3 +1,20 @@ +// GoToSocial +// Copyright (C) GoToSocial Authors admin@gotosocial.org +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + package bundb import ( @@ -153,6 +170,9 @@ func (w *webPushDB) GetWebPushSubscriptionsByAccountID(ctx context.Context, acco } return subscriptionIDs, nil }) + if err != nil { + return nil, err + } if len(subscriptionIDs) == 0 { return nil, nil } diff --git a/internal/webpush/realsender.go b/internal/webpush/realsender.go index 76661068f..9d290ab01 100644 --- a/internal/webpush/realsender.go +++ b/internal/webpush/realsender.go @@ -238,12 +238,12 @@ func (r *realSender) sendToSubscription( return nil } -// gtsHttpClientRoundTripper helps wrap a GtS HTTP client back into a regular HTTP client, +// gtsHTTPClientRoundTripper helps wrap a GtS HTTP client back into a regular HTTP client, // so that webpush-go can use our IP filters, bad hosts list, and retries. -type gtsHttpClientRoundTripper struct { +type gtsHTTPClientRoundTripper struct { httpClient *httpclient.Client } -func (r *gtsHttpClientRoundTripper) RoundTrip(request *http.Request) (*http.Response, error) { +func (r *gtsHTTPClientRoundTripper) RoundTrip(request *http.Request) (*http.Response, error) { return r.httpClient.Do(request) } diff --git a/internal/webpush/sender.go b/internal/webpush/sender.go index 0de9843e4..de0f4b04c 100644 --- a/internal/webpush/sender.go +++ b/internal/webpush/sender.go @@ -42,7 +42,7 @@ type Sender interface { func NewSender(httpClient *httpclient.Client, state *state.State) Sender { return NewRealSender( &http.Client{ - Transport: >sHttpClientRoundTripper{ + Transport: >sHTTPClientRoundTripper{ httpClient: httpClient, }, // Other fields are already set on the http.Client inside the httpclient.Client.