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