✨ Verbose provider specific logging
This commit is contained in:
parent
9be096c9b7
commit
6716397a6f
@ -2,6 +2,7 @@ package provider
|
||||
|
||||
import (
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/sideshow/apns2"
|
||||
payload2 "github.com/sideshow/apns2/payload"
|
||||
"github.com/spf13/viper"
|
||||
@ -39,7 +40,19 @@ func (v *AppleNotifyProvider) Push(in pushkit.Notification, tk string) error {
|
||||
Topic: viper.GetString(v.topic),
|
||||
Payload: rawData,
|
||||
}
|
||||
_, err = v.conn.Push(payload)
|
||||
|
||||
resp, err := v.conn.Push(payload)
|
||||
if resp != nil {
|
||||
log.Debug().
|
||||
Str("token", tk).
|
||||
Str("remote_id", resp.ApnsID).
|
||||
Str("remote_uuid", resp.ApnsUniqueID).
|
||||
Int("status", resp.StatusCode).
|
||||
Time("timestamp", resp.Timestamp.Time).
|
||||
Str("reason", resp.Reason).
|
||||
Msg("Pushed once notification to apple")
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,11 @@ func PushNotification(in pushkit.NotificationPushRequest) error {
|
||||
|
||||
prov, ok := notifyProviders[in.Provider]
|
||||
if !ok {
|
||||
log.Warn().
|
||||
Str("provider", in.Provider).
|
||||
Str("topic", in.Notification.Topic).
|
||||
Str("request_id", requestId).
|
||||
Msg("Provider was not found, push skipped...")
|
||||
return fmt.Errorf("provider not found")
|
||||
}
|
||||
start := time.Now()
|
||||
@ -62,6 +67,11 @@ func PushNotificationBatch(in pushkit.NotificationPushBatchRequest) {
|
||||
for idx, key := range in.Providers {
|
||||
prov, ok := notifyProviders[key]
|
||||
if !ok {
|
||||
log.Warn().
|
||||
Str("provider", key).
|
||||
Str("topic", in.Notification.Topic).
|
||||
Str("request_id", requestId).
|
||||
Msg("Provider was not found, push skipped...")
|
||||
continue
|
||||
}
|
||||
go func() {
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"firebase.google.com/go/messaging"
|
||||
"fmt"
|
||||
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type FirebaseNotifyProvider struct {
|
||||
@ -31,7 +32,12 @@ func (v *FirebaseNotifyProvider) Push(in pushkit.Notification, tk string) error
|
||||
Token: tk,
|
||||
}
|
||||
|
||||
_, err = client.Send(ctx, message)
|
||||
resp, err := client.Send(ctx, message)
|
||||
log.Debug().
|
||||
Str("token", tk).
|
||||
Str("response", resp).
|
||||
Msg("Pushed once notification to firebase")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ func SubscribeToQueue() error {
|
||||
return
|
||||
}
|
||||
|
||||
go provider.PushNotification(req)
|
||||
provider.PushNotification(req)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to subscribe notification topic: %v", err)
|
||||
@ -46,7 +46,7 @@ func SubscribeToQueue() error {
|
||||
return
|
||||
}
|
||||
|
||||
go provider.PushNotificationBatch(req)
|
||||
provider.PushNotificationBatch(req)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to subscribe notification batch topic: %v", err)
|
||||
@ -62,7 +62,7 @@ func SubscribeToQueue() error {
|
||||
return
|
||||
}
|
||||
|
||||
go provider.SendMail(req.To, req.Email)
|
||||
provider.SendMail(req.To, req.Email)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to subscribe email topic: %v", err)
|
||||
@ -78,11 +78,9 @@ func SubscribeToQueue() error {
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
for _, to := range req.To {
|
||||
_ = provider.SendMail(to, req.Email)
|
||||
}
|
||||
}()
|
||||
for _, to := range req.To {
|
||||
_ = provider.SendMail(to, req.Email)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to subscribe email batch topic: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user