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
|
||||
public boolean onShouldRetry(@NonNull Exception exception) {
|
||||
if (exception instanceof PushNetworkException) return true;
|
||||
return false;
|
||||
return exception instanceof PushNetworkException ||
|
||||
exception instanceof NetworkException;
|
||||
}
|
||||
|
||||
@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.exceptions.PushNetworkException;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -128,7 +129,11 @@ public class MultiDeviceGroupUpdateJob extends BaseJob {
|
|||
BlobProvider.getInstance().getStream(context, uri),
|
||||
length);
|
||||
} 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 {
|
||||
BlobProvider.getInstance().delete(context, uri);
|
||||
|
@ -149,11 +154,17 @@ public class MultiDeviceGroupUpdateJob extends BaseJob {
|
|||
private void sendUpdate(SignalServiceMessageSender messageSender, InputStream stream, long length)
|
||||
throws IOException, UntrustedIdentityException
|
||||
{
|
||||
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
|
||||
.withStream(stream)
|
||||
.withContentType("application/octet-stream")
|
||||
.withLength(length)
|
||||
.build();
|
||||
SignalServiceAttachmentStream attachmentStream;
|
||||
|
||||
if (length > 0) {
|
||||
attachmentStream = SignalServiceAttachment.newStreamBuilder()
|
||||
.withStream(stream)
|
||||
.withContentType("application/octet-stream")
|
||||
.withLength(length)
|
||||
.build();
|
||||
} else {
|
||||
attachmentStream = SignalServiceAttachment.emptyStream("application/octet-stream");
|
||||
}
|
||||
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forGroups(attachmentStream),
|
||||
UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
|
|
|
@ -869,6 +869,7 @@ public class SignalServiceMessageSender {
|
|||
private byte[] createMultiDeviceGroupsContent(SignalServiceAttachmentStream groups) throws IOException {
|
||||
Content.Builder container = Content.newBuilder();
|
||||
SyncMessage.Builder builder = createSyncMessageBuilder();
|
||||
|
||||
builder.setGroups(SyncMessage.Groups.newBuilder()
|
||||
.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.ResumableUploadSpec;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public abstract class SignalServiceAttachment {
|
||||
|
@ -39,6 +40,10 @@ public abstract class SignalServiceAttachment {
|
|||
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 {
|
||||
|
||||
private InputStream inputStream;
|
||||
|
|
Ładowanie…
Reference in New Issue