fix: accept jpush token metadata fields
This commit is contained in:
@@ -1372,6 +1372,9 @@ func createIMUserProductTables(tx *sql.Tx) error {
|
|||||||
token VARCHAR(512) NOT NULL,
|
token VARCHAR(512) NOT NULL,
|
||||||
app_version VARCHAR(64) NOT NULL DEFAULT '',
|
app_version VARCHAR(64) NOT NULL DEFAULT '',
|
||||||
platform VARCHAR(32) NOT NULL DEFAULT '',
|
platform VARCHAR(32) NOT NULL DEFAULT '',
|
||||||
|
sdk_version VARCHAR(64) NOT NULL DEFAULT '',
|
||||||
|
push_env VARCHAR(32) NOT NULL DEFAULT '',
|
||||||
|
notification_permission VARCHAR(32) NOT NULL DEFAULT '',
|
||||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||||
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||||
PRIMARY KEY(id),
|
PRIMARY KEY(id),
|
||||||
|
|||||||
@@ -6281,16 +6281,21 @@ func (a *adapter) TenantDevicePushTokenUpsert(id t.TenantID, token *t.DevicePush
|
|||||||
token.Token = strings.TrimSpace(token.Token)
|
token.Token = strings.TrimSpace(token.Token)
|
||||||
token.AppVersion = strings.TrimSpace(token.AppVersion)
|
token.AppVersion = strings.TrimSpace(token.AppVersion)
|
||||||
token.Platform = strings.ToLower(strings.TrimSpace(token.Platform))
|
token.Platform = strings.ToLower(strings.TrimSpace(token.Platform))
|
||||||
|
token.SDKVersion = strings.TrimSpace(token.SDKVersion)
|
||||||
|
token.PushEnv = strings.ToLower(strings.TrimSpace(token.PushEnv))
|
||||||
|
token.NotificationPermission = strings.ToLower(strings.TrimSpace(token.NotificationPermission))
|
||||||
tokenID, err := nextSnowflakeID()
|
tokenID, err := nextSnowflakeID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
_, err = a.db.ExecContext(ctx,
|
_, err = a.db.ExecContext(ctx,
|
||||||
`INSERT INTO im_device_push_tokens(id,device_id,user_id,provider,token,app_version,platform,created_at,updated_at)
|
`INSERT INTO im_device_push_tokens(id,device_id,user_id,provider,token,app_version,platform,sdk_version,push_env,notification_permission,created_at,updated_at)
|
||||||
VALUES(?,?,?,?,?,?,?,?,?)
|
VALUES(?,?,?,?,?,?,?,?,?,?,?,?)
|
||||||
ON DUPLICATE KEY UPDATE device_id=VALUES(device_id),user_id=VALUES(user_id),provider=VALUES(provider),token=VALUES(token),
|
ON DUPLICATE KEY UPDATE device_id=VALUES(device_id),user_id=VALUES(user_id),provider=VALUES(provider),token=VALUES(token),
|
||||||
app_version=VALUES(app_version),platform=VALUES(platform),updated_at=VALUES(updated_at)`,
|
app_version=VALUES(app_version),platform=VALUES(platform),sdk_version=VALUES(sdk_version),push_env=VALUES(push_env),
|
||||||
tokenID, token.DeviceID, decodeUID(token.UserID), token.Provider, token.Token, token.AppVersion, token.Platform, now, now)
|
notification_permission=VALUES(notification_permission),updated_at=VALUES(updated_at)`,
|
||||||
|
tokenID, token.DeviceID, decodeUID(token.UserID), token.Provider, token.Token, token.AppVersion, token.Platform,
|
||||||
|
token.SDKVersion, token.PushEnv, token.NotificationPermission, now, now)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-15
@@ -319,10 +319,13 @@ type imYouthModeEnableRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type imDevicePushTokenRequest struct {
|
type imDevicePushTokenRequest struct {
|
||||||
Provider string `json:"provider"`
|
Provider string `json:"provider"`
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
AppVersion string `json:"app_version,omitempty"`
|
AppVersion string `json:"app_version,omitempty"`
|
||||||
Platform string `json:"platform,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 {
|
type imP2PConversationRequest struct {
|
||||||
@@ -3356,12 +3359,15 @@ func serveIMDevicePushToken(wrt http.ResponseWriter, req *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
token, err := store.DevicePushTokens.Upsert(principal.TenantID, &types.DevicePushToken{
|
token, err := store.DevicePushTokens.Upsert(principal.TenantID, &types.DevicePushToken{
|
||||||
UserID: principal.Uid,
|
UserID: principal.Uid,
|
||||||
DeviceID: deviceID,
|
DeviceID: deviceID,
|
||||||
Provider: body.Provider,
|
Provider: body.Provider,
|
||||||
Token: body.Token,
|
Token: body.Token,
|
||||||
AppVersion: body.AppVersion,
|
AppVersion: body.AppVersion,
|
||||||
Platform: body.Platform,
|
Platform: body.Platform,
|
||||||
|
SDKVersion: body.SDKVersion,
|
||||||
|
PushEnv: body.PushEnv,
|
||||||
|
NotificationPermission: body.NotificationPermission,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeIMRelationError(wrt, req, err)
|
writeIMRelationError(wrt, req, err)
|
||||||
@@ -9664,11 +9670,14 @@ func youthModeRestrictionItems(restrictions []string) []map[string]any {
|
|||||||
|
|
||||||
func devicePushTokenPayload(token *types.DevicePushToken) map[string]any {
|
func devicePushTokenPayload(token *types.DevicePushToken) map[string]any {
|
||||||
return map[string]any{
|
return map[string]any{
|
||||||
"device_id": token.DeviceID,
|
"device_id": token.DeviceID,
|
||||||
"provider": token.Provider,
|
"provider": token.Provider,
|
||||||
"app_version": token.AppVersion,
|
"app_version": token.AppVersion,
|
||||||
"platform": token.Platform,
|
"platform": token.Platform,
|
||||||
"updated_at": token.UpdatedAt.UTC().Format(time.RFC3339Nano),
|
"sdk_version": token.SDKVersion,
|
||||||
|
"push_env": token.PushEnv,
|
||||||
|
"notification_permission": token.NotificationPermission,
|
||||||
|
"updated_at": token.UpdatedAt.UTC().Format(time.RFC3339Nano),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,12 +79,15 @@ type YouthModeSettings struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DevicePushToken struct {
|
type DevicePushToken struct {
|
||||||
UserID Uid
|
UserID Uid
|
||||||
DeviceID string
|
DeviceID string
|
||||||
Provider string
|
Provider string
|
||||||
Token string
|
Token string
|
||||||
AppVersion string
|
AppVersion string
|
||||||
Platform string
|
Platform string
|
||||||
UpdatedAt time.Time
|
SDKVersion string
|
||||||
CreatedAt time.Time
|
PushEnv string
|
||||||
|
NotificationPermission string
|
||||||
|
UpdatedAt time.Time
|
||||||
|
CreatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user