base.go 922 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package notifiers
  2. import (
  3. "github.com/grafana/grafana/pkg/components/simplejson"
  4. "github.com/grafana/grafana/pkg/services/alerting"
  5. )
  6. type NotifierBase struct {
  7. Name string
  8. Type string
  9. Id int64
  10. IsDeault bool
  11. UploadImage bool
  12. }
  13. func NewNotifierBase(id int64, isDefault bool, name, notifierType string, model *simplejson.Json) NotifierBase {
  14. uploadImage := model.Get("uploadImage").MustBool(true)
  15. return NotifierBase{
  16. Id: id,
  17. Name: name,
  18. IsDeault: isDefault,
  19. Type: notifierType,
  20. UploadImage: uploadImage,
  21. }
  22. }
  23. func (n *NotifierBase) PassesFilter(rule *alerting.Rule) bool {
  24. return true
  25. }
  26. func (n *NotifierBase) GetType() string {
  27. return n.Type
  28. }
  29. func (n *NotifierBase) NeedsImage() bool {
  30. return n.UploadImage
  31. }
  32. func (n *NotifierBase) GetNotifierId() int64 {
  33. return n.Id
  34. }
  35. func (n *NotifierBase) GetIsDefault() bool {
  36. return n.IsDeault
  37. }