Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for versioned expire timers #321

Merged
merged 1 commit into from
Sep 15, 2024

Conversation

GranPC
Copy link

@GranPC GranPC commented Sep 15, 2024

Signal introduced a mechanism in which the disappearing message timer is versioned to avoid conflicts where two users attempt to change it simultaneously. This unit test from the diff explains it way better than I will be able to:

signalapp/Signal-Desktop@2fb50df#diff-bbee704f3a58f941935376ab98cc2f7f301445f1db90c89b5bd6ca3c449b46c8

This commit adds support for that and declares the capacity. This fixes device linking failing with 409 Conflict.

@gferon
Copy link
Collaborator

gferon commented Sep 15, 2024

This is awesome, thanks a lot for the fix! :D

@gferon gferon enabled auto-merge (squash) September 15, 2024 13:10
auto-merge was automatically disabled September 15, 2024 13:12

Head branch was pushed to by a user without write access

@GranPC GranPC force-pushed the jesus/versioned-expiration-timer branch from fb3bb5e to 086ced7 Compare September 15, 2024 13:12
@rubdos
Copy link
Member

rubdos commented Sep 15, 2024

Actually, should we not use the update-protos.sh script for this?

diff --git a/libsignal-service/protobuf/Groups.proto b/libsignal-service/protobuf/Groups.proto
index 3f0b7300b..63970c774 100644
--- a/libsignal-service/protobuf/Groups.proto
+++ b/libsignal-service/protobuf/Groups.proto
@@ -213,13 +213,24 @@ message GroupChange {
   uint32 changeEpoch     = 3;
 }
 
+message GroupResponse {
+  Group group                         = 1;
+  bytes groupSendEndorsementsResponse = 2;
+}
+
 message GroupChanges {
   message GroupChangeState {
     GroupChange groupChange = 1;
     Group       groupState  = 2;
   }
 
-  repeated GroupChangeState groupChanges = 1;
+  repeated GroupChangeState groupChanges                  = 1;
+           bytes            groupSendEndorsementsResponse = 2;
+}
+
+message GroupChangeResponse {
+  GroupChange groupChange                   = 1;
+  bytes       groupSendEndorsementsResponse = 2;
 }
 
 message GroupAttributeBlob {
diff --git a/libsignal-service/protobuf/SignalService.proto b/libsignal-service/protobuf/SignalService.proto
index 37506c78a..c16f9b24a 100644
--- a/libsignal-service/protobuf/SignalService.proto
+++ b/libsignal-service/protobuf/SignalService.proto
@@ -37,7 +37,8 @@ message Envelope {
   reserved      /*updatedPni*/           15; // Not used presently, may be used in the future
   optional bool   story                = 16;
   optional bytes  reportingToken       = 17;
-  // NEXT ID: 18
+  reserved                               18;  // internal server use
+  // NEXT ID: 19
 }
 
 message Content {
@@ -331,6 +332,7 @@ message DataMessage {
   optional GroupContextV2     groupV2                 = 15;
   optional uint32             flags                   = 4;
   optional uint32             expireTimer             = 5;
+  optional uint32             expireTimerVersion      = 23;
   optional bytes              profileKey              = 6;
   optional uint64             timestamp               = 7;
   optional Quote              quote                   = 8;
@@ -628,7 +630,7 @@ message SyncMessage {
   message CallLinkUpdate {
     enum Type {
       UPDATE = 0;
-      DELETE = 1;
+      reserved 1; // was DELETE, superseded by storage service
     }
 
     optional bytes rootKey      = 1;
@@ -792,17 +794,18 @@ message ContactDetails {
     optional uint32 length      = 2;
   }
 
-  optional string   number        = 1;
-  optional string   aci           = 9;
-  optional string   name          = 2;
-  optional Avatar   avatar        = 3;
-  optional string   color         = 4;
-  optional Verified verified      = 5;
-  optional bytes    profileKey    = 6;
-  reserved          /*blocked*/     7;
-  optional uint32   expireTimer   = 8;
-  optional uint32   inboxPosition = 10;
-  optional bool     archived      = 11;
+  optional string   number             = 1;
+  optional string   aci                = 9;
+  optional string   name               = 2;
+  optional Avatar   avatar             = 3;
+  optional string   color              = 4;
+  optional Verified verified           = 5;
+  optional bytes    profileKey         = 6;
+  reserved          /*blocked*/          7;
+  optional uint32   expireTimer        = 8;
+  optional uint32   expireTimerVersion = 12;
+  optional uint32   inboxPosition      = 10;
+  optional bool     archived           = 11;
 }
 
 message GroupDetails {
@@ -816,17 +819,17 @@ message GroupDetails {
     optional string e164  = 2;
   }
 
-  optional bytes  id            = 1;
-  optional string name          = 2;
-  repeated string membersE164   = 3;
-  repeated Member members       = 9;
-  optional Avatar avatar        = 4;
-  optional bool   active        = 5 [default = true];
-  optional uint32 expireTimer   = 6;
-  optional string color         = 7;
-  optional bool   blocked       = 8;
-  optional uint32 inboxPosition = 10;
-  optional bool   archived      = 11;
+  optional bytes  id                 = 1;
+  optional string name               = 2;
+  repeated string membersE164        = 3;
+  repeated Member members            = 9;
+  optional Avatar avatar             = 4;
+  optional bool   active             = 5 [default = true];
+  optional uint32 expireTimer        = 6;
+  optional string color              = 7;
+  optional bool   blocked            = 8;
+  optional uint32 inboxPosition      = 10;
+  optional bool   archived           = 11;
 }
 
 message PaymentAddress {
diff --git a/libsignal-service/protobuf/update-protos.sh b/libsignal-service/protobuf/update-protos.sh
index 9cecc710e..741525398 100755
--- a/libsignal-service/protobuf/update-protos.sh
+++ b/libsignal-service/protobuf/update-protos.sh
@@ -4,10 +4,10 @@ set -euo pipefail
 update_proto() {
 	case "$1" in
 	  Signal-Android)
-	  	git_revision="251cec5dee06d8d36f0177967d675e8eac2ba32f"
+	  	git_revision="6188502cb10e46f1741af9a8da737715b9fd6e22"
 		prefix="libsignal-service/src/main/protowire/";;
 	  Signal-Desktop)
-	  	git_revision="f46872b6e980132e8045b3288eb88d803f365a10"
+	  	git_revision="94cb1544e5b5e6c4803aea5295066add2b9cf17c"
 		prefix="protos/";;
 	esac
 	curl -LOf https://raw.githubusercontent.com/signalapp/${1}/${git_revision}/${prefix}${2}

That seems to work. There are a few other bumps in there too.

@rubdos rubdos merged commit ce26bd7 into whisperfish:main Sep 15, 2024
18 checks passed
@rubdos
Copy link
Member

rubdos commented Sep 15, 2024

I'll continue that in #322

@GranPC
Copy link
Author

GranPC commented Sep 15, 2024

Oh, thanks & sorry about that. I had no idea that script existed. To be honest I don't even use Signal nor write Rust. :)

@rubdos
Copy link
Member

rubdos commented Sep 15, 2024

Oh don't worry. We're happy a good fix is there, and that someone found it! :-)
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants