🐛 Bug fixes

This commit is contained in:
2024-06-07 20:24:32 +08:00
parent 332557778d
commit b44786ae9a
3 changed files with 9 additions and 10 deletions

View File

@ -32,7 +32,7 @@ func (v *Server) NotifyUser(_ context.Context, in *proto.NotifyRequest) (*proto.
})
notification := models.Notification{
Type: in.GetType(),
Type: lo.Ternary(len(in.GetType()) > 0, in.GetType(), "common"),
Subject: in.GetSubject(),
Content: in.GetContent(),
Metadata: metadata,

View File

@ -118,13 +118,18 @@ func PushNotification(notification models.Notification) error {
}
payload := &apns2.Notification{
DeviceToken: subscriber.DeviceToken,
Topic: "dev.solsynth.solian.UniversalNotification",
Topic: "dev.solsynth.solian",
Payload: data,
}
_, err = ExtAPNS.Push(payload)
if err != nil {
if resp, err := ExtAPNS.Push(payload); err != nil {
log.Warn().Err(err).Msg("An error occurred when notify subscriber via APNs...")
} else {
log.Debug().
Str("reason", resp.Reason).
Int("status", resp.StatusCode).
Int("subscriber", int(subscriber.ID)).
Msg("Notified subscriber via APNs.")
}
}
}