🐛 Bug fixes

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

View File

@ -7,12 +7,6 @@
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Apple push notification services">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/grpc/notify.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/notify.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/grpc/proto/notify.pb.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/proto/notify.pb.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/grpc/proto/notify.proto" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/proto/notify.proto" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/grpc/proto/notify_grpc.pb.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/proto/notify_grpc.pb.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/models/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/models/notifications.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/server/notifications_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/notifications_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/server/notify_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/notify_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/services/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/services/notifications.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />

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.")
}
}
}