ausocean / cloud

GNU General Public License v3.0
1 stars 1 forks source link

notify: Look up recipients given a site key #189

Closed scruzin closed 5 days ago

scruzin commented 5 days ago

At present, notification recipients are specified at notifier initialization time with either one of the WithRecipient or WithRecipients options. This is sufficient when the recipients are known ahead of time but does not accommodate other scenarios.

It is proposed to add a WithRecipientLookup option that sets a function to look up recipients given a site key and a Kind.

func WithRecipientLookup(func(int64, Kind) []string) Option {
    return func(n *Notifier) error {
        n.lookup = lookup
        return nil
    }
}

This will enable notify.Send to customize recipients according to the target site and/or notification kind.

scruzin commented 5 days ago

Implemented in Pull Request #192