is necessary so the correct sync messages are generated
for linked accounts
import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.DBusSignal;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.DBusSignal;
import org.freedesktop.dbus.exceptions.DBusException;
+import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
import org.whispersystems.signalservice.api.push.exceptions.EncapsulatedExceptions;
import java.io.IOException;
import java.util.List;
public interface Signal extends DBusInterface {
import org.whispersystems.signalservice.api.push.exceptions.EncapsulatedExceptions;
import java.io.IOException;
import java.util.List;
public interface Signal extends DBusInterface {
- void sendMessage(String message, List<String> attachments, String recipient) throws EncapsulatedExceptions, AttachmentInvalidException, IOException;
+ void sendMessage(String message, List<String> attachments, String recipient) throws EncapsulatedExceptions, AttachmentInvalidException, IOException, UntrustedIdentityException;
- void sendMessage(String message, List<String> attachments, List<String> recipients) throws EncapsulatedExceptions, AttachmentInvalidException, IOException;
+ void sendMessage(String message, List<String> attachments, List<String> recipients) throws EncapsulatedExceptions, AttachmentInvalidException, IOException, UntrustedIdentityException;
- void sendEndSessionMessage(List<String> recipients) throws IOException, EncapsulatedExceptions;
+ void sendEndSessionMessage(List<String> recipients) throws IOException, EncapsulatedExceptions, UntrustedIdentityException;
- void sendGroupMessage(String message, List<String> attachments, byte[] groupId) throws EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException, IOException;
+ void sendGroupMessage(String message, List<String> attachments, byte[] groupId) throws EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException, IOException, UntrustedIdentityException;
class MessageReceived extends DBusSignal {
private long timestamp;
class MessageReceived extends DBusSignal {
private long timestamp;
handleAssertionError(e);
} catch (DBusExecutionException e) {
handleDBusExecutionException(e);
handleAssertionError(e);
} catch (DBusExecutionException e) {
handleDBusExecutionException(e);
+ } catch (UntrustedIdentityException e) {
+ e.printStackTrace();
}
} else {
String messageText = ns.getString("message");
}
} else {
String messageText = ns.getString("message");
System.exit(1);
} catch (DBusExecutionException e) {
handleDBusExecutionException(e);
System.exit(1);
} catch (DBusExecutionException e) {
handleDBusExecutionException(e);
+ } catch (UntrustedIdentityException e) {
+ e.printStackTrace();
handleAssertionError(e);
} catch (GroupNotFoundException e) {
handleGroupNotFoundException(e);
handleAssertionError(e);
} catch (GroupNotFoundException e) {
handleGroupNotFoundException(e);
+ } catch (UntrustedIdentityException e) {
+ e.printStackTrace();
handleGroupNotFoundException(e);
} catch (EncapsulatedExceptions e) {
handleEncapsulatedExceptions(e);
handleGroupNotFoundException(e);
} catch (EncapsulatedExceptions e) {
handleEncapsulatedExceptions(e);
+ } catch (UntrustedIdentityException e) {
+ e.printStackTrace();
@Override
public void sendGroupMessage(String messageText, List<String> attachments,
byte[] groupId)
@Override
public void sendGroupMessage(String messageText, List<String> attachments,
byte[] groupId)
- throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException {
+ throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException, UntrustedIdentityException {
final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder().withBody(messageText);
if (attachments != null) {
messageBuilder.withAttachments(getSignalServiceAttachments(attachments));
final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder().withBody(messageText);
if (attachments != null) {
messageBuilder.withAttachments(getSignalServiceAttachments(attachments));
sendMessage(message, groupStore.getGroup(groupId).members);
}
sendMessage(message, groupStore.getGroup(groupId).members);
}
- public void sendQuitGroupMessage(byte[] groupId) throws GroupNotFoundException, IOException, EncapsulatedExceptions {
+ public void sendQuitGroupMessage(byte[] groupId) throws GroupNotFoundException, IOException, EncapsulatedExceptions, UntrustedIdentityException {
SignalServiceGroup group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.QUIT)
.withId(groupId)
.build();
SignalServiceGroup group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.QUIT)
.withId(groupId)
.build();
sendMessage(message, groupStore.getGroup(groupId).members);
}
sendMessage(message, groupStore.getGroup(groupId).members);
}
- public byte[] sendUpdateGroupMessage(byte[] groupId, String name, Collection<String> members, String avatarFile) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException {
+ public byte[] sendUpdateGroupMessage(byte[] groupId, String name, Collection<String> members, String avatarFile) throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException, UntrustedIdentityException {
GroupInfo g;
if (groupId == null) {
// Create new group
GroupInfo g;
if (groupId == null) {
// Create new group
@Override
public void sendMessage(String message, List<String> attachments, String recipient)
@Override
public void sendMessage(String message, List<String> attachments, String recipient)
- throws EncapsulatedExceptions, AttachmentInvalidException, IOException {
+ throws EncapsulatedExceptions, AttachmentInvalidException, IOException, UntrustedIdentityException {
List<String> recipients = new ArrayList<>(1);
recipients.add(recipient);
sendMessage(message, attachments, recipients);
List<String> recipients = new ArrayList<>(1);
recipients.add(recipient);
sendMessage(message, attachments, recipients);
@Override
public void sendMessage(String messageText, List<String> attachments,
List<String> recipients)
@Override
public void sendMessage(String messageText, List<String> attachments,
List<String> recipients)
- throws IOException, EncapsulatedExceptions, AttachmentInvalidException {
+ throws IOException, EncapsulatedExceptions, AttachmentInvalidException, UntrustedIdentityException {
final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder().withBody(messageText);
if (attachments != null) {
messageBuilder.withAttachments(getSignalServiceAttachments(attachments));
final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder().withBody(messageText);
if (attachments != null) {
messageBuilder.withAttachments(getSignalServiceAttachments(attachments));
- public void sendEndSessionMessage(List<String> recipients) throws IOException, EncapsulatedExceptions {
+ public void sendEndSessionMessage(List<String> recipients) throws IOException, EncapsulatedExceptions, UntrustedIdentityException {
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
.asEndSessionMessage()
.build();
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
.asEndSessionMessage()
.build();
}
private void sendMessage(SignalServiceDataMessage message, Collection<String> recipients)
}
private void sendMessage(SignalServiceDataMessage message, Collection<String> recipients)
- throws IOException, EncapsulatedExceptions {
+ throws IOException, EncapsulatedExceptions, UntrustedIdentityException {
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(URL, TRUST_STORE, username, password,
signalProtocolStore, USER_AGENT, Optional.<SignalServiceMessageSender.EventListener>absent());
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(URL, TRUST_STORE, username, password,
signalProtocolStore, USER_AGENT, Optional.<SignalServiceMessageSender.EventListener>absent());
- messageSender.sendMessage(new ArrayList<>(recipientsTS), message);
+ if (message.getGroupInfo().isPresent()) {
+ messageSender.sendMessage(new ArrayList<>(recipientsTS), message);
+ } else {
+ // Send to all individually, so sync messages are sent correctly
+ for (SignalServiceAddress address : recipientsTS) {
+ messageSender.sendMessage(address, message);
+ }
+ }
if (message.isEndSession()) {
for (SignalServiceAddress recipient : recipientsTS) {
if (message.isEndSession()) {
for (SignalServiceAddress recipient : recipientsTS) {