refactor: remove config from notification struct. (#617)
* refactor: remove config from notification struct. * chore: update Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@@ -273,7 +273,6 @@ func handleNotification(ctx context.Context, cfg config.ConfYaml, req notify.Req
|
||||
continue
|
||||
}
|
||||
}
|
||||
notification.Cfg = cfg
|
||||
newNotification = append(newNotification, notification)
|
||||
}
|
||||
|
||||
@@ -284,10 +283,10 @@ func handleNotification(ctx context.Context, cfg config.ConfYaml, req notify.Req
|
||||
}
|
||||
|
||||
if core.IsLocalQueue(core.Queue(cfg.Queue.Engine)) && cfg.Core.Sync {
|
||||
func(msg *notify.PushNotification) {
|
||||
func(msg *notify.PushNotification, cfg config.ConfYaml) {
|
||||
q.QueueTask(func(ctx context.Context) error {
|
||||
defer wg.Done()
|
||||
resp, err := notify.SendNotification(msg)
|
||||
resp, err := notify.SendNotification(msg, cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -299,7 +298,7 @@ func handleNotification(ctx context.Context, cfg config.ConfYaml, req notify.Req
|
||||
|
||||
return nil
|
||||
})
|
||||
}(notification)
|
||||
}(notification, cfg)
|
||||
} else if err := q.Queue(notification); err != nil {
|
||||
resp := markFailedNotification(cfg, notification, "max capacity reached")
|
||||
// add log
|
||||
|
||||
@@ -36,10 +36,17 @@ func TestMain(m *testing.M) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
cfg.Android.Enabled = true
|
||||
cfg.Android.APIKey = os.Getenv("ANDROID_API_KEY")
|
||||
|
||||
if _, err := notify.InitFCMClient(cfg, ""); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
w = simple.NewWorker(
|
||||
simple.WithRunFunc(func(ctx context.Context, msg queue.QueuedMessage) error {
|
||||
notify.SendNotification(msg)
|
||||
return nil
|
||||
_, err := notify.SendNotification(msg, cfg)
|
||||
return err
|
||||
}),
|
||||
)
|
||||
q, _ = queue.NewQueue(
|
||||
@@ -600,7 +607,6 @@ func TestSyncModeForTopicNotification(t *testing.T) {
|
||||
// android
|
||||
{
|
||||
// success
|
||||
Cfg: cfg,
|
||||
Condition: "'dogs' in topics || 'cats' in topics",
|
||||
Platform: core.PlatFormAndroid,
|
||||
Message: "This is a Firebase Cloud Messaging Topic Message!",
|
||||
|
||||
Reference in New Issue
Block a user