summaryrefslogtreecommitdiffci
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
-rw-r--r--config/config.go19
-rw-r--r--config/config.local.yaml2
-rw-r--r--config/config.prod.yaml2
-rw-r--r--config/config.stage.yaml2
-rw-r--r--internal/blogtrigger/blogtrigger.go4
-rw-r--r--main.go2
6 files changed, 10 insertions, 21 deletions
diff --git a/config/config.go b/config/config.go
index 1393dd8..d5dab2d 100644
--- a/config/config.go
+++ b/config/config.go
@@ -62,18 +62,13 @@ type Sqlite3Config struct {
}
type MailConfig struct {
- ClientHost string `json:"ClientHost" yaml:"clientHost" validate:"required"`
- MailHost string `json:"MailHost" yaml:"mailHost" validate:"required"`
- PublicName string `json:"PublicName" yaml:"publicName" validate:"required"`
- MailAddress string `json:"MailAddress" yaml:"mailAddress" validate:"required"`
- Username string `json:"Username" yaml:"username" validate:"required"`
- Password string `json:"Password" yaml:"password" validate:"required"`
- Salt string `json:"Salt" yaml:"salt" validate:"required"`
- Trigger TriggerConfig `json:"Trigger" yaml:"trigger" validate:"required"`
-}
-
-type TriggerConfig struct {
- OnNewPost string `json:"OnNewPost" yaml:"onNewPost" validate:"cron,required"`
+ ClientHost string `json:"ClientHost" yaml:"clientHost" validate:"required"`
+ MailHost string `json:"MailHost" yaml:"mailHost" validate:"required"`
+ PublicName string `json:"PublicName" yaml:"publicName" validate:"required"`
+ MailAddress string `json:"MailAddress" yaml:"mailAddress" validate:"required"`
+ Username string `json:"Username" yaml:"username" validate:"required"`
+ Password string `json:"Password" yaml:"password" validate:"required"`
+ Salt string `json:"Salt" yaml:"salt" validate:"required"`
}
func LoadConfig(path string, config *Config) error {
diff --git a/config/config.local.yaml b/config/config.local.yaml
index d40e8e9..008fa93 100644
--- a/config/config.local.yaml
+++ b/config/config.local.yaml
@@ -42,5 +42,3 @@ mail:
username: '${MAIL_USERNAME}'
password: '${MAIL_PASSWORD}'
salt: '${MAIL_SALT}'
- trigger:
- onNewPost: "* * * * *"
diff --git a/config/config.prod.yaml b/config/config.prod.yaml
index 7a9e5ae..4c0f425 100644
--- a/config/config.prod.yaml
+++ b/config/config.prod.yaml
@@ -42,5 +42,3 @@ mail:
username: '${MAIL_USERNAME}'
password: '${MAIL_PASSWORD}'
salt: '${MAIL_SALT}'
- trigger:
- onNewPost: "0/5 * * * *"
diff --git a/config/config.stage.yaml b/config/config.stage.yaml
index 8a5fde1..003ec05 100644
--- a/config/config.stage.yaml
+++ b/config/config.stage.yaml
@@ -42,5 +42,3 @@ mail:
username: '${MAIL_USERNAME}'
password: '${MAIL_PASSWORD}'
salt: '${MAIL_SALT}'
- trigger:
- onNewPost: "0/3 * * * *"
diff --git a/internal/blogtrigger/blogtrigger.go b/internal/blogtrigger/blogtrigger.go
index 9b016e8..ab66981 100644
--- a/internal/blogtrigger/blogtrigger.go
+++ b/internal/blogtrigger/blogtrigger.go
@@ -16,7 +16,7 @@ type BlogTriggerScheduler struct {
onTrigger func([]*b2.BlogPage) error
}
-func NewBlogTriggerScheduler(b2Client *b2.B2Client, availableLanguages []config.AvailableLanguageConfig, cron string, onTrigger func([]*b2.BlogPage) error) (*BlogTriggerScheduler, error) {
+func NewBlogTriggerScheduler(b2Client *b2.B2Client, availableLanguages []config.AvailableLanguageConfig, onTrigger func([]*b2.BlogPage) error) (*BlogTriggerScheduler, error) {
s, err := gocron.NewScheduler()
if err != nil {
return nil, fmt.Errorf("failed to create new scheduler: %w", err)
@@ -30,7 +30,7 @@ func NewBlogTriggerScheduler(b2Client *b2.B2Client, availableLanguages []config.
bts := &BlogTriggerScheduler{s, knownBlogPages, b2Client, onTrigger}
defer bts.s.Start()
- bts.s.NewJob(gocron.CronJob(cron, false), gocron.NewTask(func(bts *BlogTriggerScheduler) {
+ bts.s.NewJob(gocron.CronJob("0/5 * * * *", false), gocron.NewTask(func(bts *BlogTriggerScheduler) {
posts, err := bts.scan()
if err != nil {
slog.Error("failed to execute scanning new blog pages cron job", slog.String("error", err.Error()))
diff --git a/main.go b/main.go
index bd552a1..9d80cee 100644
--- a/main.go
+++ b/main.go
@@ -153,7 +153,7 @@ func main() {
os.Exit(1)
}
- router.BlogTrigger, err = blogtrigger.NewBlogTriggerScheduler(b2Client, cfg.AvailableLanguages, cfg.Mail.Trigger.OnNewPost, func(bp []*b2.BlogPage) error {
+ router.BlogTrigger, err = blogtrigger.NewBlogTriggerScheduler(b2Client, cfg.AvailableLanguages, func(bp []*b2.BlogPage) error {
for _, post := range bp {
if err := router.Mailer.NewPost(post); err != nil {
return err