mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Always save when sending messages
This commit is contained in:
parent
5c1127ced6
commit
800b92c4ba
1 changed files with 26 additions and 23 deletions
|
@ -548,36 +548,39 @@ class Manager implements Signal {
|
||||||
|
|
||||||
private void sendMessage(SignalServiceDataMessage message, Collection<String> recipients)
|
private void sendMessage(SignalServiceDataMessage message, Collection<String> recipients)
|
||||||
throws IOException, EncapsulatedExceptions, UntrustedIdentityException {
|
throws IOException, EncapsulatedExceptions, UntrustedIdentityException {
|
||||||
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(URL, TRUST_STORE, username, password,
|
try {
|
||||||
deviceId, signalProtocolStore, USER_AGENT, Optional.<SignalServiceMessageSender.EventListener>absent());
|
SignalServiceMessageSender messageSender = new SignalServiceMessageSender(URL, TRUST_STORE, username, password,
|
||||||
|
deviceId, signalProtocolStore, USER_AGENT, Optional.<SignalServiceMessageSender.EventListener>absent());
|
||||||
|
|
||||||
Set<SignalServiceAddress> recipientsTS = new HashSet<>(recipients.size());
|
Set<SignalServiceAddress> recipientsTS = new HashSet<>(recipients.size());
|
||||||
for (String recipient : recipients) {
|
for (String recipient : recipients) {
|
||||||
try {
|
try {
|
||||||
recipientsTS.add(getPushAddress(recipient));
|
recipientsTS.add(getPushAddress(recipient));
|
||||||
} catch (InvalidNumberException e) {
|
} catch (InvalidNumberException e) {
|
||||||
System.err.println("Failed to add recipient \"" + recipient + "\": " + e.getMessage());
|
System.err.println("Failed to add recipient \"" + recipient + "\": " + e.getMessage());
|
||||||
System.err.println("Aborting sending.");
|
System.err.println("Aborting sending.");
|
||||||
save();
|
save();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (message.getGroupInfo().isPresent()) {
|
if (message.getGroupInfo().isPresent()) {
|
||||||
messageSender.sendMessage(new ArrayList<>(recipientsTS), message);
|
messageSender.sendMessage(new ArrayList<>(recipientsTS), message);
|
||||||
} else {
|
} else {
|
||||||
// Send to all individually, so sync messages are sent correctly
|
// Send to all individually, so sync messages are sent correctly
|
||||||
for (SignalServiceAddress address : recipientsTS) {
|
for (SignalServiceAddress address : recipientsTS) {
|
||||||
messageSender.sendMessage(address, message);
|
messageSender.sendMessage(address, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (message.isEndSession()) {
|
if (message.isEndSession()) {
|
||||||
for (SignalServiceAddress recipient : recipientsTS) {
|
for (SignalServiceAddress recipient : recipientsTS) {
|
||||||
handleEndSession(recipient.getNumber());
|
handleEndSession(recipient.getNumber());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
save();
|
||||||
}
|
}
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SignalServiceContent decryptMessage(SignalServiceEnvelope envelope) {
|
private SignalServiceContent decryptMessage(SignalServiceEnvelope envelope) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue