| 1 | package signalscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src . fmt/" |
| 5 | "netscip-go gomod github.com/golang/go/src . net/" |
| 6 | "net/urlscip-go gomod github.com/golang/go/src . `net/url`/" |
| 7 | "regexpscip-go gomod github.com/golang/go/src . regexp/" |
| 8 | "strconvscip-go gomod github.com/golang/go/src . strconv/" |
| 9 | "stringsscip-go gomod github.com/golang/go/src . strings/" |
| 10 | |
| 11 | "github.com/nicholas-fedor/shoutrrr/pkg/formatscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/" |
| 12 | "github.com/nicholas-fedor/shoutrrr/pkg/services/standardscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/standard`/" |
| 13 | "github.com/nicholas-fedor/shoutrrr/pkg/typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/" |
| 14 | ) |
| 15 | |
| 16 | // Config holds settings for the Signal notification service. |
| 17 | type Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config# struct { |
| 18 | standardscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/standard`/.EnumlessConfigscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#EnumlessConfig. |
| 19 | |
| 20 | Hostscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Host. string `default:"localhost" desc:"Signal REST API server hostname or IP" key:"host"` |
| 21 | Portscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Port. int `default:"8080" desc:"Signal REST API server port" key:"port"` |
| 22 | Userscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#User. string ` desc:"Username for HTTP Basic Auth" key:"user"` |
| 23 | Passwordscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Password. string ` desc:"Password for HTTP Basic Auth" key:"password" sensitive:"true"` |
| 24 | Tokenscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Token. string ` desc:"API token for Bearer authentication" key:"token,apikey"` |
| 25 | Sourcescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Source. string ` desc:"Source phone number (with country code)" key:"source"` |
| 26 | Recipientsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Recipients. []string ` desc:"Recipient phone numbers or group IDs" key:"recipients,to"` |
| 27 | DisableTLSscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#DisableTLS. bool `default:"No" desc:"Disable TLS for Signal REST API connection" key:"disabletls"` |
| 28 | } |
| 29 | |
| 30 | // Scheme identifies this service in configuration URLs. |
| 31 | const ( |
| 32 | Schemescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Scheme. = "signal" |
| 33 | // minPathParts is the minimum number of path parts required (source + at least one recipient). |
| 34 | minPathPartsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/minPathParts. = 2 |
| 35 | ) |
| 36 | |
| 37 | // phoneRegex validates phone number format (with or without + prefix). |
| 38 | var phoneRegexscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/phoneRegex. = regexpscip-go gomod github.com/golang/go/src . regexp/.MustCompilescip-go gomod github.com/golang/go/src . regexp/MustCompile().(`^\+?[0-9\s)(+-]+$`) |
| 39 | |
| 40 | // groupRegex validates group ID format. |
| 41 | var groupRegexscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/groupRegex. = regexpscip-go gomod github.com/golang/go/src . regexp/.MustCompilescip-go gomod github.com/golang/go/src . regexp/MustCompile().(`^group\.[a-zA-Z0-9_+/=-]+$`) |
| 42 | |
| 43 | // GetURL generates a URL from the current configuration values. |
| 44 | // |
| 45 | // Returns: |
| 46 | // - *url.URL: the generated URL representing the configuration. |
| 47 | func (c *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#) GetURLscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#GetURL().() *urlscip-go gomod github.com/golang/go/src . `net/url`/.URLscip-go gomod github.com/golang/go/src . `net/url`/URL# { |
| 48 | resolver := 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().(c) |
| 49 | |
| 50 | return c.getURLscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#getURL().(&resolver) |
| 51 | } |
| 52 | |
| 53 | // SetURL updates the configuration from a URL representation. |
| 54 | // |
| 55 | // Parameters: |
| 56 | // - serviceURL: the URL to parse configuration from |
| 57 | // |
| 58 | // Returns: |
| 59 | // - error: if parsing fails, nil otherwise |
| 60 | func (c *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#) SetURLscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#SetURL().(serviceURL *urlscip-go gomod github.com/golang/go/src . `net/url`/.URLscip-go gomod github.com/golang/go/src . `net/url`/URL#) error { |
| 61 | resolver := 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().(c) |
| 62 | |
| 63 | return c.setURLscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#setURL().(&resolver, serviceURL) |
| 64 | } |
| 65 | |
| 66 | // getURL constructs a URL from the Config's fields using the provided resolver. |
| 67 | // |
| 68 | // Parameters: |
| 69 | // - resolver: the configuration query resolver for property resolution |
| 70 | // |
| 71 | // Returns: |
| 72 | // - *url.URL: the constructed URL |
| 73 | func (c *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#) getURLscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#getURL().(resolver typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.ConfigQueryResolverscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/ConfigQueryResolver#) *urlscip-go gomod github.com/golang/go/src . `net/url`/.URLscip-go gomod github.com/golang/go/src . `net/url`/URL# { |
| 74 | recipients := stringsscip-go gomod github.com/golang/go/src . strings/.Joinscip-go gomod github.com/golang/go/src . strings/Join().(c.Recipientsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Recipients., "/") |
| 75 | |
| 76 | result := &urlscip-go gomod github.com/golang/go/src . `net/url`/.URLscip-go gomod github.com/golang/go/src . `net/url`/URL#{ |
| 77 | Schemescip-go gomod github.com/golang/go/src . `net/url`/URL#Scheme.: Schemescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Scheme., |
| 78 | Hostscip-go gomod github.com/golang/go/src . `net/url`/URL#Host.: fmtscip-go gomod github.com/golang/go/src . fmt/.Sprintfscip-go gomod github.com/golang/go/src . fmt/Sprintf().("%s:%d", c.Hostscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Host., c.Portscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Port.), |
| 79 | Pathscip-go gomod github.com/golang/go/src . `net/url`/URL#Path.: fmtscip-go gomod github.com/golang/go/src . fmt/.Sprintfscip-go gomod github.com/golang/go/src . fmt/Sprintf().("/%s/%s", c.Sourcescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Source., recipients), |
| 80 | RawQueryscip-go gomod github.com/golang/go/src . `net/url`/URL#RawQuery.: formatscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/.BuildQueryscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/format`/BuildQuery().(resolver), |
| 81 | } |
| 82 | |
| 83 | // Add user:password if authentication is configured |
| 84 | if c.Userscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#User. != "" { |
| 85 | if c.Passwordscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Password. != "" { |
| 86 | result.Userscip-go gomod github.com/golang/go/src . `net/url`/URL#User. = urlscip-go gomod github.com/golang/go/src . `net/url`/.UserPasswordscip-go gomod github.com/golang/go/src . `net/url`/UserPassword().(c.Userscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#User., c.Passwordscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Password.) |
| 87 | } else { |
| 88 | result.Userscip-go gomod github.com/golang/go/src . `net/url`/URL#User. = urlscip-go gomod github.com/golang/go/src . `net/url`/.Userscip-go gomod github.com/golang/go/src . `net/url`/User().(c.Userscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#User.) |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return result |
| 93 | } |
| 94 | |
| 95 | // parseAuth extracts user and password from the URL. |
| 96 | // |
| 97 | // Parameters: |
| 98 | // - serviceURL: the URL to extract authentication from |
| 99 | // |
| 100 | // Returns: |
| 101 | // - error: if extraction fails, nil otherwise |
| 102 | func (c *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#) parseAuthscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#parseAuth().(serviceURL *urlscip-go gomod github.com/golang/go/src . `net/url`/.URLscip-go gomod github.com/golang/go/src . `net/url`/URL#) error { |
| 103 | if serviceURL.Userscip-go gomod github.com/golang/go/src . `net/url`/URL#User. != nil { |
| 104 | c.Userscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#User. = serviceURL.Userscip-go gomod github.com/golang/go/src . `net/url`/URL#User..Usernamescip-go gomod github.com/golang/go/src . `net/url`/Userinfo#Username().() |
| 105 | if password, ok := serviceURL.Userscip-go gomod github.com/golang/go/src . `net/url`/URL#User..Passwordscip-go gomod github.com/golang/go/src . `net/url`/Userinfo#Password().(); ok { |
| 106 | c.Passwordscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Password. = password |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | return nil |
| 111 | } |
| 112 | |
| 113 | // parseHostPort extracts host and port from the URL. |
| 114 | // |
| 115 | // Parameters: |
| 116 | // - serviceURL: the URL to extract host and port from |
| 117 | // |
| 118 | // Returns: |
| 119 | // - error: if parsing fails, nil otherwise |
| 120 | func (c *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#) parseHostPortscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#parseHostPort().(serviceURL *urlscip-go gomod github.com/golang/go/src . `net/url`/.URLscip-go gomod github.com/golang/go/src . `net/url`/URL#) error { |
| 121 | host, portStr, err := netscip-go gomod github.com/golang/go/src . net/.SplitHostPortscip-go gomod github.com/golang/go/src . net/SplitHostPort().(serviceURL.Hostscip-go gomod github.com/golang/go/src . `net/url`/URL#Host.) |
| 122 | if err != nil { |
| 123 | // If no port specified, use default |
| 124 | host = serviceURL.Hostscip-go gomod github.com/golang/go/src . `net/url`/URL#Host. |
| 125 | portStr = "8080" |
| 126 | } |
| 127 | |
| 128 | c.Hostscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Host. = host |
| 129 | |
| 130 | if portStr != "" { |
| 131 | if port, err := strconvscip-go gomod github.com/golang/go/src . strconv/.Atoiscip-go gomod github.com/golang/go/src . strconv/Atoi().(portStr); err == nil { |
| 132 | c.Portscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Port. = port |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | return nil |
| 137 | } |
| 138 | |
| 139 | // parsePath extracts source phone number and recipients from the URL path. |
| 140 | // |
| 141 | // Parameters: |
| 142 | // - serviceURL: the URL to extract path from |
| 143 | // |
| 144 | // Returns: |
| 145 | // - error: if parsing fails, nil otherwise |
| 146 | func (c *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#) parsePathscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#parsePath().(serviceURL *urlscip-go gomod github.com/golang/go/src . `net/url`/.URLscip-go gomod github.com/golang/go/src . `net/url`/URL#) error { |
| 147 | pathParts := stringsscip-go gomod github.com/golang/go/src . strings/.Splitscip-go gomod github.com/golang/go/src . strings/Split().(stringsscip-go gomod github.com/golang/go/src . strings/.Trimscip-go gomod github.com/golang/go/src . strings/Trim().(serviceURL.Pathscip-go gomod github.com/golang/go/src . `net/url`/URL#Path., "/"), "/") |
| 148 | if len(pathParts) < minPathPartsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/minPathParts. { |
| 149 | return ErrNoRecipientsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/ErrNoRecipients. |
| 150 | } |
| 151 | |
| 152 | // First part is source phone number |
| 153 | source := pathParts[0] |
| 154 | if !isValidPhoneNumberscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/isValidPhoneNumber().(source) { |
| 155 | return fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("%w: %s", ErrInvalidPhoneNumberscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/ErrInvalidPhoneNumber., source) |
| 156 | } |
| 157 | |
| 158 | c.Sourcescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Source. = source |
| 159 | |
| 160 | // Parse recipients from remaining path parts |
| 161 | recipients, err := parseRecipientsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/parseRecipients().(pathParts[1:]) |
| 162 | if err != nil { |
| 163 | return err |
| 164 | } |
| 165 | |
| 166 | c.Recipientsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Recipients. = recipients |
| 167 | |
| 168 | return nil |
| 169 | } |
| 170 | |
| 171 | // parseRecipients parses recipient phone numbers and group IDs from URL path segments. |
| 172 | // It handles group IDs that may contain "/" characters by accumulating consecutive segments. |
| 173 | // |
| 174 | // Parameters: |
| 175 | // - pathParts: the URL path segments to parse |
| 176 | // |
| 177 | // Returns: |
| 178 | // - []string: the parsed recipients |
| 179 | // - error: if parsing fails, nil otherwise |
| 180 | func parseRecipientsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/parseRecipients().(pathParts []string) ([]string, error) { |
| 181 | if len(pathParts) == 0 { |
| 182 | return nil, ErrNoRecipientsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/ErrNoRecipients. |
| 183 | } |
| 184 | |
| 185 | var ( |
| 186 | recipients []string |
| 187 | currentGroupID stringsscip-go gomod github.com/golang/go/src . strings/.Builderscip-go gomod github.com/golang/go/src . strings/Builder# |
| 188 | ) |
| 189 | |
| 190 | inGroupID := false |
| 191 | |
| 192 | for _, part := range pathParts { |
| 193 | switch { |
| 194 | case stringsscip-go gomod github.com/golang/go/src . strings/.HasPrefixscip-go gomod github.com/golang/go/src . strings/HasPrefix().(part, "group."): |
| 195 | // Finalize any previous group ID |
| 196 | if inGroupID { |
| 197 | recipients = append(recipients, currentGroupID.Stringscip-go gomod github.com/golang/go/src . strings/Builder#String().()) |
| 198 | } |
| 199 | // Start new group ID |
| 200 | currentGroupID.Resetscip-go gomod github.com/golang/go/src . strings/Builder#Reset().() |
| 201 | currentGroupID.WriteStringscip-go gomod github.com/golang/go/src . strings/Builder#WriteString().(part) |
| 202 | |
| 203 | inGroupID = true |
| 204 | |
| 205 | case inGroupID && !stringsscip-go gomod github.com/golang/go/src . strings/.HasPrefixscip-go gomod github.com/golang/go/src . strings/HasPrefix().(part, "+"): |
| 206 | // Continue building group ID (not a phone number) |
| 207 | currentGroupID.WriteStringscip-go gomod github.com/golang/go/src . strings/Builder#WriteString().("/") |
| 208 | currentGroupID.WriteStringscip-go gomod github.com/golang/go/src . strings/Builder#WriteString().(part) |
| 209 | |
| 210 | default: |
| 211 | // Finalize any group ID in progress |
| 212 | if inGroupID { |
| 213 | recipients = append(recipients, currentGroupID.Stringscip-go gomod github.com/golang/go/src . strings/Builder#String().()) |
| 214 | inGroupID = false |
| 215 | } |
| 216 | // Add phone number or other recipient |
| 217 | recipients = append(recipients, part) |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | // Finalize any remaining group ID |
| 222 | if inGroupID { |
| 223 | recipients = append(recipients, currentGroupID.Stringscip-go gomod github.com/golang/go/src . strings/Builder#String().()) |
| 224 | } |
| 225 | |
| 226 | // Validate all recipients |
| 227 | for _, recipient := range recipients { |
| 228 | if !isValidPhoneNumberscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/isValidPhoneNumber().(recipient) && !isValidGroupIDscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/isValidGroupID().(recipient) { |
| 229 | return nil, fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("%w: %s", ErrInvalidRecipientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/ErrInvalidRecipient., recipient) |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | return recipients, nil |
| 234 | } |
| 235 | |
| 236 | // parseQuery processes query parameters using the resolver. |
| 237 | // |
| 238 | // Parameters: |
| 239 | // - resolver: the configuration query resolver |
| 240 | // - serviceURL: the URL containing query parameters |
| 241 | // |
| 242 | // Returns: |
| 243 | // - error: if parsing fails, nil otherwise |
| 244 | func (c *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#) parseQueryscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#parseQuery().(resolver typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.ConfigQueryResolverscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/ConfigQueryResolver#, serviceURL *urlscip-go gomod github.com/golang/go/src . `net/url`/.URLscip-go gomod github.com/golang/go/src . `net/url`/URL#) error { |
| 245 | for key, vals := range serviceURL.Queryscip-go gomod github.com/golang/go/src . `net/url`/URL#Query().() { |
| 246 | if err := resolver.Setscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/ConfigQueryResolver#Set.(key, vals[0]); err != nil { |
| 247 | return fmtscip-go gomod github.com/golang/go/src . fmt/.Errorfscip-go gomod github.com/golang/go/src . fmt/Errorf().("setting config property %q from URL query: %w", key, err) |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | return nil |
| 252 | } |
| 253 | |
| 254 | // setURL updates the Config from a URL using the provided resolver. |
| 255 | // |
| 256 | // Parameters: |
| 257 | // - resolver: the configuration query resolver |
| 258 | // - serviceURL: the URL to parse |
| 259 | // |
| 260 | // Returns: |
| 261 | // - error: if parsing fails, nil otherwise |
| 262 | func (c *Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#) setURLscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#setURL().(resolver typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.ConfigQueryResolverscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/ConfigQueryResolver#, serviceURL *urlscip-go gomod github.com/golang/go/src . `net/url`/.URLscip-go gomod github.com/golang/go/src . `net/url`/URL#) error { |
| 263 | // Handle dummy URL used for documentation generation |
| 264 | if serviceURL.Stringscip-go gomod github.com/golang/go/src . `net/url`/URL#String().() == "signal://[email protected]" { |
| 265 | c.Hostscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Host. = "localhost" |
| 266 | c.Portscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Port. = 8080 |
| 267 | c.Sourcescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Source. = "+1234567890" |
| 268 | c.Recipientsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#Recipients. = []string{"+0987654321"} |
| 269 | c.DisableTLSscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#DisableTLS. = false |
| 270 | |
| 271 | return nil |
| 272 | } |
| 273 | |
| 274 | if err := c.parseAuthscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#parseAuth().(serviceURL); err != nil { |
| 275 | return err |
| 276 | } |
| 277 | |
| 278 | if err := c.parseHostPortscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#parseHostPort().(serviceURL); err != nil { |
| 279 | return err |
| 280 | } |
| 281 | |
| 282 | if err := c.parsePathscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#parsePath().(serviceURL); err != nil { |
| 283 | return err |
| 284 | } |
| 285 | |
| 286 | if err := c.parseQueryscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/Config#parseQuery().(resolver, serviceURL); err != nil { |
| 287 | return err |
| 288 | } |
| 289 | |
| 290 | return nil |
| 291 | } |
| 292 | |
| 293 | // isValidPhoneNumber checks if the string is a valid phone number. |
| 294 | // |
| 295 | // Parameters: |
| 296 | // - phone: the phone number string to validate |
| 297 | // |
| 298 | // Returns: |
| 299 | // - bool: true if valid, false otherwise |
| 300 | func isValidPhoneNumberscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/isValidPhoneNumber().(phone string) bool { |
| 301 | return phoneRegexscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/phoneRegex..MatchStringscip-go gomod github.com/golang/go/src . regexp/Regexp#MatchString().(phone) |
| 302 | } |
| 303 | |
| 304 | // isValidGroupID checks if the string is a valid group ID. |
| 305 | // |
| 306 | // Parameters: |
| 307 | // - groupID: the group ID string to validate |
| 308 | // |
| 309 | // Returns: |
| 310 | // - bool: true if valid, false otherwise |
| 311 | func isValidGroupIDscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/isValidGroupID().(groupID string) bool { |
| 312 | return groupRegexscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/signal`/groupRegex..MatchStringscip-go gomod github.com/golang/go/src . regexp/Regexp#MatchString().(groupID) |
| 313 | } |