feat: add jpush push handler
This commit is contained in:
@@ -5853,15 +5853,36 @@ func (a *adapter) TenantDevicePushTokenUpsert(id t.TenantID, token *t.DevicePush
|
||||
}
|
||||
|
||||
func (a *adapter) TenantDevicePushTokenGetAll(id t.TenantID, uids ...t.Uid) (map[t.Uid][]t.DeviceDef, int, error) {
|
||||
return a.tenantDevicePushTokenGetAllByProviders(id, []string{"fcm", "firebase"}, uids...)
|
||||
}
|
||||
|
||||
func (a *adapter) TenantDevicePushTokenGetAllByProvider(id t.TenantID, provider string, uids ...t.Uid) (map[t.Uid][]t.DeviceDef, int, error) {
|
||||
provider = strings.ToLower(strings.TrimSpace(provider))
|
||||
if provider == "" {
|
||||
return map[t.Uid][]t.DeviceDef{}, 0, nil
|
||||
}
|
||||
return a.tenantDevicePushTokenGetAllByProviders(id, []string{provider}, uids...)
|
||||
}
|
||||
|
||||
func (a *adapter) tenantDevicePushTokenGetAllByProviders(id t.TenantID, providers []string, uids ...t.Uid) (map[t.Uid][]t.DeviceDef, int, error) {
|
||||
if !a.tenantScopedDB {
|
||||
tenantAdp, err := a.routedTenantAdapter(id)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if tenantAdp != a {
|
||||
return tenantAdp.TenantDevicePushTokenGetAll(id, uids...)
|
||||
return tenantAdp.tenantDevicePushTokenGetAllByProviders(id, providers, uids...)
|
||||
}
|
||||
}
|
||||
normalizedProviders := make([]any, 0, len(providers))
|
||||
for _, provider := range providers {
|
||||
if provider = strings.ToLower(strings.TrimSpace(provider)); provider != "" {
|
||||
normalizedProviders = append(normalizedProviders, provider)
|
||||
}
|
||||
}
|
||||
if len(normalizedProviders) == 0 {
|
||||
return map[t.Uid][]t.DeviceDef{}, 0, nil
|
||||
}
|
||||
decoded := make([]any, 0, len(uids))
|
||||
for _, uid := range uids {
|
||||
if !uid.IsZero() {
|
||||
@@ -5872,7 +5893,7 @@ func (a *adapter) TenantDevicePushTokenGetAll(id t.TenantID, uids ...t.Uid) (map
|
||||
return map[t.Uid][]t.DeviceDef{}, 0, nil
|
||||
}
|
||||
query, args, err := sqlx.In(`SELECT user_id,token,platform,updated_at FROM im_device_push_tokens
|
||||
WHERE provider IN ('fcm','firebase') AND user_id IN (?)`, decoded)
|
||||
WHERE provider IN (?) AND user_id IN (?)`, normalizedProviders, decoded)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user