Skip to content

Commit

Permalink
Extract method notifyAboutStateChange to follow DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
ebroda committed Nov 25, 2024
1 parent 03bffe6 commit 1c50a22
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions dao/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,34 +435,30 @@ func EventStateNotification(ctx context.Context, i *models.Event) (err error) {
return
}

notifyAboutStateChange(eventAps, i)
return
}

func notifyAboutStateChange(notifyUser *models.User, i *models.Event) {
template := "event_state"
mail := vcago.NewMailData(eventAps.Email, "pool-backend", template, "pool", eventAps.Country)
mail.AddUser(eventAps.User())
mail := vcago.NewMailData(notifyUser.Email, "pool-backend", template, "pool", notifyUser.Country)
mail.AddUser(notifyUser.User())
mail.AddContent(i.ToContent())
vcago.Nats.Publish("system.mail.job", mail)
//notification := vcago.NewMNotificationData(user.Email, "pool-backend", template, user.Country, token.ID)
//notification.AddUser(user.User())

//notification := vcago.NewMNotificationData(notifyUser.Email, "pool-backend", template, notifyUser.Country, token.ID)
//notification.AddUser(notifyUser.User())
//notification.AddContent(i.ToContent())
//vcago.Nats.Publish("system.notification.job", notification)
return
}

func EventStateNotificationCreator(i *models.Event) (err error) {

// if event_asp is creator -> stop.
if i.EventASPID == i.Creator.ID {
return
}

template := "event_state"
mail := vcago.NewMailData(i.Creator.Email, "pool-backend", template, "pool", i.Creator.Country)
mail.AddUser(i.Creator)
mail.AddContent(i.ToContent())
vcago.Nats.Publish("system.mail.job", mail)
//notification := vcago.NewMNotificationData(user.Email, "pool-backend", template, user.Country, token.ID)
//notification.AddUser(user.User())
//notification.AddContent(i.ToContent())
//vcago.Nats.Publish("system.notification.job", notification)
notifyAboutStateChange(i.Creator, i)

Check failure on line 461 in dao/event.go

View workflow job for this annotation

GitHub Actions / check-run

cannot use i.Creator (variable of type models.User) as *models.User value in argument to notifyAboutStateChange
return
}

Expand Down

0 comments on commit 1c50a22

Please sign in to comment.