private SignalServiceMessageSender getMessageSender() {
// TODO implement ZkGroup support
final ClientZkProfileOperations clientZkProfileOperations = null;
- final boolean attachmentsV3 = false;
final ExecutorService executor = null;
return new SignalServiceMessageSender(serviceConfiguration, account.getUuid(), account.getUsername(), account.getPassword(),
- account.getDeviceId(), account.getSignalProtocolStore(), userAgent, account.isMultiDevice(), attachmentsV3, Optional.fromNullable(messagePipe), Optional.fromNullable(unidentifiedMessagePipe), Optional.absent(), clientZkProfileOperations, executor);
+ account.getDeviceId(), account.getSignalProtocolStore(), userAgent, account.isMultiDevice(), Optional.fromNullable(messagePipe), Optional.fromNullable(unidentifiedMessagePipe), Optional.absent(), clientZkProfileOperations, executor, ServiceConfig.MAX_ENVELOPE_SIZE);
}
private SignalServiceProfile getEncryptedRecipientProfile(SignalServiceAddress address, Optional<UnidentifiedAccess> unidentifiedAccess) throws IOException {
SignalServiceSyncMessage syncMessage = SignalServiceSyncMessage.forSentTranscript(transcript);
try {
+ long startTime = System.currentTimeMillis();
messageSender.sendMessage(syncMessage, unidentifiedAccess);
- return SendMessageResult.success(recipient, unidentifiedAccess.isPresent(), false);
+ return SendMessageResult.success(recipient, unidentifiedAccess.isPresent(), false, System.currentTimeMillis() - startTime);
} catch (UntrustedIdentityException e) {
account.getSignalProtocolStore().saveIdentity(resolveSignalServiceAddress(e.getIdentifier()), e.getIdentityKey(), TrustLevel.UNTRUSTED);
return SendMessageResult.identityFailure(recipient, e.getIdentityKey());
if (!envelope.isReceipt()) {
try {
content = decryptMessage(envelope);
- } catch (Exception e) {
+ } catch (org.whispersystems.libsignal.UntrustedIdentityException e) {
+ return;
+ } catch (Exception er) {
+ // All other errors are not recoverable, so delete the cached message
+ try {
+ Files.delete(fileEntry.toPath());
+ } catch (IOException e) {
+ System.err.println("Failed to delete cached message file “" + fileEntry + "”: " + e.getMessage());
+ }
return;
}
List<HandleAction> actions = handleMessage(envelope, content, ignoreAttachments);
System.err.println("Ignoring error: " + e.getMessage());
continue;
}
+
if (envelope.hasSource()) {
// Store uuid if we don't have it already
SignalServiceAddress source = envelope.getSourceAddress();
if (!(exception instanceof org.whispersystems.libsignal.UntrustedIdentityException)) {
File cacheFile = null;
try {
- cacheFile = getMessageCacheFile(envelope.getSourceE164().get(), now, envelope.getTimestamp());
+ String source = envelope.getSourceE164().isPresent() ? envelope.getSourceE164().get() : "";
+ cacheFile = getMessageCacheFile(source, now, envelope.getTimestamp());
Files.delete(cacheFile.toPath());
// Try to delete directory if empty
new File(getMessageCachePath()).delete();