mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-05 01:52:46 +00:00
Linter fixes
This commit is contained in:
parent
b99ea8121c
commit
88dddd529f
|
@ -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")
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue