fix: normalize jpush aliases
This commit is contained in:
@@ -360,7 +360,7 @@ func preparePayloads(rcpt *push.Receipt, config *configType) ([]*jpushPayload, [
|
||||
}
|
||||
var audience map[string][]string
|
||||
if useAlias {
|
||||
audience = map[string][]string{"alias": {uid.UserId()}}
|
||||
audience = map[string][]string{"alias": {aliasForUid(uid)}}
|
||||
} else {
|
||||
var registrationIDs []string
|
||||
for _, device := range devices[uid] {
|
||||
@@ -584,6 +584,12 @@ func containsString(values []string, target string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func aliasForUid(uid t.Uid) string {
|
||||
// JPush alias does not accept '-' or '_'. Tinode user IDs are base64url-like,
|
||||
// so map them to legal characters which never appear in the original alphabet.
|
||||
return strings.NewReplacer("-", ".", "_", "|").Replace(uid.UserId())
|
||||
}
|
||||
|
||||
func providerDevicesForUsers(tenantID t.TenantID, provider string, uids ...t.Uid) (map[t.Uid][]t.DeviceDef, int, error) {
|
||||
if tokens, ok := store.DevicePushTokens.(store.DevicePushTokenProviderQueryInterface); ok {
|
||||
return tokens.GetAllByProvider(tenantID, provider, uids...)
|
||||
|
||||
Reference in New Issue
Block a user