Skip to content

Commit 3b3e6ac

Browse files
committed
Rename twilio-from-number to twilio-phone-number
1 parent 8ddfd24 commit 3b3e6ac

7 files changed

+19
-19
lines changed

cmd/serve.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var flagsServe = append(
7474
altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-server-addr-prefix", Aliases: []string{"smtp_server_addr_prefix"}, EnvVars: []string{"NTFY_SMTP_SERVER_ADDR_PREFIX"}, Usage: "SMTP email address prefix for topics to prevent spam (e.g. 'ntfy-')"}),
7575
altsrc.NewStringFlag(&cli.StringFlag{Name: "twilio-account", Aliases: []string{"twilio_account"}, EnvVars: []string{"NTFY_TWILIO_ACCOUNT"}, Usage: "Twilio account SID, used for phone calls, e.g. AC123..."}),
7676
altsrc.NewStringFlag(&cli.StringFlag{Name: "twilio-auth-token", Aliases: []string{"twilio_auth_token"}, EnvVars: []string{"NTFY_TWILIO_AUTH_TOKEN"}, Usage: "Twilio auth token"}),
77-
altsrc.NewStringFlag(&cli.StringFlag{Name: "twilio-from-number", Aliases: []string{"twilio_from_number"}, EnvVars: []string{"NTFY_TWILIO_FROM_NUMBER"}, Usage: "Twilio number to use for outgoing calls"}),
77+
altsrc.NewStringFlag(&cli.StringFlag{Name: "twilio-phone-number", Aliases: []string{"twilio_phone_number"}, EnvVars: []string{"NTFY_TWILIO_PHONE_NUMBER"}, Usage: "Twilio number to use for outgoing calls"}),
7878
altsrc.NewStringFlag(&cli.StringFlag{Name: "twilio-verify-service", Aliases: []string{"twilio_verify_service"}, EnvVars: []string{"NTFY_TWILIO_VERIFY_SERVICE"}, Usage: "Twilio Verify service ID, used for phone number verification"}),
7979
altsrc.NewIntFlag(&cli.IntFlag{Name: "global-topic-limit", Aliases: []string{"global_topic_limit", "T"}, EnvVars: []string{"NTFY_GLOBAL_TOPIC_LIMIT"}, Value: server.DefaultTotalTopicLimit, Usage: "total number of topics allowed"}),
8080
altsrc.NewIntFlag(&cli.IntFlag{Name: "visitor-subscription-limit", Aliases: []string{"visitor_subscription_limit"}, EnvVars: []string{"NTFY_VISITOR_SUBSCRIPTION_LIMIT"}, Value: server.DefaultVisitorSubscriptionLimit, Usage: "number of subscriptions per visitor"}),
@@ -159,7 +159,7 @@ func execServe(c *cli.Context) error {
159159
smtpServerAddrPrefix := c.String("smtp-server-addr-prefix")
160160
twilioAccount := c.String("twilio-account")
161161
twilioAuthToken := c.String("twilio-auth-token")
162-
twilioFromNumber := c.String("twilio-from-number")
162+
twilioPhoneNumber := c.String("twilio-phone-number")
163163
twilioVerifyService := c.String("twilio-verify-service")
164164
totalTopicLimit := c.Int("global-topic-limit")
165165
visitorSubscriptionLimit := c.Int("visitor-subscription-limit")
@@ -219,8 +219,8 @@ func execServe(c *cli.Context) error {
219219
return errors.New("cannot set enable-signup without also setting enable-login")
220220
} else if stripeSecretKey != "" && (stripeWebhookKey == "" || baseURL == "") {
221221
return errors.New("if stripe-secret-key is set, stripe-webhook-key and base-url must also be set")
222-
} else if twilioAccount != "" && (twilioAuthToken == "" || twilioFromNumber == "" || twilioVerifyService == "" || baseURL == "" || authFile == "") {
223-
return errors.New("if twilio-account is set, twilio-auth-token, twilio-from-number, twilio-verify-service, base-url, and auth-file must also be set")
222+
} else if twilioAccount != "" && (twilioAuthToken == "" || twilioPhoneNumber == "" || twilioVerifyService == "" || baseURL == "" || authFile == "") {
223+
return errors.New("if twilio-account is set, twilio-auth-token, twilio-phone-number, twilio-verify-service, base-url, and auth-file must also be set")
224224
}
225225

226226
// Backwards compatibility
@@ -323,7 +323,7 @@ func execServe(c *cli.Context) error {
323323
conf.SMTPServerAddrPrefix = smtpServerAddrPrefix
324324
conf.TwilioAccount = twilioAccount
325325
conf.TwilioAuthToken = twilioAuthToken
326-
conf.TwilioFromNumber = twilioFromNumber
326+
conf.TwilioPhoneNumber = twilioPhoneNumber
327327
conf.TwilioVerifyService = twilioVerifyService
328328
conf.TotalTopicLimit = totalTopicLimit
329329
conf.VisitorSubscriptionLimit = visitorSubscriptionLimit

docs/config.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ are the easiest), and then configure the following options:
866866

867867
* `twilio-account` is the Twilio account SID, e.g. AC12345beefbeef67890beefbeef122586
868868
* `twilio-auth-token` is the Twilio auth token, e.g. affebeef258625862586258625862586
869-
* `twilio-from-number` is the outgoing phone number you purchased, e.g. +18775132586
869+
* `twilio-phone-number` is the outgoing phone number you purchased, e.g. +18775132586
870870
* `twilio-verify-service` is the Twilio Verify service SID, e.g. VA12345beefbeef67890beefbeef122586
871871

872872
After you have configured phone calls, create a [tier](#tiers) with a call limit (e.g. `ntfy tier create --call-limit=10 ...`),
@@ -1261,7 +1261,7 @@ variable before running the `ntfy` command (e.g. `export NTFY_LISTEN_HTTP=:80`).
12611261
| `smtp-server-addr-prefix` | `NTFY_SMTP_SERVER_ADDR_PREFIX` | *string* | - | Optional prefix for the e-mail addresses to prevent spam, e.g. `ntfy-` |
12621262
| `twilio-account` | `NTFY_TWILIO_ACCOUNT` | *string* | - | Twilio account SID, e.g. AC12345beefbeef67890beefbeef122586 |
12631263
| `twilio-auth-token` | `NTFY_TWILIO_AUTH_TOKEN` | *string* | - | Twilio auth token, e.g. affebeef258625862586258625862586 |
1264-
| `twilio-from-number` | `NTFY_TWILIO_FROM_NUMBER` | *string* | - | Twilio outgoing phone number, e.g. +18775132586 |
1264+
| `twilio-phone-number` | `NTFY_TWILIO_PHONE_NUMBER` | *string* | - | Twilio outgoing phone number, e.g. +18775132586 |
12651265
| `twilio-verify-service` | `NTFY_TWILIO_VERIFY_SERVICE` | *string* | - | Twilio Verify service SID, e.g. VA12345beefbeef67890beefbeef122586 |
12661266
| `keepalive-interval` | `NTFY_KEEPALIVE_INTERVAL` | *duration* | 45s | Interval in which keepalive messages are sent to the client. This is to prevent intermediaries closing the connection for inactivity. Note that the Android app has a hardcoded timeout at 77s, so it should be less than that. |
12671267
| `manager-interval` | `NTFY_MANAGER_INTERVAL` | *duration* | 1m | Interval in which the manager prunes old messages, deletes topics and prints the stats. |

server/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ type Config struct {
108108
SMTPServerAddrPrefix string
109109
TwilioAccount string
110110
TwilioAuthToken string
111-
TwilioFromNumber string
111+
TwilioPhoneNumber string
112112
TwilioCallsBaseURL string
113113
TwilioVerifyBaseURL string
114114
TwilioVerifyService string
@@ -194,7 +194,7 @@ func NewConfig() *Config {
194194
TwilioCallsBaseURL: "https://api.twilio.com", // Override for tests
195195
TwilioAccount: "",
196196
TwilioAuthToken: "",
197-
TwilioFromNumber: "",
197+
TwilioPhoneNumber: "",
198198
TwilioVerifyBaseURL: "https://verify.twilio.com", // Override for tests
199199
TwilioVerifyService: "",
200200
MessageLimit: DefaultMessageLengthLimit,

server/server.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@
148148
#
149149
# - twilio-account is the Twilio account SID, e.g. AC12345beefbeef67890beefbeef122586
150150
# - twilio-auth-token is the Twilio auth token, e.g. affebeef258625862586258625862586
151-
# - twilio-from-number is the outgoing phone number you purchased, e.g. +18775132586
151+
# - twilio-phone-number is the outgoing phone number you purchased, e.g. +18775132586
152152
# - twilio-verify-service is the Twilio Verify service SID, e.g. VA12345beefbeef67890beefbeef122586
153153
#
154154
# twilio-account:
155155
# twilio-auth-token:
156-
# twilio-from-number:
156+
# twilio-phone-number:
157157
# twilio-verify-service:
158158

159159
# Interval in which keepalive messages are sent to the client. This is to prevent

server/server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ func TestServer_PublishDelayedCall_Fail(t *testing.T) {
11981198
c := newTestConfigWithAuthFile(t)
11991199
c.TwilioAccount = "AC1234567890"
12001200
c.TwilioAuthToken = "AAEAA1234567890"
1201-
c.TwilioFromNumber = "+1234567890"
1201+
c.TwilioPhoneNumber = "+1234567890"
12021202
s := newTestServer(t, c)
12031203
response := request(t, s, "PUT", "/mytopic", "fail", map[string]string{
12041204
"Call": "yes",

server/server_twilio.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (s *Server) callPhone(v *visitor, r *http.Request, m *message, to string) {
6767
}
6868
body := fmt.Sprintf(twilioCallFormat, xmlEscapeText(m.Topic), xmlEscapeText(m.Message), xmlEscapeText(sender))
6969
data := url.Values{}
70-
data.Set("From", s.config.TwilioFromNumber)
70+
data.Set("From", s.config.TwilioPhoneNumber)
7171
data.Set("To", to)
7272
data.Set("Twiml", body)
7373
ev := logvrm(v, r, m).Tag(tagTwilio).Field("twilio_to", to).FieldIf("twilio_body", body, log.TraceLevel).Debug("Sending Twilio request")

server/server_twilio_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestServer_Twilio_Call_Add_Verify_Call_Delete_Success(t *testing.T) {
5353
c.TwilioCallsBaseURL = twilioCallsServer.URL
5454
c.TwilioAccount = "AC1234567890"
5555
c.TwilioAuthToken = "AAEAA1234567890"
56-
c.TwilioFromNumber = "+1234567890"
56+
c.TwilioPhoneNumber = "+1234567890"
5757
c.TwilioVerifyService = "VA1234567890"
5858
s := newTestServer(t, c)
5959

@@ -131,7 +131,7 @@ func TestServer_Twilio_Call_Success(t *testing.T) {
131131
c.TwilioCallsBaseURL = twilioServer.URL
132132
c.TwilioAccount = "AC1234567890"
133133
c.TwilioAuthToken = "AAEAA1234567890"
134-
c.TwilioFromNumber = "+1234567890"
134+
c.TwilioPhoneNumber = "+1234567890"
135135
s := newTestServer(t, c)
136136

137137
// Add tier and user
@@ -176,7 +176,7 @@ func TestServer_Twilio_Call_Success_With_Yes(t *testing.T) {
176176
c.TwilioCallsBaseURL = twilioServer.URL
177177
c.TwilioAccount = "AC1234567890"
178178
c.TwilioAuthToken = "AAEAA1234567890"
179-
c.TwilioFromNumber = "+1234567890"
179+
c.TwilioPhoneNumber = "+1234567890"
180180
s := newTestServer(t, c)
181181

182182
// Add tier and user
@@ -207,7 +207,7 @@ func TestServer_Twilio_Call_UnverifiedNumber(t *testing.T) {
207207
c.TwilioCallsBaseURL = "http://dummy.invalid"
208208
c.TwilioAccount = "AC1234567890"
209209
c.TwilioAuthToken = "AAEAA1234567890"
210-
c.TwilioFromNumber = "+1234567890"
210+
c.TwilioPhoneNumber = "+1234567890"
211211
s := newTestServer(t, c)
212212

213213
// Add tier and user
@@ -232,7 +232,7 @@ func TestServer_Twilio_Call_InvalidNumber(t *testing.T) {
232232
c.TwilioCallsBaseURL = "https://127.0.0.1"
233233
c.TwilioAccount = "AC1234567890"
234234
c.TwilioAuthToken = "AAEAA1234567890"
235-
c.TwilioFromNumber = "+1234567890"
235+
c.TwilioPhoneNumber = "+1234567890"
236236
s := newTestServer(t, c)
237237

238238
response := request(t, s, "POST", "/mytopic", "test", map[string]string{
@@ -246,7 +246,7 @@ func TestServer_Twilio_Call_Anonymous(t *testing.T) {
246246
c.TwilioCallsBaseURL = "https://127.0.0.1"
247247
c.TwilioAccount = "AC1234567890"
248248
c.TwilioAuthToken = "AAEAA1234567890"
249-
c.TwilioFromNumber = "+1234567890"
249+
c.TwilioPhoneNumber = "+1234567890"
250250
s := newTestServer(t, c)
251251

252252
response := request(t, s, "POST", "/mytopic", "test", map[string]string{

0 commit comments

Comments
 (0)