Skip to content

Commit

Permalink
fix(discord): rename channel into webhook ID (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
piksel committed May 14, 2021
1 parent 7a60bc1 commit 80c2c21
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/services/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func CreateAPIURLFromConfig(config *Config) string {
return fmt.Sprintf(
"%s/%s/%s",
hookURL,
config.Channel,
config.WebhookID,
config.Token)
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/services/discord/discord_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
// Config is the configuration needed to send discord notifications
type Config struct {
standard.EnumlessConfig
Channel string
WebhookID string
Token string
Title string `key:"title" default:""`
Username string `key:"username" default:"" desc:"Override the webhook default username"`
Expand Down Expand Up @@ -51,7 +51,7 @@ func (config *Config) SetURL(url *url.URL) error {
func (config *Config) getURL(resolver types.ConfigQueryResolver) (u *url.URL) {
u = &url.URL{
User: url.User(config.Token),
Host: config.Channel,
Host: config.WebhookID,
Scheme: Scheme,
RawQuery: format.BuildQuery(resolver),
ForceQuery: false,
Expand All @@ -67,7 +67,7 @@ func (config *Config) getURL(resolver types.ConfigQueryResolver) (u *url.URL) {
// SetURL updates a ServiceConfig from a URL representation of it's field values
func (config *Config) setURL(resolver types.ConfigQueryResolver, url *url.URL) error {

config.Channel = url.Host
config.WebhookID = url.Host
config.Token = url.User.Username()

if len(url.Path) > 0 {
Expand All @@ -80,8 +80,8 @@ func (config *Config) setURL(resolver types.ConfigQueryResolver, url *url.URL) e
}
}

if config.Channel == "" {
return errors.New("channel missing from config URL")
if config.WebhookID == "" {
return errors.New("webhook ID missing from config URL")
}

if len(config.Token) < 1 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/services/discord/discord_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ var _ = Describe("the discord service", func() {
})
It("should not report an error if the server accepts the payload", func() {
config := Config{
Channel: "1",
Token: "dummyToken",
WebhookID: "1",
Token: "dummyToken",
}
serviceURL := config.GetURL()
service := Service{}
Expand Down

0 comments on commit 80c2c21

Please sign in to comment.