Skip to content

Commit

Permalink
livenote: add option channel
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Nov 11, 2024
1 parent 0b2fdd4 commit 9b1060e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pkg/livenote/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import "time"

type Option interface{}

type OptionChannel struct {
Channel string
}

func Channel(channel string) *OptionChannel {
return &OptionChannel{
Channel: channel,
}
}

type OptionCompare struct {
Value bool
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/notifier/slacknotifier/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ func (n *Notifier) PostLiveNote(obj livenote.Object, opts ...livenote.Option) er
var shouldPin bool
var ttl time.Duration = 0

// load the default channel
channel := n.channel

for _, opt := range opts {
switch val := opt.(type) {
case *livenote.OptionOneTimeMention:
Expand All @@ -254,6 +257,10 @@ func (n *Notifier) PostLiveNote(obj livenote.Object, opts ...livenote.Option) er
shouldPin = val.Value
case *livenote.OptionTimeToLive:
ttl = val.Duration
case *livenote.OptionChannel:
if val.Channel != "" {
channel = val.Channel
}
}
}

Expand All @@ -265,7 +272,6 @@ func (n *Notifier) PostLiveNote(obj livenote.Object, opts ...livenote.Option) er
}
}

channel := n.channel
note := n.liveNotePool.Update(obj)
curObj = note.Object

Expand Down

0 comments on commit 9b1060e

Please sign in to comment.