Debian Codegraph @

pkg/services/push/gotify/gotify.go

raw symbols SCIP
1 package gotifyscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src . fmt/"
5 "net/httpscip-go gomod github.com/golang/go/src . `net/http`/"
6 "net/urlscip-go gomod github.com/golang/go/src . `net/url`/"
7 "syncscip-go gomod github.com/golang/go/src . sync/"
8
9 "github.com/nicholas-fedor/shoutrrr/pkg/formatscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/"
10 "github.com/nicholas-fedor/shoutrrr/pkg/services/standardscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/standard`/"
11 "github.com/nicholas-fedor/shoutrrr/pkg/typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/"
12 "github.com/nicholas-fedor/shoutrrr/pkg/util/jsonclientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util/jsonclient`/"
13 )
14
15 // Service implements a Gotify notification service that handles sending push notifications
16 // to Gotify servers. It manages HTTP client configuration, TLS settings, authentication,
17 // and payload construction for reliable message delivery.
18 type Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service# struct {
19 standardscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/standard`/.Standardscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Standard. // Embeds the standard service functionality including logging
20
21 Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Config. *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config# // Holds the configuration settings for the Gotify service, including host, token, and other parameters
22 pkrscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#pkr. formatscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/.PropKeyResolverscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/PropKeyResolver# // Property key resolver used to update configuration from URL parameters dynamically
23 muscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#mu. syncscip-go gomod github.com/golang/go/src . sync/.Mutexscip-go gomod github.com/golang/go/src . sync/Mutex# // Protects HTTP client initialization for thread safety
24 httpClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#httpClient. typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.HTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/HTTPClient# // HTTP client instance configured with appropriate timeout and transport settings for API calls
25 clientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#client. jsonclientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util/jsonclient`/.Clientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util/jsonclient`/Client# // JSON client wrapper that handles JSON request/response marshaling and HTTP communication
26
27 // Interface dependencies (injected during initialization)
28 httpClientManagerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#httpClientManager. HTTPClientManagerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/HTTPClientManager#
29 urlBuilderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#urlBuilder. URLBuilderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/URLBuilder#
30 payloadBuilderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#payloadBuilder. PayloadBuilderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/PayloadBuilder#
31 validatorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#validator. Validatorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Validator#
32 senderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#sender. Senderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Sender#
33 }
34
35 // GetID returns the identifier for this service.
36 func (s *Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#) GetIDscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#GetID().() string {
37 return Schemescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Scheme.
38 }
39
40 // Initialize configures the service with a URL and logger.
41 // This method sets up the entire service infrastructure including configuration parsing,
42 // HTTP client creation with appropriate TLS settings, and logging capabilities.
43 // Parameters:
44 // - serviceURL: The URL containing Gotify server configuration (host, token, path, etc.)
45 // - logger: Logger instance for recording service operations and warnings
46 //
47 // Returns: error if configuration parsing or setup fails, nil on success.
48 func (s *Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#) Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Initialize().(serviceURL *urlscip-go gomod github.com/golang/go/src . `net/url`/.URLscip-go gomod github.com/golang/go/src . `net/url`/URL#, logger typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.StdLoggerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/StdLogger#) error {
49 // Set the logger for this service instance to enable logging throughout the service lifecycle
50 s.SetLoggerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/standard`/Logger#SetLogger().(logger)
51
52 // Initialize the configuration with default values
53 s.Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Config. = &Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#{
54 Titlescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#Title.: "Shoutrrr notification", // Default notification title used when none specified
55 }
56
57 // Create a property key resolver to handle dynamic configuration updates from parameters
58 s.pkrscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#pkr. = formatscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/.NewPropKeyResolverscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/NewPropKeyResolver().(s.Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Config.)
59
60 // Parse the configuration URL to extract host, token, path, and other settings
61 err := s.Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Config..SetURLscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#SetURL().(serviceURL)
62 if err != nil {
63 return fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("failed to set URL: %w", err)
64 }
65
66 // Inject default implementations for interfaces
67 s.httpClientManagerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#httpClientManager. = &DefaultHTTPClientManagerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/DefaultHTTPClientManager#{}
68 s.urlBuilderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#urlBuilder. = &DefaultURLBuilderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/DefaultURLBuilder#{}
69 s.payloadBuilderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#payloadBuilder. = &DefaultPayloadBuilderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/DefaultPayloadBuilder#{}
70 s.validatorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#validator. = &DefaultValidatorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/DefaultValidator#{}
71 s.senderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#sender. = &DefaultSenderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/DefaultSender#{}
72
73 // Initialize HTTP client and related components in a thread-safe manner
74 s.initClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#initClient().()
75
76 return nil // Return success
77 }
78
79 // Send delivers a notification message to Gotify.
80 // This is the main entry point for sending notifications. It handles message validation,
81 // parameter processing, configuration updates, URL construction, authentication setup,
82 // and HTTP request execution.
83 // Parameters:
84 // - message: The notification message content to send (cannot be empty)
85 // - params: Optional parameters that can override configuration settings or provide extras
86 //
87 // Returns: error if sending fails or validation fails, nil on successful delivery.
88 func (s *Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#) Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Send().(message string, params *typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.Paramsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Params#) error {
89 if err := s.validateInputsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#validateInputs().(message, params); err != nil {
90 return fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("input validation failed: %w", err)
91 }
92
93 s.initClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#initClient().()
94
95 config, extras, err := s.processConfigscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#processConfig().(params)
96 if err != nil {
97 return fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("failed to process config: %w", err)
98 }
99
100 postURL, request, headers, err := s.buildRequestscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#buildRequest().(message, &config, extras)
101 if err != nil {
102 return fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("failed to build request: %w", err)
103 }
104
105 return s.sendRequestscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#sendRequest().(postURL, request, headers)
106 }
107
108 // SetHTTPClient allows external injection of a custom HTTP client (for router propagation).
109 func (s *Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#) SetHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#SetHTTPClient().(client typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.HTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/HTTPClient#) {
110 s.muscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#mu..Lockscip-go gomod github.com/golang/go/src . sync/Mutex#Lock().()
111 defer s.muscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#mu..Unlockscip-go gomod github.com/golang/go/src . sync/Mutex#Unlock().()
112
113 if client == nil {
114 s.httpClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#httpClient. = nil
115 s.clientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#client. = nil
116
117 return
118 }
119
120 if c, ok := client.(*httpscip-go gomod github.com/golang/go/src . `net/http`/.Clientscip-go gomod github.com/golang/go/src . `net/http`/Client#); ok && c == nil {
121 s.httpClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#httpClient. = nil
122 s.clientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#client. = nil
123
124 return
125 }
126
127 s.httpClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#httpClient. = client
128 s.clientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#client. = jsonclientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util/jsonclient`/.NewWithHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/util/jsonclient`/NewWithHTTPClient().(client)
129 }
130
131 // buildRequest constructs the URL, payload, and headers for the HTTP request.
132 func (s *Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#) buildRequestscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#buildRequest().(
133 message string,
134 config *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#,
135 extras map[string]any,
136 ) (string, *MessageRequestscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/MessageRequest#, httpscip-go gomod github.com/golang/go/src . `net/http`/.Headerscip-go gomod github.com/golang/go/src . `net/http`/Header#, error) {
137 // Validate token format before constructing URL
138 if !s.validatorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#validator..ValidateTokenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Validator#ValidateToken.(config.Tokenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#Token.) {
139 return "", nil, nil, fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("%w: %q", ErrInvalidTokenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/ErrInvalidToken., config.Tokenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#Token.)
140 }
141
142 // Construct the complete API endpoint URL
143 postURL, err := s.urlBuilderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#urlBuilder..BuildURLscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/URLBuilder#BuildURL.(config)
144 if err != nil {
145 return "", nil, nil, fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("failed to build URL: %w", err)
146 }
147
148 // Prepare the JSON request payload
149 request := s.payloadBuilderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#payloadBuilder..PrepareRequestscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/PayloadBuilder#PrepareRequest.(message, config, extras, config.Datescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#Date.)
150
151 // Prepare headers for header-based authentication
152 var headers httpscip-go gomod github.com/golang/go/src . `net/http`/.Headerscip-go gomod github.com/golang/go/src . `net/http`/Header#
153 if config.UseHeaderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#UseHeader. {
154 headers = make(httpscip-go gomod github.com/golang/go/src . `net/http`/.Headerscip-go gomod github.com/golang/go/src . `net/http`/Header#)
155 headers.Setscip-go gomod github.com/golang/go/src . `net/http`/Header#Set().("X-Gotify-Key", config.Tokenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#Token.)
156 }
157
158 return postURL, request, headers, nil
159 }
160
161 // initClient initializes the HTTP client and related components.
162 // This method ensures that the transport, HTTP client, JSON client,
163 // and TLS warning logging are performed when needed, allowing re-initialization if the client becomes nil.
164 func (s *Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#) initClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#initClient().() {
165 initClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/initClient().(s, s.httpClientManagerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#httpClientManager.)
166 }
167
168 // processConfig handles configuration processing including parameter updates, validation, and extras parsing.
169 func (s *Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#) processConfigscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#processConfig().(params *typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.Paramsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Params#) (Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#, map[string]any, error) {
170 // Get reference to current configuration
171 config := *s.Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Config.
172
173 // Filter out 'extras' parameter as it's handled separately from other config updates
174 filteredParams := filterParamsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/filterParams().(params)
175
176 // Update configuration with filtered parameters (title, priority, etc.)
177 if err := s.pkrscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#pkr..UpdateConfigFromParamsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/PropKeyResolver#UpdateConfigFromParams().(&config, &filteredParams); err != nil {
178 return config, nil, fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("failed to update config from params: %w", err)
179 }
180
181 // Validate priority is within valid range (-2 to 10)
182 if err := s.validatorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#validator..ValidatePriorityscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Validator#ValidatePriority.(config.Priorityscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#Priority.); err != nil {
183 return config, nil, fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("priority validation failed: %w", err)
184 }
185
186 // Validate and convert date format
187 validatedDate, err := s.validatorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#validator..ValidateDatescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Validator#ValidateDate.(config.Datescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#Date.)
188 if err != nil {
189 s.Logfscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/standard`/Logger#Logf().("Invalid date format: %v", err)
190
191 config.Datescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#Date. = ""
192 } else {
193 config.Datescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#Date. = validatedDate
194 }
195
196 // Parse extras from parameters or fall back to config extras
197 extras, err := s.payloadBuilderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#payloadBuilder..ParseExtrasscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/PayloadBuilder#ParseExtras.(params, &config)
198 if err != nil {
199 s.Logfscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/standard`/Logger#Logf().("Failed to parse extras from params: %v", err)
200
201 extras = config.Extrasscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Config#Extras.
202 }
203
204 return config, extras, nil
205 }
206
207 // sendRequest handles the HTTP request.
208 // This function executes the actual HTTP POST request to the Gotify API endpoint,
209 // handling both successful responses and error conditions with appropriate error wrapping.
210 // Parameters:
211 // - postURL: The complete API endpoint URL to send the request to
212 // - request: The JSON payload to send in the request body
213 // - headers: Optional headers to set on the request
214 //
215 // Returns: error if the request fails or server returns an error, nil on success.
216 func (s *Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#) sendRequestscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#sendRequest().(
217 postURL string,
218 request *MessageRequestscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/MessageRequest#,
219 headers httpscip-go gomod github.com/golang/go/src . `net/http`/.Headerscip-go gomod github.com/golang/go/src . `net/http`/Header#,
220 ) error {
221 if err := s.senderscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#sender..SendRequestscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Sender#SendRequest.(
222 s.httpClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#httpClient.,
223 postURL,
224 request,
225 headers,
226 ); err != nil {
227 return fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("%s: %w", ErrSendFailedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/ErrSendFailed..Error(), err)
228 }
229
230 return nil
231 }
232
233 // validateInputs performs initial validation checks for the Send method.
234 func (s *Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#) validateInputsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#validateInputs().(message string, _ *typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.Paramsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Params#) error {
235 if err := s.validatorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#validator..ValidateMessagescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Validator#ValidateMessage.(message); err != nil {
236 return fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("message validation failed: %w", err)
237 }
238
239 if err := s.validatorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#validator..ValidateServiceInitializedscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Validator#ValidateServiceInitialized.(s.Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/Service#Config.); err != nil {
240 return fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("service initialization validation failed: %w", err)
241 }
242
243 return nil
244 }
245
246 // filterParams filters out 'extras' parameters from the given params.
247 func filterParamsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/gotify`/filterParams().(params *typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.Paramsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Params#) typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.Paramsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Params# {
248 if params == nil {
249 return typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.Paramsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Params#{}
250 }
251
252 filtered := make(typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.Paramsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/Params#)
253
254 for k, v := range *params {
255 if k != "extras" {
256 filtered[k] = v
257 }
258 }
259
260 return filtered
261 }