Skip to content

Commit

Permalink
refactor: consistent receiver naming
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneM committed Sep 19, 2023
1 parent cf0844e commit 1ad6950
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions notifier_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,47 +48,47 @@ type DetailedNotifier interface {
type Notifiers []DetailedNotifier

// DetailedNotifier implementation
func (not *Notifier) GetNotifier() *Notifier {
return not
func (n *Notifier) GetNotifier() *Notifier {
return n
}

func (not *Notifier) GetID() string {
return not.ID
func (n *Notifier) GetID() string {
return n.ID
}

func (not *Notifier) GetName() string {
return not.Name
func (n *Notifier) GetName() string {
return n.Name
}

func (not *Notifier) GetType() NotifierType {
return not.Type
func (n *Notifier) GetType() NotifierType {
return n.Type
}

func (not *Notifier) GetSendAllEvents() bool {
return *not.SendAllEvents
func (n *Notifier) GetSendAllEvents() bool {
return *n.SendAllEvents
}

func (not *Notifier) GetSendAllAlerts() bool {
return *not.SendAllAlerts
func (n *Notifier) GetSendAllAlerts() bool {
return *n.SendAllAlerts
}

func (not *Notifier) GetSelectedEventIDs() []string {
return not.SelectedEventIDs
func (n *Notifier) GetSelectedEventIDs() []string {
return n.SelectedEventIDs
}

func (not *Notifier) IsActive() bool {
return *not.Active
func (n *Notifier) IsActive() bool {
return *n.Active
}

func (not *Notifier) When() string {
return not.UpdatedAt.Format("Mon Jan 02 2006 15:04:05")
func (n *Notifier) When() string {
return n.UpdatedAt.Format("Mon Jan 02 2006 15:04:05")
}

func (not *Notifier) TypeDataPtr() interface{} {
return &not.TypeData
func (n *Notifier) TypeDataPtr() interface{} {
return &n.TypeData
}

func (not *Notifier) TypeDataMap() map[string]interface{} {
func (n *Notifier) TypeDataMap() map[string]interface{} {
return map[string]interface{}{}
}

Expand All @@ -106,9 +106,9 @@ func (e *NotifierWebhookType) TypeDataPtr() interface{} {
return &e.TypeData
}

func (not *NotifierWebhookType) TypeDataMap() map[string]interface{} {
func (e *NotifierWebhookType) TypeDataMap() map[string]interface{} {
return map[string]interface{}{
"webhook url": not.TypeData.WebhookURL,
"webhook url": e.TypeData.WebhookURL,
}
}

Expand All @@ -126,9 +126,9 @@ func (e *NotifierSlackType) TypeDataPtr() interface{} {
return &e.TypeData
}

func (not *NotifierSlackType) TypeDataMap() map[string]interface{} {
func (e *NotifierSlackType) TypeDataMap() map[string]interface{} {
return map[string]interface{}{
"webhook url": not.TypeData.WebhookURL,
"webhook url": e.TypeData.WebhookURL,
}
}

Expand All @@ -154,9 +154,9 @@ func (not *NotifierEmailType) TypeDataMap() map[string]interface{} {
}
}

func (pnot *Notifier) Specialize() DetailedNotifier {
func (n *Notifier) Specialize() DetailedNotifier {
var detailedNotifier DetailedNotifier
notifier := *pnot
notifier := *n
switch notifier.Type {
case NotifierWebhook:
detailedNotifier = &NotifierWebhookType{Notifier: notifier}
Expand All @@ -165,12 +165,12 @@ func (pnot *Notifier) Specialize() DetailedNotifier {
case NotifierEmail:
detailedNotifier = &NotifierEmailType{Notifier: notifier}
default:
return pnot
return n
}
err := json.Unmarshal(pnot.RawTypeData, detailedNotifier.TypeDataPtr())
err := json.Unmarshal(n.RawTypeData, detailedNotifier.TypeDataPtr())
if err != nil {
debug.Printf("error reading the data: %+v\n", err)
return pnot
return n
}
return detailedNotifier
}
Expand Down

0 comments on commit 1ad6950

Please sign in to comment.