messagebird / sachet

SMS alerts for Prometheus' Alertmanager

Home Page:https://www.messagebird.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

psst..

callowaylc opened this issue · comments

thanks @callowaylc. Pull request #44 should fix it, right?

Theoretically, it should, but I haven't tested it.

Browsing through cmd/sachet/main.go and examples/config.yaml, there seems to be a disconnect between the token definition, defined "in" config.telegram.token, and the unmarshaling of the receiver object, which does not contain the bot token.
https://github.com/messagebird/sachet/blob/master/examples/config.yaml#L22-L23
https://github.com/messagebird/sachet/blob/master/examples/config.yaml#L40-L43

Unless I am mistaken, when we unmarshal the receiver, it shouldn't contain the token.
https://github.com/messagebird/sachet/blob/master/cmd/sachet/main.go#L50-L55

Which if the case, token will not be present there.
https://github.com/messagebird/sachet/pull/44/files#diff-f0743f22c708ff8f49227a99aa165690R19

Nice that you spent time looking!

The thing is that I think it works :-D

Right at the beginning of the handler we get the receiver name from the request (call to receiverConfByReceiver):
https://github.com/messagebird/sachet/blob/master/cmd/sachet/main.go#L50

With the receiverConf we do providerByName. There is a simple switch and here
https://github.com/messagebird/sachet/blob/master/cmd/sachet/main.go#L152 you see we instantiating a telegram.Telegram passing the config.Providers.Telegram that has the token!

Back in main we use that provider by calling Send on it https://github.com/messagebird/sachet/blob/master/cmd/sachet/main.go#L96

all should work :-D