From c51057ae26118490176af0b2421f8fa62d926c00 Mon Sep 17 00:00:00 2001 From: signald Date: Thu, 16 Jun 2022 13:04:00 -0700 Subject: [PATCH] update build files and provide a way for the websocket receive callback to indicate the message was not saved --- 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..81f7038d 100644 --- a/build.gradle +++ b/build.gradle @@ -9,11 +9,8 @@ buildscript { } } -plugins { - id("io.github.gradle-nexus.publish-plugin") version "1.1.0" -} -project.group = "com.github.turasa" +project.group = "org.signald" def getRepositoryUsername() { return hasProperty('whisperSonatypeUsername') ? whisperSonatypeUsername : "" @@ -23,18 +20,10 @@ def getRepositoryPassword() { return hasProperty('whisperSonatypePassword') ? whisperSonatypePassword : "" } -nexusPublishing { - repositories { - sonatype { - username = getRepositoryUsername() - password = getRepositoryPassword() - } - } -} subprojects { - 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_2" + ext.lib_signal_service_group_info = "org.signald" if (JavaVersion.current().isJava8Compatible()) { allprojects { diff --git a/dependencies.gradle b/dependencies.gradle index e4b9f8a8..20e0d2f2 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -8,8 +8,7 @@ dependencyResolutionManagement { alias('google-libphonenumber').to('com.googlecode.libphonenumber:libphonenumber:8.12.48') // 1st Party - alias('libsignal-client').to('org.signal', 'libsignal-client').versionRef('libsignal-client') - alias('libsignal-android').to('org.signal', 'libsignal-android').versionRef('libsignal-client') + alias('libsignal-client').to('org.signald', 'libsignal-client-' + System.getenv("TARGET")).versionRef('libsignal-client') // Third Party alias('jackson-core').to('com.fasterxml.jackson.core:jackson-databind:2.13.0') diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index fc39d024..59fde59c 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -482,6 +482,9 @@ + + + @@ -1133,12 +1136,12 @@ - - - + + + - - + + diff --git a/service/build.gradle b/service/build.gradle index ae4df43a..4b0240d8 100644 --- a/service/build.gradle +++ b/service/build.gradle @@ -21,6 +21,7 @@ compileJava { } repositories { + maven {url "https://gitlab.com/api/v4/groups/6853927/-/packages/maven"} // https://gitlab.com/groups/signald/-/packages mavenCentral() mavenLocal() } @@ -98,7 +99,7 @@ def getRepositoryPassword() { publishing { publications { mavenJava(MavenPublication) { - artifactId = 'signal-service-java' + artifactId = 'signal-service-java-' + System.getenv("TARGET") from components.java pom { @@ -139,16 +140,14 @@ publishing { repositories { maven { - url = getReleaseRepositoryUrl() - credentials { - username getRepositoryUsername() - password getRepositoryPassword() + url System.getenv("CI_API_V4_URL") + "/projects/" + System.getenv("CI_PROJECT_ID") + "/packages/maven" + credentials(HttpHeaderCredentials) { + name = 'Job-Token' + value = System.getenv("CI_JOB_TOKEN") + } + authentication { + header(HttpHeaderAuthentication) } } } } - -signing { - 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 +++ b/settings.gradle @@ -1,6 +1,5 @@ enableFeaturePreview('VERSION_CATALOGS') -include ':android' include 'libsignal-service' project(':libsignal-service').projectDir = file('service') -- 2.30.2