🔊 Verbose notifying logging

This commit is contained in:
LittleSheep 2024-11-23 00:34:53 +08:00
parent 663b563b39
commit 720f9690f6
2 changed files with 15 additions and 6 deletions

8
.idea/workspace.xml generated
View File

@ -4,9 +4,9 @@
<option name="autoReloadType" value="ALL" />
</component>
<component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix get user info query statement bug">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":boom: Remove deprecated subscription API">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/index.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/index.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/notifications.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -159,7 +159,6 @@
</component>
<component name="VcsManagerConfiguration">
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<MESSAGE value=":bug: Fix notification order... again" />
<MESSAGE value=":bug: Trying to fix panic" />
<MESSAGE value=":recycle: Remove most of the dealer deps and move to nexus" />
<MESSAGE value=":recycle: Refactored more modules into nexus" />
@ -184,7 +183,8 @@
<MESSAGE value=":sparkles: Allow get realm by numeric auto increment id" />
<MESSAGE value=":sparkles: Allow access user info via numeric id" />
<MESSAGE value=":bug: Fix get user info query statement bug" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix get user info query statement bug" />
<MESSAGE value=":boom: Remove deprecated subscription API" />
<option name="LAST_COMMIT_MESSAGE" value=":boom: Remove deprecated subscription API" />
<option name="GROUP_MULTIFILE_MERGE_BY_DIRECTORY" value="true" />
</component>
<component name="VgoProject">

View File

@ -129,6 +129,8 @@ func PushNotification(notification models.Notification, skipNotifiableCheck ...b
tokens = append(tokens, subscriber.DeviceToken)
}
log.Debug().Str("topic", notification.Topic).Any("uid", notification.AccountID).Msg("Pushing notify to user...")
ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
err = gap.Px.PushNotifyBatch(pushkit.NotificationPushBatchRequest{
@ -136,6 +138,9 @@ func PushNotification(notification models.Notification, skipNotifiableCheck ...b
Tokens: tokens,
Notification: notification.EncodeToPushkit(),
})
if err != nil {
log.Warn().Err(err).Str("topic", notification.Topic).Msg("Failed to push notification to Pusher")
}
return err
}
@ -167,6 +172,8 @@ func PushNotificationBatch(notifications []models.Notification, skipNotifiableCh
)
}
log.Debug().Str("topic", notifications[0].Topic).Any("uid", accountIdx).Msg("Pushing notify to users...")
if len(accountIdx) == 0 {
return
}
@ -201,11 +208,13 @@ func PushNotificationBatch(notifications []models.Notification, skipNotifiableCh
}
ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
_ = gap.Px.PushNotifyBatch(pushkit.NotificationPushBatchRequest{
if err := gap.Px.PushNotifyBatch(pushkit.NotificationPushBatchRequest{
Providers: providers,
Tokens: tokens,
Notification: notification.EncodeToPushkit(),
})
}); err != nil {
log.Warn().Err(err).Str("topic", notification.Topic).Msg("Failed to push notification to Pusher")
}
cancel()
}
}