fix: accept jpush token metadata fields

This commit is contained in:
richjohnrambo
2026-09-14 17:34:12 +08:00
parent 2581d7b8f0
commit 02eddb6010
4 changed files with 47 additions and 27 deletions
+24 -15
View File
@@ -319,10 +319,13 @@ type imYouthModeEnableRequest struct {
}
type imDevicePushTokenRequest struct {
Provider string `json:"provider"`
Token string `json:"token"`
AppVersion string `json:"app_version,omitempty"`
Platform string `json:"platform,omitempty"`
Provider string `json:"provider"`
Token string `json:"token"`
AppVersion string `json:"app_version,omitempty"`
Platform string `json:"platform,omitempty"`
SDKVersion string `json:"sdk_version,omitempty"`
PushEnv string `json:"push_env,omitempty"`
NotificationPermission string `json:"notification_permission,omitempty"`
}
type imP2PConversationRequest struct {
@@ -3356,12 +3359,15 @@ func serveIMDevicePushToken(wrt http.ResponseWriter, req *http.Request) {
return
}
token, err := store.DevicePushTokens.Upsert(principal.TenantID, &types.DevicePushToken{
UserID: principal.Uid,
DeviceID: deviceID,
Provider: body.Provider,
Token: body.Token,
AppVersion: body.AppVersion,
Platform: body.Platform,
UserID: principal.Uid,
DeviceID: deviceID,
Provider: body.Provider,
Token: body.Token,
AppVersion: body.AppVersion,
Platform: body.Platform,
SDKVersion: body.SDKVersion,
PushEnv: body.PushEnv,
NotificationPermission: body.NotificationPermission,
})
if err != nil {
writeIMRelationError(wrt, req, err)
@@ -9664,11 +9670,14 @@ func youthModeRestrictionItems(restrictions []string) []map[string]any {
func devicePushTokenPayload(token *types.DevicePushToken) map[string]any {
return map[string]any{
"device_id": token.DeviceID,
"provider": token.Provider,
"app_version": token.AppVersion,
"platform": token.Platform,
"updated_at": token.UpdatedAt.UTC().Format(time.RFC3339Nano),
"device_id": token.DeviceID,
"provider": token.Provider,
"app_version": token.AppVersion,
"platform": token.Platform,
"sdk_version": token.SDKVersion,
"push_env": token.PushEnv,
"notification_permission": token.NotificationPermission,
"updated_at": token.UpdatedAt.UTC().Format(time.RFC3339Nano),
}
}