From 6f7529fc9bd9e19188cdd293767a786e9d1c5d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 17 Nov 2018 14:01:51 +0100 Subject: [PATCH] fixed duplicate-recieve --- .../simplecloudnotifier/model/ServerCommunication.java | 9 +++------ .../simplecloudnotifier/service/FBMService.java | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java index daaaef2..414a601 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java @@ -283,10 +283,7 @@ public class ServerCommunication SCNApp.refreshAccountTab(); - if (json_int(json, "unack_count")>0) - { - ServerCommunication.requery(id, key, loader); - } + if (json_int(json, "unack_count")>0) ServerCommunication.requery(id, key, loader); } catch (Exception e) { Log.e("SC:info", e.toString()); @@ -432,12 +429,12 @@ public class ServerCommunication } } - public static void ack(int id, String key, CMessage msg) + public static void ack(int id, String key, long msg_scn_id) { try { Request request = new Request.Builder() - .url(BASE_URL + "ack.php?user_id=" + id + "&user_key=" + key + "&scn_msg_id=" + msg.SCN_ID) + .url(BASE_URL + "ack.php?user_id=" + id + "&user_key=" + key + "&scn_msg_id=" + msg_scn_id) .build(); client.newCall(request).enqueue(new Callback() { diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/service/FBMService.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/service/FBMService.java index d3c612c..45c066d 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/service/FBMService.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/service/FBMService.java @@ -50,15 +50,15 @@ public class FBMService extends FirebaseMessagingService public static void recieveData(long time, String title, String content, PriorityEnum prio, long scn_id, boolean alwaysAck) { - CMessage msg = CMessageList.inst().add(scn_id, time, title, content, prio); - if (CMessageList.inst().isAck(scn_id)) { Log.w("FB::MessageReceived", "Recieved ack-ed message: " + scn_id); - if (alwaysAck) ServerCommunication.ack(SCNSettings.inst().user_id, SCNSettings.inst().user_key, msg); + if (alwaysAck) ServerCommunication.ack(SCNSettings.inst().user_id, SCNSettings.inst().user_key, scn_id); return; } + CMessage msg = CMessageList.inst().add(scn_id, time, title, content, prio); + if (SCNApp.isBackground()) { NotificationService.inst().showBackground(msg); @@ -68,6 +68,6 @@ public class FBMService extends FirebaseMessagingService NotificationService.inst().showForeground(msg); } - ServerCommunication.ack(SCNSettings.inst().user_id, SCNSettings.inst().user_key, msg); + ServerCommunication.ack(SCNSettings.inst().user_id, SCNSettings.inst().user_key, scn_id); } } \ No newline at end of file