mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
parent
c07ba14fc6
commit
3290a5bf4d
8 changed files with 66 additions and 42 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue