mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-01-26 16:08:08 +00:00
Linter fixes
This commit is contained in:
parent
b99ea8121c
commit
88dddd529f
4 changed files with 28 additions and 8 deletions
|
@ -224,18 +224,18 @@ func validateNormalizeCreate(request *apimodel.WebPushSubscriptionCreateRequest)
|
||||||
if request.Subscription.Endpoint == "" {
|
if request.Subscription.Endpoint == "" {
|
||||||
return errors.New("endpoint is required")
|
return errors.New("endpoint is required")
|
||||||
}
|
}
|
||||||
endpointUrl, err := url.Parse(request.Subscription.Endpoint)
|
endpointURL, err := url.Parse(request.Subscription.Endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("endpoint must be a valid URL")
|
return errors.New("endpoint must be a valid URL")
|
||||||
}
|
}
|
||||||
// TODO: (Vyr) remove http option after testing
|
// 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")
|
return errors.New("endpoint must be an https:// URL")
|
||||||
}
|
}
|
||||||
if endpointUrl.Host == "" {
|
if endpointURL.Host == "" {
|
||||||
return errors.New("endpoint URL must have a 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")
|
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
|
package bundb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -153,6 +170,9 @@ func (w *webPushDB) GetWebPushSubscriptionsByAccountID(ctx context.Context, acco
|
||||||
}
|
}
|
||||||
return subscriptionIDs, nil
|
return subscriptionIDs, nil
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if len(subscriptionIDs) == 0 {
|
if len(subscriptionIDs) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,12 +238,12 @@ func (r *realSender) sendToSubscription(
|
||||||
return nil
|
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.
|
// so that webpush-go can use our IP filters, bad hosts list, and retries.
|
||||||
type gtsHttpClientRoundTripper struct {
|
type gtsHTTPClientRoundTripper struct {
|
||||||
httpClient *httpclient.Client
|
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)
|
return r.httpClient.Do(request)
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ type Sender interface {
|
||||||
func NewSender(httpClient *httpclient.Client, state *state.State) Sender {
|
func NewSender(httpClient *httpclient.Client, state *state.State) Sender {
|
||||||
return NewRealSender(
|
return NewRealSender(
|
||||||
&http.Client{
|
&http.Client{
|
||||||
Transport: >sHttpClientRoundTripper{
|
Transport: >sHTTPClientRoundTripper{
|
||||||
httpClient: httpClient,
|
httpClient: httpClient,
|
||||||
},
|
},
|
||||||
// Other fields are already set on the http.Client inside the httpclient.Client.
|
// Other fields are already set on the http.Client inside the httpclient.Client.
|
||||||
|
|
Loading…
Reference in a new issue