Merge tag 'Fix_Firebase&Notifiche' into develop
Finish Fix_Firebase&Notifiche
This commit is contained in:
@@ -32,6 +32,9 @@ public class FirebaseService {
|
||||
private final Logger logger = LogManager.getLogger();
|
||||
|
||||
private boolean initialize() throws Exception {
|
||||
boolean isDryRunCheckEnabled = !setupGest.getSetupBoolean("FIREBASE", "NOTIFICATION", "DISABLE_DRY_RUN_CHECK");
|
||||
dryRun = UtilityDebug.isDebugExecution() && isDryRunCheckEnabled;
|
||||
|
||||
if (!FirebaseApp.getApps().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
@@ -40,9 +43,6 @@ public class FirebaseService {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isDryRunCheckEnabled = !setupGest.getSetupBoolean("FIREBASE", "NOTIFICATION", "DISABLE_DRY_RUN_CHECK");
|
||||
dryRun = UtilityDebug.isDebugExecution() && isDryRunCheckEnabled;
|
||||
|
||||
InputStream refreshToken;
|
||||
try {
|
||||
URL url = new URL(this.getFirebaseEndpoint());
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.firebase.messaging.FirebaseMessagingException;
|
||||
import com.google.firebase.messaging.MessagingErrorCode;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.javabeans.RequestDataDTO;
|
||||
@@ -2751,12 +2753,12 @@ public class PvmService {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (UtilityDate.DaysAfter(dataScad, UtilityDate.getTodayWithoutTime())>0 && codDtip.equalsIgnoreCase("DDTEC")) {
|
||||
if (UtilityDate.DaysAfter(dataScad, UtilityDate.getTodayWithoutTime()) > 0 && codDtip.equalsIgnoreCase("DDTEC")) {
|
||||
anomalieResiDTO.add(setAnomalia(anomalieResiDTO, codMart, dataScad, "Impossibile effetture un reso di in articolo già scaduto."));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (UtilityDate.DaysAfter(dataScad, UtilityDate.getTodayWithoutTime())>15) {
|
||||
if (UtilityDate.DaysAfter(dataScad, UtilityDate.getTodayWithoutTime()) > 15) {
|
||||
anomalieResiDTO.add(setAnomalia(anomalieResiDTO, codMart, dataScad, "Impossibile effetture un reso dopo più di 15gg dalla scadenza."));
|
||||
continue;
|
||||
}
|
||||
@@ -3668,21 +3670,31 @@ public class PvmService {
|
||||
data.put("type", "modal");
|
||||
data.put("style", "warning");
|
||||
data.put("title", "Attenzione note modificate");
|
||||
data.put("body", "Sono state modificate le note dell'ordine di lavorazione n. " + numOrdLav + " del " + dataOrdLav + "<br><span class='text-info'>" + note + "</span>");
|
||||
data.put("body", "Sono state modificate le note dell'ordine di lavorazione n. " + numOrdLav + " del " + dataOrdLav + " " + note);
|
||||
data.put("bodyHTML", "Sono state modificate le note dell'ordine di lavorazione n. " + numOrdLav + " del " + dataOrdLav + "<br><span class='text-info'>" + note + "</span>");
|
||||
data.put("icon", "sticky-note");
|
||||
WebpushNotificationDTO webpushNotificationDTO = new WebpushNotificationDTO();
|
||||
webpushNotificationDTO.setRequireInteraction(true);
|
||||
WebpushConfigDTO webpushConfigDTO = new WebpushConfigDTO();
|
||||
webpushConfigDTO.setNotification(webpushNotificationDTO);
|
||||
|
||||
for (String codJfas : codJfasArray) {
|
||||
String topic = dbName + "_" + codJfas;
|
||||
List<String> topics = Stream.of(codJfasArray).map(codJfas -> dbName + "_" + codJfas).toList();
|
||||
|
||||
for (HashMap<String, Object> topicDeviceToken : notificationService.getTopicDeviceTokens(topics)) {
|
||||
String deviceToken = UtilityHashMap.getValueIfExists(topicDeviceToken, "device_token");
|
||||
|
||||
MessageDTO message = new MessageDTO();
|
||||
message.setTopic(topic);
|
||||
message.setToken(deviceToken);
|
||||
message.setData(data);
|
||||
message.setWebpush(webpushConfigDTO);
|
||||
firebaseService.sendMessage(message.toBuilder().build());
|
||||
|
||||
try {
|
||||
firebaseService.sendMessage(message.toBuilder().build());
|
||||
} catch (FirebaseMessagingException fireEx) {
|
||||
if (fireEx.getMessagingErrorCode() == MessagingErrorCode.UNREGISTERED) {
|
||||
// deviceTokenService.removeDeviceToken(deviceToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user