public interface Signal extends DBusInterface {
- void sendMessage(String message, List<String> attachments, String recipient) throws EncapsulatedExceptions, AttachmentInvalidException, IOException, InvalidNumberException;
+ long sendMessage(String message, List<String> attachments, String recipient) throws EncapsulatedExceptions, AttachmentInvalidException, IOException, InvalidNumberException;
- void sendMessage(String message, List<String> attachments, List<String> recipients) throws EncapsulatedExceptions, AttachmentInvalidException, IOException, InvalidNumberException;
+ long sendMessage(String message, List<String> attachments, List<String> recipients) throws EncapsulatedExceptions, AttachmentInvalidException, IOException, InvalidNumberException;
void sendEndSessionMessage(List<String> recipients) throws IOException, EncapsulatedExceptions, InvalidNumberException;
- void sendGroupMessage(String message, List<String> attachments, byte[] groupId) throws EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException, IOException;
+ long sendGroupMessage(String message, List<String> attachments, byte[] groupId) throws EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException, IOException;
String getContactName(String number) throws InvalidNumberException;
if (attachments == null) {
attachments = new ArrayList<>();
}
+ long timestamp;
if (ns.getString("group") != null) {
byte[] groupId = Util.decodeGroupId(ns.getString("group"));
- signal.sendGroupMessage(messageText, attachments, groupId);
+ timestamp = signal.sendGroupMessage(messageText, attachments, groupId);
} else {
- signal.sendMessage(messageText, attachments, ns.getList("recipient"));
+ timestamp = signal.sendMessage(messageText, attachments, ns.getList("recipient"));
}
+ System.out.println(timestamp);
return 0;
} catch (IOException e) {
handleIOException(e);
}
@Override
- public void sendGroupMessage(String messageText, List<String> attachments,
+ public long sendGroupMessage(String messageText, List<String> attachments,
byte[] groupId)
throws IOException, EncapsulatedExceptions, GroupNotFoundException, AttachmentInvalidException {
final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder().withBody(messageText);
messageBuilder.withExpiration(g.messageExpirationTime);
- sendMessageLegacy(messageBuilder, g.getMembersWithout(account.getSelfAddress()));
+ return sendMessageLegacy(messageBuilder, g.getMembersWithout(account.getSelfAddress()));
}
public void sendGroupMessageReaction(String emoji, boolean remove, String targetAuthor,
}
@Override
- public void sendMessage(String message, List<String> attachments, String recipient)
+ public long sendMessage(String message, List<String> attachments, String recipient)
throws EncapsulatedExceptions, AttachmentInvalidException, IOException, InvalidNumberException {
List<String> recipients = new ArrayList<>(1);
recipients.add(recipient);
- sendMessage(message, attachments, recipients);
+ return sendMessage(message, attachments, recipients);
}
@Override
- public void sendMessage(String messageText, List<String> attachments,
+ public long sendMessage(String messageText, List<String> attachments,
List<String> recipients)
throws IOException, EncapsulatedExceptions, AttachmentInvalidException, InvalidNumberException {
final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder().withBody(messageText);
messageBuilder.withAttachments(attachmentPointers);
}
- sendMessageLegacy(messageBuilder, getSignalServiceAddresses(recipients));
+ return sendMessageLegacy(messageBuilder, getSignalServiceAddresses(recipients));
}
public void sendMessageReaction(String emoji, boolean remove, String targetAuthor,
/**
* This method throws an EncapsulatedExceptions exception instead of returning a list of SendMessageResult.
*/
- private void sendMessageLegacy(SignalServiceDataMessage.Builder messageBuilder, Collection<SignalServiceAddress> recipients)
+ private long sendMessageLegacy(SignalServiceDataMessage.Builder messageBuilder, Collection<SignalServiceAddress> recipients)
throws EncapsulatedExceptions, IOException {
+ final long timestamp = System.currentTimeMillis();
+ messageBuilder.withTimestamp(timestamp);
List<SendMessageResult> results = sendMessage(messageBuilder, recipients);
List<UntrustedIdentityException> untrustedIdentities = new LinkedList<>();
if (!untrustedIdentities.isEmpty() || !unregisteredUsers.isEmpty() || !networkExceptions.isEmpty()) {
throw new EncapsulatedExceptions(untrustedIdentities, unregisteredUsers, networkExceptions);
}
+ return timestamp;
}
private Collection<SignalServiceAddress> getSignalServiceAddresses(Collection<String> numbers) throws InvalidNumberException {