Add --notify-self parmeter

Fixes #1087
This commit is contained in:
AsamK 2024-01-12 18:07:14 +01:00
parent c07ba14fc6
commit 3290a5bf4d
8 changed files with 66 additions and 42 deletions

View file

@ -225,19 +225,20 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
}
@Override
public long sendMessage(final String message, final List<String> attachments, final List<String> recipients) {
public long sendMessage(final String messageText, final List<String> attachments, final List<String> recipients) {
try {
final var results = m.sendMessage(new Message(message,
attachments,
List.of(),
Optional.empty(),
Optional.empty(),
List.of(),
Optional.empty(),
List.of()),
getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
.map(RecipientIdentifier.class::cast)
.collect(Collectors.toSet()));
final var message = new Message(messageText,
attachments,
List.of(),
Optional.empty(),
Optional.empty(),
List.of(),
Optional.empty(),
List.of());
final var recipientIdentifiers = getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
.map(RecipientIdentifier.class::cast)
.collect(Collectors.toSet());
final var results = m.sendMessage(message, recipientIdentifiers, false);
checkSendMessageResults(results);
return results.timestamp();
@ -384,17 +385,18 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
@Override
public long sendNoteToSelfMessage(
final String message, final List<String> attachments
final String messageText, final List<String> attachments
) throws Error.AttachmentInvalid, Error.Failure, Error.UntrustedIdentity {
try {
final var results = m.sendMessage(new Message(message,
final var message = new Message(messageText,
attachments,
List.of(),
Optional.empty(),
Optional.empty(),
List.of(),
Optional.empty(),
List.of()), Set.of(RecipientIdentifier.NoteToSelf.INSTANCE));
List.of());
final var results = m.sendMessage(message, Set.of(RecipientIdentifier.NoteToSelf.INSTANCE), false);
checkSendMessageResults(results);
return results.timestamp();
} catch (AttachmentInvalidException e) {
@ -429,16 +431,17 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
}
@Override
public long sendGroupMessage(final String message, final List<String> attachments, final byte[] groupId) {
public long sendGroupMessage(final String messageText, final List<String> attachments, final byte[] groupId) {
try {
var results = m.sendMessage(new Message(message,
final var message = new Message(messageText,
attachments,
List.of(),
Optional.empty(),
Optional.empty(),
List.of(),
Optional.empty(),
List.of()), Set.of(getGroupRecipientIdentifier(groupId)));
List.of());
var results = m.sendMessage(message, Set.of(getGroupRecipientIdentifier(groupId)), false);
checkSendMessageResults(results);
return results.timestamp();
} catch (IOException | InvalidStickerException e) {