🐛 Bug fix and fix

This commit is contained in:
LittleSheep 2024-06-07 20:50:27 +08:00
parent b44786ae9a
commit 533745e0e4
3 changed files with 9 additions and 5 deletions

View File

@ -4,10 +4,10 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Apple push notification services"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Bug fixes">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <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/services/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/services/notifications.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/services/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/services/notifications.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/settings.toml" beforeDir="false" afterPath="$PROJECT_DIR$/settings.toml" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -142,7 +142,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":sparkles: Batch mark notify as read API" />
<MESSAGE value=":bug: Bug fixes of risk detection&#10;:lipstick: Optimized UI" /> <MESSAGE value=":bug: Bug fixes of risk detection&#10;:lipstick: Optimized UI" />
<MESSAGE value=":sparkles: Realm in passport" /> <MESSAGE value=":sparkles: Realm in passport" />
<MESSAGE value=":sparkles: Realm GRPC" /> <MESSAGE value=":sparkles: Realm GRPC" />
@ -167,7 +166,8 @@
<MESSAGE value=":bug: Bug fixes in update avatar" /> <MESSAGE value=":bug: Bug fixes in update avatar" />
<MESSAGE value=":sparkles: Firebase is back" /> <MESSAGE value=":sparkles: Firebase is back" />
<MESSAGE value=":sparkles: Apple push notification services" /> <MESSAGE value=":sparkles: Apple push notification services" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Apple push notification services" /> <MESSAGE value=":bug: Bug fixes" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Bug fixes" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

View File

@ -8,6 +8,7 @@ import (
"github.com/rs/zerolog/log" "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"
"reflect" "reflect"
) )
@ -112,13 +113,15 @@ func PushNotification(notification models.Notification) error {
NewPayload(). NewPayload().
AlertTitle(notification.Subject). AlertTitle(notification.Subject).
AlertBody(notification.Content). AlertBody(notification.Content).
Badge(1).
MarshalJSON() MarshalJSON()
if err != nil { if err != nil {
log.Warn().Err(err).Msg("An error occurred when preparing to notify subscriber via APNs...") log.Warn().Err(err).Msg("An error occurred when preparing to notify subscriber via APNs...")
} }
payload := &apns2.Notification{ payload := &apns2.Notification{
ApnsID: subscriber.DeviceID,
DeviceToken: subscriber.DeviceToken, DeviceToken: subscriber.DeviceToken,
Topic: "dev.solsynth.solian", Topic: viper.GetString("apns_topic"),
Payload: data, Payload: data,
} }

View File

@ -6,6 +6,7 @@ grpc_bind = "0.0.0.0:7444"
domain = "localhost" domain = "localhost"
secret = "LtTjzAGFLshwXhN4ZD4nG5KlMv1MWcsvfv03TSZYnT1VhiAnLIZFTnHUwR0XhGgi" secret = "LtTjzAGFLshwXhN4ZD4nG5KlMv1MWcsvfv03TSZYnT1VhiAnLIZFTnHUwR0XhGgi"
apns_topic = "dev.solsynth.solian.Runner"
apns_credentials = "" apns_credentials = ""
apns_credentials_team = "000000000" apns_credentials_team = "000000000"
apns_credentials_key = "000000000" apns_credentials_key = "000000000"