|
@@ -30,6 +30,7 @@ public class BusinessPushService {
|
|
|
|
|
|
|
|
public void send(RecipientApp app, Long userId, String cid,
|
|
public void send(RecipientApp app, Long userId, String cid,
|
|
|
String title, String content, String payload) {
|
|
String title, String content, String payload) {
|
|
|
|
|
+ String platform = "unknown";
|
|
|
try {
|
|
try {
|
|
|
if (properties.getMode() == BusinessPushProperties.Mode.UNI) {
|
|
if (properties.getMode() == BusinessPushProperties.Mode.UNI) {
|
|
|
if (cid == null || cid.isBlank()) {
|
|
if (cid == null || cid.isBlank()) {
|
|
@@ -40,9 +41,16 @@ public class BusinessPushService {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
InfoUser current = userId == null ? null : users.getById(userId);
|
|
InfoUser current = userId == null ? null : users.getById(userId);
|
|
|
- String platform = platform(current);
|
|
|
|
|
- if (platform == null || current.getDeviceToken() == null || current.getDeviceToken().isBlank()) {
|
|
|
|
|
- log.warn("Native push address missing or platform invalid, app={}, userId={}", app, userId);
|
|
|
|
|
|
|
+ String resolvedPlatform = platform(current);
|
|
|
|
|
+ if (resolvedPlatform == null) {
|
|
|
|
|
+ log.warn("Native push skipped, app={}, userId={}, platform={}, category=PLATFORM_INVALID_OR_USER_MISSING",
|
|
|
|
|
+ app, userId, platform);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ platform = resolvedPlatform;
|
|
|
|
|
+ if (current.getDeviceToken() == null || current.getDeviceToken().isBlank()) {
|
|
|
|
|
+ log.warn("Native push skipped, app={}, userId={}, platform={}, category=TOKEN_MISSING",
|
|
|
|
|
+ app, userId, platform);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if ("android".equals(platform)) {
|
|
if ("android".equals(platform)) {
|
|
@@ -51,9 +59,18 @@ public class BusinessPushService {
|
|
|
apns.send(app, current.getDeviceToken(), title, content, payload);
|
|
apns.send(app, current.getDeviceToken(), title, content, payload);
|
|
|
}
|
|
}
|
|
|
} catch (RuntimeException exception) {
|
|
} catch (RuntimeException exception) {
|
|
|
- log.warn("Business push failed, app={}, userId={}, mode={}, category={}",
|
|
|
|
|
- app, userId, properties.getMode(), exception.getClass().getSimpleName());
|
|
|
|
|
|
|
+ log.warn("Business push failed, app={}, userId={}, mode={}, platform={}, category={}",
|
|
|
|
|
+ app, userId, properties.getMode(), platform, failureCategory(exception));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static String failureCategory(RuntimeException exception) {
|
|
|
|
|
+ String category = exception.getMessage();
|
|
|
|
|
+ if (exception instanceof IllegalStateException && category != null
|
|
|
|
|
+ && category.matches("(?:FCM|APNS)_[A-Za-z0-9_]{1,64}")) {
|
|
|
|
|
+ return category;
|
|
|
}
|
|
}
|
|
|
|
|
+ return exception.getClass().getSimpleName();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public String addressKey(InfoUser recipient) {
|
|
public String addressKey(InfoUser recipient) {
|