Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# This file is licensed under the terms of the MIT license https://opensource.org/license/mit
# Copyright (c) 2021-2025 Marat Reymers
# Copyright (c) 2021-2025 Marat Reimers

## Golden config for golangci-lint v2.5.0
## Golden config for golangci-lint v2.9.0
#
# This is the best config for golangci-lint based on my experience and opinion.
# It is very strict, but not extremely strict.
# Feel free to adapt it to suit your needs.
# If this config helps you, please consider keeping a link to this file (see the next comment).
# If this config helps you, please consider keeping a link to this repo (see the next comment).

# Based on https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322
# Based on https://github.com/maratori/golangci-lint-config

version: "2"

Expand Down Expand Up @@ -82,6 +82,7 @@ linters:
- makezero # finds slice declarations with non-zero initial length
- mirror # reports wrong mirror patterns of bytes/strings usage
- mnd # detects magic numbers
- modernize # suggests simplifications to Go code, using modern language and library features
- musttag # enforces field tags in (un)marshaled structs
- nakedret # finds naked returns in functions greater than a specified function length
- nestif # reports deeply nested if statements
Expand Down Expand Up @@ -252,17 +253,19 @@ linters:
- ^os/exec.Cmd$
- ^reflect.StructField$
# public libs
- "^github.com/gofiber/.+Config$"
- "^gopkg.in/telebot.v4.LongPoller$"
- "^gopkg.in/telebot.v4.ReplyMarkup$"
- "^gopkg.in/telebot.v4.Settings$"
- ^firebase.google.com/go/v4/messaging.AndroidConfig$
- ^firebase.google.com/go/v4/messaging.Message$
- ^github.com/aws/aws-sdk-go-v2/service/s3.+Input$
- ^github.com/aws/aws-sdk-go-v2/service/s3/types.ObjectIdentifier$
- ^github.com/go-telegram-bot-api/telegram-bot-api/.+Config$
- ^github.com/go-telegram/bot.+Params$
- ^github.com/go-telegram/bot/models.+$
- ^github.com/gofiber/.+Config$
- ^github.com/golang-jwt/jwt/v5.+Claims$
- ^github.com/mitchellh/mapstructure.DecoderConfig$
- ^github.com/mymmrac/telego.+Parameters$
- ^github.com/prometheus/client_golang/.+Opts$
- ^github.com/revrost/go-openrouter.+$
- ^github.com/secsy/goftp.Config$
- ^github.com/Shopify/sarama.Config$
- ^github.com/Shopify/sarama.ProducerMessage$
Expand All @@ -271,11 +274,15 @@ linters:
- ^github.com/stretchr/testify/mock.Mock$
- ^github.com/testcontainers/testcontainers-go.+Request$
- ^github.com/testcontainers/testcontainers-go.FromDockerfile$
- ^github.com/ThreeDotsLabs/watermill.+(Config|Schema|Adapter)$
- ^github.com/urfave/cli.v3.ArgumentBase$
- ^github.com/urfave/cli.v3.Command$
- ^github.com/urfave/cli.v3.FlagBase$
- ^golang.org/x/tools/go/analysis.Analyzer$
- ^google.golang.org/protobuf/.+Options$
- ^gopkg.in/telebot.v4.LongPoller$
- ^gopkg.in/telebot.v4.ReplyMarkup$
- ^gopkg.in/telebot.v4.Settings$
- ^gopkg.in/yaml.v3.Node$
- ^gorm.io/gorm/clause.+$
# Allows empty structures in return statements.
Expand Down Expand Up @@ -328,6 +335,16 @@ linters:
# Assert no unused link in godocs.
# https://github.com/godoc-lint/godoc-lint?tab=readme-ov-file#no-unused-link
- no-unused-link
# Require proper doc links to standard library declarations where applicable.
# https://github.com/godoc-lint/godoc-lint?tab=readme-ov-file#require-stdlib-doclink
- require-stdlib-doclink

gosec:
# To specify a set of rules to explicitly exclude.
# Available rules: https://github.com/securego/gosec#available-rules
excludes:
- G117 # Potential exposure of secrets via JSON marshaling
- G704 # SSRF via taint analysis

govet:
# Enable all analyzers.
Expand Down
2 changes: 1 addition & 1 deletion smsgateway/domain_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type DataMessage struct {
// Data is the base64-encoded payload.
Data string `json:"data" validate:"required,base64,min=4,max=65535" example:"SGVsbG8gV29ybGQh" format:"byte"`
// Port is the destination port.
Port uint16 `json:"port" validate:"required,min=1,max=65535" example:"53739"`
Port uint16 `json:"port" validate:"required,min=1,max=65535" example:"53739"`
}

// Message represents an SMS message.
Expand Down
15 changes: 15 additions & 0 deletions smsgateway/domain_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ type DeviceSettings struct {

// Webhooks contains settings related to webhook functionality.
Webhooks *SettingsWebhooks `json:"webhooks,omitempty"`

// Gateway contains settings related to the gateway.
Gateway *SettingsGateway `json:"gateway,omitempty"`
}

func (s DeviceSettings) Validate() error {
Expand Down Expand Up @@ -134,3 +137,15 @@ type SettingsWebhooks struct {
// SigningKey is the secret key used for signing webhook payloads. Must not be used with Cloud Server.
SigningKey *string `json:"signing_key,omitempty" validate:"omitempty,isdefault"`
}

// SettingsGateway contains settings related to the gateway.
type SettingsGateway struct {
// CloudURL is the URL of the cloud server. Must not be used with Cloud Server.
CloudURL *string `json:"cloud_url,omitempty" validate:"omitempty,isdefault,url"`

// PrivateToken is the auth token for the private server. Must not be used with Cloud Server.
PrivateToken *string `json:"private_token,omitempty" validate:"omitempty,isdefault"`

// NotificationChannel is the way device receives notifications.
NotificationChannel *string `json:"notification_channel,omitempty" validate:"omitempty,oneof=AUTO SSE_ONLY"`
}
4 changes: 2 additions & 2 deletions smsgateway/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type MessagesExportRequest struct {
// DeviceID is the ID of the device to export messages for.
DeviceID string `json:"deviceId" example:"PyDmBQZZXYmyxMwED8Fzy" validate:"required,max=21"`
// Since is the start of the time range to export.
Since time.Time `json:"since" example:"2024-01-01T00:00:00Z" validate:"required,ltefield=Until"`
Since time.Time `json:"since" example:"2024-01-01T00:00:00Z" validate:"required,ltefield=Until"`
// Until is the end of the time range to export.
Until time.Time `json:"until" example:"2024-01-01T23:59:59Z" validate:"required,gtefield=Since"`
Until time.Time `json:"until" example:"2024-01-01T23:59:59Z" validate:"required,gtefield=Since"`
}
2 changes: 1 addition & 1 deletion smsgateway/requests_3rdparty.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (o *SendOptions) Apply(options ...SendOption) *SendOptions {
return o
}

// ToURLValues returns the SendOptions as a URL query string in the form of url.Values.
// ToURLValues returns the SendOptions as a URL query string in the form of [url.Values].
// It includes only the options that have been set.
func (o *SendOptions) ToURLValues() url.Values {
values := url.Values{}
Expand Down
6 changes: 3 additions & 3 deletions smsgateway/requests_mobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type MobileRegisterRequest struct {
Name *string `json:"name,omitempty" validate:"omitempty,max=128" example:"Android Phone"`
// FCM token of the device (optional)
// +optional
PushToken *string `json:"pushToken" validate:"omitempty,max=256" example:"gHz-T6NezDlOfllr7F-Be"`
PushToken *string `json:"pushToken" validate:"omitempty,max=256" example:"gHz-T6NezDlOfllr7F-Be"`
}

// MobileUpdateRequest represents a request to update a mobile device.
Expand All @@ -39,9 +39,9 @@ type MobileChangePasswordRequest struct {
// MobilePatchMessageItem represents a single message patch request.
type MobilePatchMessageItem struct {
// Message ID
ID string `json:"id" validate:"required,max=36" example:"PyDmBQZZXYmyxMwED8Fzy"`
ID string `json:"id" validate:"required,max=36" example:"PyDmBQZZXYmyxMwED8Fzy"`
// State
State ProcessingState `json:"state" validate:"required" example:"Pending"`
State ProcessingState `json:"state" validate:"required" example:"Pending"`
// Recipients states
Recipients []RecipientState `json:"recipients" validate:"required,min=1,dive"`
// History of states
Expand Down