Skip to content

Commit 34dbf76

Browse files
committed
[smsgate] add priority param to send command
1 parent dd6f075 commit 34dbf76

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/android-sms-gateway/cli
33
go 1.23.2
44

55
require (
6-
github.com/android-sms-gateway/client-go v1.5.5
6+
github.com/android-sms-gateway/client-go v1.7.0
77
github.com/capcom6/go-helpers v0.0.0-20240521035631-865ee2879fa3
88
github.com/joho/godotenv v1.5.1
99
github.com/urfave/cli/v2 v2.27.5

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ github.com/android-sms-gateway/client-go v1.5.5-0.20250309004612-ebfc247ebb13 h1
22
github.com/android-sms-gateway/client-go v1.5.5-0.20250309004612-ebfc247ebb13/go.mod h1:DQsReciU1xcaVW3T5Z2bqslNdsAwCFCtghawmA6g6L4=
33
github.com/android-sms-gateway/client-go v1.5.5 h1:38ykCT1g+w3dW7ZNDeX1qyfZuvXI5h19MP/WFg4Rodw=
44
github.com/android-sms-gateway/client-go v1.5.5/go.mod h1:DQsReciU1xcaVW3T5Z2bqslNdsAwCFCtghawmA6g6L4=
5+
github.com/android-sms-gateway/client-go v1.7.0 h1:952kvhk/yDQmiVjKJV+dKHYNoWuObBwXbARwqYevbnA=
6+
github.com/android-sms-gateway/client-go v1.7.0/go.mod h1:DQsReciU1xcaVW3T5Z2bqslNdsAwCFCtghawmA6g6L4=
57
github.com/capcom6/go-helpers v0.0.0-20240521035631-865ee2879fa3 h1:mq9rmBMCCzqGnZtbQqFSd+Ua3fahqUOYaTf26YFhWJc=
68
github.com/capcom6/go-helpers v0.0.0-20240521035631-865ee2879fa3/go.mod h1:WDqc7HZNqHxUTisArkYIBZtqUfJBVyPWeQI+FMwEzAw=
79
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=

internal/commands/messages/send.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ var send = &cli.Command{
3333
Aliases: []string{"simNumber"},
3434
Usage: "SIM card index (one-based index, e.g. 1)",
3535
},
36+
&cli.BoolFlag{
37+
Name: "deliveryReport",
38+
Usage: "Enable delivery report (default: true)",
39+
Value: true,
40+
},
41+
&cli.IntFlag{
42+
Name: "priority",
43+
Usage: "Priority, use >= 100 to bypass all limits and delays (-128 to 127, default: 0)",
44+
Value: 0,
45+
},
3646
&cli.DurationFlag{
3747
Name: "ttl",
3848
Usage: "Time to live (duration, e.g. 1h30m)",
@@ -49,7 +59,12 @@ var send = &cli.Command{
4959
ttl := c.Duration("ttl")
5060
validUntil := c.Timestamp("validUntil")
5161
if ttl > 0 && validUntil != nil {
52-
return cli.Exit("TTL and Valid Until flags are mutually exclusive", 1)
62+
return cli.Exit("TTL and Valid Until flags are mutually exclusive", codes.ParamsError)
63+
}
64+
65+
priority := c.Int("priority")
66+
if priority < int(smsgateway.PriorityMinimum) || priority > int(smsgateway.PriorityMaximum) {
67+
return cli.Exit(fmt.Sprintf("Priority must be between %d and %d", smsgateway.PriorityMinimum, smsgateway.PriorityMaximum), codes.ParamsError)
5368
}
5469

5570
return nil
@@ -63,10 +78,13 @@ var send = &cli.Command{
6378
client := metadata.GetClient(c.App.Metadata)
6479
renderer := metadata.GetRenderer(c.App.Metadata)
6580

81+
withDeliveryReport := c.Bool("deliveryReport")
6682
req := smsgateway.Message{
67-
ID: c.String("id"),
68-
Message: msg,
69-
PhoneNumbers: c.StringSlice("phones"),
83+
ID: c.String("id"),
84+
Message: msg,
85+
PhoneNumbers: c.StringSlice("phones"),
86+
WithDeliveryReport: &withDeliveryReport,
87+
Priority: smsgateway.MessagePriority(c.Int("priority")),
7088
}
7189

7290
if sim := uint8(c.Int("sim")); sim > 0 {

0 commit comments

Comments
 (0)