generated from ViBiOh/goweb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding check if mailer is enabled (#7)
- Loading branch information
Showing
3 changed files
with
12 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,7 @@ func (a app) checkUpdates(_ time.Time) error { | |
} | ||
|
||
if release.TagName != target.LatestVersion { | ||
logger.Info("New version available for %s", target.Repository) | ||
logger.Info("New version available for %s: %s", target.Repository, release.TagName) | ||
target.LatestVersion = release.TagName | ||
|
||
newReleases = append(newReleases, release) | ||
|
@@ -92,7 +92,9 @@ func (a app) checkUpdates(_ time.Time) error { | |
} | ||
|
||
if len(newReleases) > 0 { | ||
if err := mailer.NewEmail(a.mailerApp).Template("ketchup").From("[email protected]").As("Ketchup").WithSubject("Ketchup - New version available").To(a.emailTo).Data(newReleases).Send(context.Background()); err != nil { | ||
if a.mailerApp == nil || !a.mailerApp.Enabled() { | ||
logger.Warn("mailer is not configured") | ||
} else if err := mailer.NewEmail(a.mailerApp).Template("ketchup").From("[email protected]").As("Ketchup").WithSubject("Ketchup - New update").To(a.emailTo).Data(newReleases).Send(context.Background()); err != nil { | ||
logger.Error("unable to send email to %s: %s", a.emailTo, err) | ||
} | ||
} | ||
|