From abfe60edbe91de9205893be79166d4aaf7ac1262 Mon Sep 17 00:00:00 2001 From: finn Date: Mon, 22 Aug 2022 15:04:33 -0700 Subject: [PATCH] modify websocket receive callback to allow indicating the message was not saved and should be re-delivered --- .gitlab-ci.yml | 2 +- libsignal-service-java.patch | 77 +++++++++++++++++++++++++++++++----- 2 files changed, 68 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e80526d..77becbb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ stages: - build variables: - version: "v2.15.3_unofficial_50" + version: "v2.15.3_unofficial_50_signald_1" GRADLE_OPTS: -Dorg.gradle.daemon=false build: diff --git a/libsignal-service-java.patch b/libsignal-service-java.patch index fdbc2fe..65bb6fc 100644 --- a/libsignal-service-java.patch +++ b/libsignal-service-java.patch @@ -1,18 +1,22 @@ -From dfcc82ab4b4f4d3c18e210ba724ce761deaa6e91 Mon Sep 17 00:00:00 2001 +From ae19ed8b15251adae911868ffe570e5608bc2eef Mon Sep 17 00:00:00 2001 From: signald Date: Thu, 16 Jun 2022 13:04:00 -0700 -Subject: [PATCH] update build files +Subject: [PATCH] update build files and provide a way for the websocket + receive callback to indicate the message was not saved --- - build.gradle | 15 ++------------- - dependencies.gradle | 3 +-- - gradle/verification-metadata.xml | 13 ++++++++----- - service/build.gradle | 19 +++++++++---------- - settings.gradle | 1 - - 5 files changed, 20 insertions(+), 31 deletions(-) + build.gradle | 17 +++-------------- + dependencies.gradle | 3 +-- + gradle/verification-metadata.xml | 13 ++++++++----- + service/build.gradle | 19 +++++++++---------- + .../signalservice/api/NotSavedException.java | 4 ++++ + .../signalservice/api/SignalWebSocket.java | 13 ++++++++++--- + settings.gradle | 1 - + 7 files changed, 35 insertions(+), 35 deletions(-) + create mode 100644 service/src/main/java/org/whispersystems/signalservice/api/NotSavedException.java diff --git a/build.gradle b/build.gradle -index 2498bfcb..9a69ac82 100644 +index 2498bfcb..965084e6 100644 --- a/build.gradle +++ b/build.gradle @@ -9,11 +9,8 @@ buildscript { @@ -42,8 +46,9 @@ index 2498bfcb..9a69ac82 100644 -} subprojects { - ext.lib_signal_service_version_number = "2.15.3_unofficial_50" +- ext.lib_signal_service_version_number = "2.15.3_unofficial_50" - ext.lib_signal_service_group_info = "com.github.turasa" ++ ext.lib_signal_service_version_number = "2.15.3_unofficial_50_signald_1" + ext.lib_signal_service_group_info = "org.signald" if (JavaVersion.current().isJava8Compatible()) { @@ -139,6 +144,58 @@ index ae4df43a..4b0240d8 100644 - required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } - sign publishing.publications.mavenJava -} +diff --git a/service/src/main/java/org/whispersystems/signalservice/api/NotSavedException.java b/service/src/main/java/org/whispersystems/signalservice/api/NotSavedException.java +new file mode 100644 +index 00000000..05d77d1f +--- /dev/null ++++ b/service/src/main/java/org/whispersystems/signalservice/api/NotSavedException.java +@@ -0,0 +1,4 @@ ++package org.whispersystems.signalservice.api; ++ ++public class NotSavedException extends Exception { ++} +diff --git a/service/src/main/java/org/whispersystems/signalservice/api/SignalWebSocket.java b/service/src/main/java/org/whispersystems/signalservice/api/SignalWebSocket.java +index 5a98f3c4..dff24940 100644 +--- a/service/src/main/java/org/whispersystems/signalservice/api/SignalWebSocket.java ++++ b/service/src/main/java/org/whispersystems/signalservice/api/SignalWebSocket.java +@@ -243,6 +243,7 @@ public final class SignalWebSocket { + while (true) { + WebSocketRequestMessage request = getWebSocket().readRequest(timeout); + WebSocketResponseMessage response = createWebSocketResponse(request); ++ boolean sendResponse = true; // indicates the acknowledgement should be sent to the server + try { + if (isSignalServiceEnvelope(request)) { + Optional timestampHeader = findHeader(request); +@@ -258,13 +259,19 @@ public final class SignalWebSocket { + + SignalServiceEnvelope envelope = new SignalServiceEnvelope(request.getBody().toByteArray(), timestamp); + +- callback.onMessage(envelope); ++ try { ++ callback.onMessage(envelope); ++ } catch (NotSavedException e) { ++ sendResponse = false; ++ } + return Optional.of(envelope); + } else if (isSocketEmptyRequest(request)) { + return Optional.empty(); + } + } finally { +- getWebSocket().sendResponse(response); ++ if(sendResponse) { ++ getWebSocket().sendResponse(response); ++ } + } + } + } +@@ -315,6 +322,6 @@ public final class SignalWebSocket { + * received. + */ + public interface MessageReceivedCallback { +- void onMessage(SignalServiceEnvelope envelope); ++ void onMessage(SignalServiceEnvelope envelope) throws NotSavedException; + } + } diff --git a/settings.gradle b/settings.gradle index 8861c008..8dd03423 100644 --- a/settings.gradle