libsignal-service-java/libsignal-service-java.patch

212 lines
8.4 KiB
Diff
Raw Normal View History

From cf6beb24c0031b018f8f5dbbc3c1fee31e801f6f Mon Sep 17 00:00:00 2001
2022-06-16 20:08:44 +00:00
From: signald <nobody@signald.org>
Date: Tue, 20 Dec 2022 03:03:01 -0800
Subject: [PATCH] update build files and provide a way for the websocket to
receive callback to indicate the message was not saved
2021-10-27 01:01:41 +00:00
---
build.gradle | 15 ++-------------
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, 34 insertions(+), 34 deletions(-)
create mode 100644 service/src/main/java/org/whispersystems/signalservice/api/NotSavedException.java
2021-10-27 01:01:41 +00:00
diff --git a/build.gradle b/build.gradle
index 88570c52..f574c667 100644
2021-10-27 01:01:41 +00:00
--- a/build.gradle
+++ b/build.gradle
@@ -18,11 +18,8 @@ buildscript {
}
}
-plugins {
- id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
-}
2022-06-16 20:08:44 +00:00
-project.group = "com.github.turasa"
+project.group = "org.signald"
def getRepositoryUsername() {
return hasProperty('whisperSonatypeUsername') ? whisperSonatypeUsername : ""
@@ -32,18 +29,10 @@ def getRepositoryPassword() {
2021-10-27 02:46:14 +00:00
return hasProperty('whisperSonatypePassword') ? whisperSonatypePassword : ""
2021-10-27 01:01:41 +00:00
}
2021-10-27 02:46:14 +00:00
-nexusPublishing {
- repositories {
- sonatype {
- username = getRepositoryUsername()
- password = getRepositoryPassword()
- }
- }
-}
2022-06-16 20:08:44 +00:00
2021-10-27 02:46:14 +00:00
subprojects {
ext.lib_signal_service_version_number = "2.15.3_unofficial_65"
- ext.lib_signal_service_group_info = "com.github.turasa"
+ ext.lib_signal_service_group_info = "org.signald"
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
2021-10-27 01:01:41 +00:00
diff --git a/dependencies.gradle b/dependencies.gradle
index 18107b58..d6f67f8c 100644
2021-10-27 01:01:41 +00:00
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -13,8 +13,7 @@ dependencyResolutionManagement {
alias('google-jsr305').to('com.google.code.findbugs:jsr305:3.0.2')
2021-10-27 01:01:41 +00:00
// 1st Party
2022-04-06 18:45:49 +00:00
- 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')
2021-10-27 01:01:41 +00:00
// Third Party
alias('jackson-core').to('com.fasterxml.jackson.core:jackson-databind:2.14.1')
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index 3ae6989c..1e428740 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -840,6 +840,9 @@
<artifact name="protoc-3.21.7-linux-x86_64.exe">
<sha256 value="9b83158ee8c60bbf735bf7df3f225b3961c1711887ce77b90341055d7035665e" origin="Generated by Gradle"/>
2022-03-22 02:06:14 +00:00
</artifact>
+ <artifact name="protoc-3.21.7-osx-x86_64.exe">
+ <sha256 value="9a7b8ecffa82e7ce3de863c89da86427314508161fd0c586d68da999ddc0e1fc" origin="Generated by Gradle"/>
2022-03-22 02:06:14 +00:00
+ </artifact>
<artifact name="protoc-3.21.7.pom">
<sha256 value="385898c492ec183df04427b044947f2a6e1db6f000843aacd80af41aba157e20" origin="Generated by Gradle"/>
</artifact>
@@ -2111,12 +2114,12 @@
<sha256 value="e85ceb3d3a77bd11345548dcbb081a846684477152e63e8404092a7d4f7a8dee" origin="Generated by Gradle"/>
</artifact>
</component>
- <component group="org.signal" name="libsignal-client" version="0.21.1">
- <artifact name="libsignal-client-0.21.1.jar">
- <sha256 value="1d9add6391b019fb53f09a01d0ae05dc753a6edcf59b0183c64d9e2026b5c31b" origin="Generated by Gradle"/>
+ <component group="org.signald" name="libsignal-client-{TARGET}" version="0.21.1">
+ <artifact name="libsignal-client-{TARGET}-0.21.1.jar">
+ <sha256 value="{TARGET_JAR_SHA256}" origin="Generated by Gradle"/>
2022-06-16 20:08:44 +00:00
</artifact>
- <artifact name="libsignal-client-0.21.1.module">
- <sha256 value="1c46f905f3ab79404080486a0d454159cdc08de1ea1ba2608b41c94bf3a0e739" origin="Generated by Gradle"/>
+ <artifact name="libsignal-client-{TARGET}-0.21.1.module">
2022-03-22 01:59:33 +00:00
+ <sha256 value="{TARGET_MODULE_SHA256}" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.slf4j" name="slf4j-api" version="1.7.30">
2021-10-27 01:01:41 +00:00
diff --git a/service/build.gradle b/service/build.gradle
index ec21f92e..49556776 100644
2021-10-27 01:01:41 +00:00
--- a/service/build.gradle
+++ b/service/build.gradle
@@ -21,6 +21,7 @@ compileJava {
2021-11-08 23:47:39 +00:00
}
repositories {
2021-11-08 23:47:39 +00:00
+ maven {url "https://gitlab.com/api/v4/groups/6853927/-/packages/maven"} // https://gitlab.com/groups/signald/-/packages
mavenCentral()
mavenLocal()
2021-11-08 23:47:39 +00:00
}
2022-03-22 01:58:14 +00:00
@@ -98,7 +99,7 @@ def getRepositoryPassword() {
2021-10-27 01:01:41 +00:00
publishing {
publications {
2022-03-22 01:58:14 +00:00
mavenJava(MavenPublication) {
2021-10-27 01:01:41 +00:00
- artifactId = 'signal-service-java'
+ artifactId = 'signal-service-java-' + System.getenv("TARGET")
2021-11-09 00:53:59 +00:00
from components.java
pom {
2022-03-22 01:58:14 +00:00
@@ -139,16 +140,14 @@ publishing {
2021-11-08 23:47:39 +00:00
2021-10-27 01:01:41 +00:00
repositories {
maven {
- url = getReleaseRepositoryUrl()
2021-10-27 01:01:41 +00:00
- credentials {
- username getRepositoryUsername()
- password getRepositoryPassword()
2021-11-19 03:02:58 +00:00
+ url System.getenv("CI_API_V4_URL") + "/projects/" + System.getenv("CI_PROJECT_ID") + "/packages/maven"
2021-10-27 01:01:41 +00:00
+ credentials(HttpHeaderCredentials) {
+ name = 'Job-Token'
+ value = System.getenv("CI_JOB_TOKEN")
2022-03-22 01:58:14 +00:00
+ }
2021-10-27 01:01:41 +00:00
+ authentication {
+ header(HttpHeaderAuthentication)
2022-03-22 01:58:14 +00:00
}
2021-10-27 01:01:41 +00:00
}
}
2022-04-27 00:25:45 +00:00
}
2021-10-27 01:01:41 +00:00
-
-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 a113ac36..74867895 100644
--- a/service/src/main/java/org/whispersystems/signalservice/api/SignalWebSocket.java
+++ b/service/src/main/java/org/whispersystems/signalservice/api/SignalWebSocket.java
@@ -242,6 +242,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<String> timestampHeader = findHeader(request);
@@ -257,13 +258,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);
+ }
}
}
}
@@ -314,6 +321,6 @@ public final class SignalWebSocket {
* received.
*/
public interface MessageReceivedCallback {
- void onMessage(SignalServiceEnvelope envelope);
+ void onMessage(SignalServiceEnvelope envelope) throws NotSavedException;
}
}
2021-10-27 01:01:41 +00:00
diff --git a/settings.gradle b/settings.gradle
2022-06-16 20:08:44 +00:00
index 8861c008..8dd03423 100644
2021-10-27 01:01:41 +00:00
--- a/settings.gradle
+++ b/settings.gradle
2022-06-16 20:08:44 +00:00
@@ -1,6 +1,5 @@
2021-10-27 01:01:41 +00:00
enableFeaturePreview('VERSION_CATALOGS')
-include ':android'
2022-06-16 20:08:44 +00:00
2021-10-27 01:01:41 +00:00
include 'libsignal-service'
project(':libsignal-service').projectDir = file('service')
--
2.30.2
2021-10-27 01:01:41 +00:00