kopia lustrzana https://github.com/ryukoposting/Signal-Android
Send an empty group sync when linking devices if no groups exist.
rodzic
35c102aa98
commit
20b98122c1
|
@ -244,8 +244,8 @@ public class MultiDeviceContactUpdateJob extends BaseJob {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onShouldRetry(@NonNull Exception exception) {
|
public boolean onShouldRetry(@NonNull Exception exception) {
|
||||||
if (exception instanceof PushNetworkException) return true;
|
return exception instanceof PushNetworkException ||
|
||||||
return false;
|
exception instanceof NetworkException;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSy
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -128,7 +129,11 @@ public class MultiDeviceGroupUpdateJob extends BaseJob {
|
||||||
BlobProvider.getInstance().getStream(context, uri),
|
BlobProvider.getInstance().getStream(context, uri),
|
||||||
length);
|
length);
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "No groups present for sync message...");
|
Log.w(TAG, "No groups present for sync message. Sending an empty update.");
|
||||||
|
|
||||||
|
sendUpdate(ApplicationDependencies.getSignalServiceMessageSender(),
|
||||||
|
null,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
BlobProvider.getInstance().delete(context, uri);
|
BlobProvider.getInstance().delete(context, uri);
|
||||||
|
@ -149,11 +154,17 @@ public class MultiDeviceGroupUpdateJob extends BaseJob {
|
||||||
private void sendUpdate(SignalServiceMessageSender messageSender, InputStream stream, long length)
|
private void sendUpdate(SignalServiceMessageSender messageSender, InputStream stream, long length)
|
||||||
throws IOException, UntrustedIdentityException
|
throws IOException, UntrustedIdentityException
|
||||||
{
|
{
|
||||||
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
|
SignalServiceAttachmentStream attachmentStream;
|
||||||
.withStream(stream)
|
|
||||||
.withContentType("application/octet-stream")
|
if (length > 0) {
|
||||||
.withLength(length)
|
attachmentStream = SignalServiceAttachment.newStreamBuilder()
|
||||||
.build();
|
.withStream(stream)
|
||||||
|
.withContentType("application/octet-stream")
|
||||||
|
.withLength(length)
|
||||||
|
.build();
|
||||||
|
} else {
|
||||||
|
attachmentStream = SignalServiceAttachment.emptyStream("application/octet-stream");
|
||||||
|
}
|
||||||
|
|
||||||
messageSender.sendMessage(SignalServiceSyncMessage.forGroups(attachmentStream),
|
messageSender.sendMessage(SignalServiceSyncMessage.forGroups(attachmentStream),
|
||||||
UnidentifiedAccessUtil.getAccessForSync(context));
|
UnidentifiedAccessUtil.getAccessForSync(context));
|
||||||
|
|
|
@ -869,6 +869,7 @@ public class SignalServiceMessageSender {
|
||||||
private byte[] createMultiDeviceGroupsContent(SignalServiceAttachmentStream groups) throws IOException {
|
private byte[] createMultiDeviceGroupsContent(SignalServiceAttachmentStream groups) throws IOException {
|
||||||
Content.Builder container = Content.newBuilder();
|
Content.Builder container = Content.newBuilder();
|
||||||
SyncMessage.Builder builder = createSyncMessageBuilder();
|
SyncMessage.Builder builder = createSyncMessageBuilder();
|
||||||
|
|
||||||
builder.setGroups(SyncMessage.Groups.newBuilder()
|
builder.setGroups(SyncMessage.Groups.newBuilder()
|
||||||
.setBlob(createAttachmentPointer(groups)));
|
.setBlob(createAttachmentPointer(groups)));
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
import org.whispersystems.signalservice.internal.push.http.CancelationSignal;
|
import org.whispersystems.signalservice.internal.push.http.CancelationSignal;
|
||||||
import org.whispersystems.signalservice.internal.push.http.ResumableUploadSpec;
|
import org.whispersystems.signalservice.internal.push.http.ResumableUploadSpec;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
public abstract class SignalServiceAttachment {
|
public abstract class SignalServiceAttachment {
|
||||||
|
@ -39,6 +40,10 @@ public abstract class SignalServiceAttachment {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SignalServiceAttachmentStream emptyStream(String contentType) {
|
||||||
|
return new SignalServiceAttachmentStream(new ByteArrayInputStream(new byte[0]), contentType, 0, Optional.absent(), false, false, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
private InputStream inputStream;
|
private InputStream inputStream;
|
||||||
|
|
Ładowanie…
Reference in New Issue