Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Almost no services implements params overrides #88

Closed
atighineanu opened this issue Nov 24, 2020 · 1 comment · Fixed by #92
Closed

Almost no services implements params overrides #88

atighineanu opened this issue Nov 24, 2020 · 1 comment · Fixed by #92

Comments

@atighineanu
Copy link
Contributor

So, I tried to test the sender creation feature.
The code looks like this:

url := "slack://A/B/C"
	sender, err := shoutrrr.CreateSender(url)
	if err != nil {
		fmt.Printf("%v", err)
	}
	var hej_da types.Params
	hej_da = make(map[string]string)
	hej_da["channel"] = "random"
	sender.Send("tralala", &hej_da)

NOTE: I have created the "random" channel and added the bot to it. Still, when adding the params to the sender, it still didn't send the message to the desired "random" channel. Instead, it sent it to the one corresponding to one of the tokens (I guess it must be C, not sure).

@piksel
Copy link
Member

piksel commented Nov 26, 2020

Yeah, the Params overrides need to implemented in every service, and I think SMTP might be the only service that fully implements it.
Slack, like you used in your code above, does not handle them at all:

func (service *Service) Send(message string, params *types.Params) error {
config := service.config
if err := validateToken(config.Token); err != nil {
return err
}
if len(message) > maxlength {
return errors.New("message exceeds max length")
}
return service.doSend(config, message)
}

There should be a generic solution for all services to use by just adding a tag to their config.

Also, what parts can be overridden by params (and that it's that that they are used for) needs to be documented.

@piksel piksel changed the title passing *types.Params into the Sender doesn't override the corresponding token given from URL Almost no services implements params overrides Nov 26, 2020
@piksel piksel linked a pull request Dec 19, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants