@@ -49,10 +49,7 @@ func (c *Client) Send(entry model.NotifEntry) error {
49
49
return errors .Wrap (err , "cannot retrieve token secret for Telegram notifier" )
50
50
}
51
51
52
- var cids []interface {}
53
- for _ , cid := range c .cfg .ChatIDs {
54
- cids = append (cids , cid )
55
- }
52
+ cids := c .cfg .ChatIDs
56
53
cidsRaw , err := utl .GetSecret ("" , c .cfg .ChatIDsFile )
57
54
if err != nil {
58
55
return errors .Wrap (err , "cannot retrieve chat IDs secret for Telegram notifier" )
@@ -124,41 +121,32 @@ func (c *Client) Send(entry model.NotifEntry) error {
124
121
return nil
125
122
}
126
123
127
- func parseChatIDs (entries []interface {} ) ([]chatID , error ) {
124
+ func parseChatIDs (entries []string ) ([]chatID , error ) {
128
125
var chatIDs []chatID
129
126
for _ , entry := range entries {
130
- switch v := entry .(type ) {
131
- case int :
132
- chatIDs = append (chatIDs , chatID {id : int64 (v )})
133
- case int64 :
134
- chatIDs = append (chatIDs , chatID {id : v })
135
- case string :
136
- parts := strings .Split (v , ":" )
137
- if len (parts ) < 1 || len (parts ) > 2 {
138
- return nil , errors .Errorf ("invalid chat ID %q" , v )
139
- }
140
- id , err := strconv .ParseInt (parts [0 ], 10 , 64 )
141
- if err != nil {
142
- return nil , errors .Wrap (err , "invalid chat ID" )
143
- }
144
- var topics []int64
145
- if len (parts ) == 2 {
146
- topicParts := strings .Split (parts [1 ], ";" )
147
- for _ , topicPart := range topicParts {
148
- topic , err := strconv .ParseInt (topicPart , 10 , 64 )
149
- if err != nil {
150
- return nil , errors .Wrapf (err , "invalid topic %q for chat ID %d" , topicPart , id )
151
- }
152
- topics = append (topics , topic )
127
+ parts := strings .Split (entry , ":" )
128
+ if len (parts ) < 1 || len (parts ) > 2 {
129
+ return nil , errors .Errorf ("invalid chat ID %q" , entry )
130
+ }
131
+ id , err := strconv .ParseInt (parts [0 ], 10 , 64 )
132
+ if err != nil {
133
+ return nil , errors .Wrap (err , "invalid chat ID" )
134
+ }
135
+ var topics []int64
136
+ if len (parts ) == 2 {
137
+ topicParts := strings .Split (parts [1 ], ";" )
138
+ for _ , topicPart := range topicParts {
139
+ topic , err := strconv .ParseInt (topicPart , 10 , 64 )
140
+ if err != nil {
141
+ return nil , errors .Wrapf (err , "invalid topic %q for chat ID %d" , topicPart , id )
153
142
}
143
+ topics = append (topics , topic )
154
144
}
155
- chatIDs = append (chatIDs , chatID {
156
- id : id ,
157
- topics : topics ,
158
- })
159
- default :
160
- return nil , errors .Errorf ("invalid chat ID %v (type=%T)" , entry , entry )
161
145
}
146
+ chatIDs = append (chatIDs , chatID {
147
+ id : id ,
148
+ topics : topics ,
149
+ })
162
150
}
163
151
return chatIDs , nil
164
152
}
0 commit comments