mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Implement sendGroupTying dbus method
This commit is contained in:
parent
4999487476
commit
d9c8711eb0
4 changed files with 56 additions and 26 deletions
|
@ -237,9 +237,9 @@ Exceptions: Failure, InvalidNumber
|
|||
|
||||
sendTyping(recipient<s>, stop<b>) -> <>::
|
||||
* recipient : Phone number of a single recipient
|
||||
* targetSentTimestamp : True, if typing state should be stopped
|
||||
* stop : True, if typing state should be stopped
|
||||
|
||||
Exceptions: Failure, GroupNotFound, UntrustedIdentity
|
||||
Exceptions: Failure, UntrustedIdentity
|
||||
|
||||
setContactBlocked(number<s>, block<b>) -> <>::
|
||||
* number : Phone number affected by method
|
||||
|
@ -353,6 +353,12 @@ sendGroupMessage(message<s>, attachments<as>, groupId<ay>) -> timestamp<x>::
|
|||
|
||||
Exceptions: GroupNotFound, Failure, AttachmentInvalid, InvalidGroupId
|
||||
|
||||
sendGroupTyping(groupId<ay>, stop<b>) -> <>::
|
||||
* groupId : Byte array representing the internal group identifier
|
||||
* stop : True, if typing state should be stopped
|
||||
|
||||
Exceptions: Failure, GroupNotFound, UntrustedIdentity
|
||||
|
||||
sendGroupMessageReaction(emoji<s>, remove<b>, targetAuthor<s>, targetSentTimestamp<x>, groupId<ay>) -> timestamp<x>::
|
||||
* emoji : Unicode grapheme cluster of the emoji
|
||||
* remove : Boolean, whether a previously sent reaction (emoji) should be removed
|
||||
|
|
|
@ -36,7 +36,7 @@ public interface Signal extends DBusInterface {
|
|||
|
||||
void sendTyping(
|
||||
String recipient, boolean stop
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
|
||||
) throws Error.Failure, Error.UntrustedIdentity;
|
||||
|
||||
void sendReadReceipt(
|
||||
String recipient, List<Long> messageIds
|
||||
|
@ -54,10 +54,6 @@ public interface Signal extends DBusInterface {
|
|||
long targetSentTimestamp, List<String> recipients
|
||||
) throws Error.Failure, Error.InvalidNumber;
|
||||
|
||||
long sendGroupRemoteDeleteMessage(
|
||||
long targetSentTimestamp, byte[] groupId
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
|
||||
|
||||
long sendMessageReaction(
|
||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, String recipient
|
||||
) throws Error.InvalidNumber, Error.Failure;
|
||||
|
@ -84,6 +80,14 @@ public interface Signal extends DBusInterface {
|
|||
String message, List<String> attachments, byte[] groupId
|
||||
) throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId;
|
||||
|
||||
void sendGroupTyping(
|
||||
final byte[] groupId, final boolean stop
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
|
||||
|
||||
long sendGroupRemoteDeleteMessage(
|
||||
long targetSentTimestamp, byte[] groupId
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
|
||||
|
||||
long sendGroupMessageReaction(
|
||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, byte[] groupId
|
||||
) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
|
||||
|
|
|
@ -301,7 +301,8 @@ public class DbusManagerImpl implements Manager {
|
|||
signal.sendTyping(signal.getSelfNumber(), action == TypingAction.STOP);
|
||||
return 0L;
|
||||
}, groupId -> {
|
||||
throw new UnsupportedOperationException();
|
||||
signal.sendGroupTyping(groupId, action == TypingAction.STOP);
|
||||
return 0L;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -238,22 +238,6 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long sendGroupRemoteDeleteMessage(
|
||||
final long targetSentTimestamp, final byte[] groupId
|
||||
) {
|
||||
try {
|
||||
final var results = m.sendRemoteDeleteMessage(targetSentTimestamp,
|
||||
Set.of(new RecipientIdentifier.Group(getGroupId(groupId))));
|
||||
checkSendMessageResults(results.timestamp(), results.results());
|
||||
return results.timestamp();
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||
throw new Error.GroupNotFound(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long sendMessageReaction(
|
||||
final String emoji,
|
||||
|
@ -401,7 +385,7 @@ public class DbusSignalImpl implements Signal {
|
|||
public long sendGroupMessage(final String message, final List<String> attachments, final byte[] groupId) {
|
||||
try {
|
||||
var results = m.sendMessage(new Message(message, attachments, List.of(), Optional.empty()),
|
||||
Set.of(new RecipientIdentifier.Group(getGroupId(groupId))));
|
||||
Set.of(getGroupRecipientIdentifier(groupId)));
|
||||
checkSendMessageResults(results.timestamp(), results.results());
|
||||
return results.timestamp();
|
||||
} catch (IOException e) {
|
||||
|
@ -413,6 +397,37 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGroupTyping(
|
||||
final byte[] groupId, final boolean stop
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity {
|
||||
try {
|
||||
final var results = m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START,
|
||||
Set.of(getGroupRecipientIdentifier(groupId)));
|
||||
checkSendMessageResults(results.timestamp(), results.results());
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||
throw new Error.GroupNotFound(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long sendGroupRemoteDeleteMessage(
|
||||
final long targetSentTimestamp, final byte[] groupId
|
||||
) {
|
||||
try {
|
||||
final var results = m.sendRemoteDeleteMessage(targetSentTimestamp,
|
||||
Set.of(getGroupRecipientIdentifier(groupId)));
|
||||
checkSendMessageResults(results.timestamp(), results.results());
|
||||
return results.timestamp();
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||
throw new Error.GroupNotFound(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long sendGroupMessageReaction(
|
||||
final String emoji,
|
||||
|
@ -426,7 +441,7 @@ public class DbusSignalImpl implements Signal {
|
|||
remove,
|
||||
getSingleRecipientIdentifier(targetAuthor, m.getSelfNumber()),
|
||||
targetSentTimestamp,
|
||||
Set.of(new RecipientIdentifier.Group(getGroupId(groupId))));
|
||||
Set.of(getGroupRecipientIdentifier(groupId)));
|
||||
checkSendMessageResults(results.timestamp(), results.results());
|
||||
return results.timestamp();
|
||||
} catch (IOException e) {
|
||||
|
@ -854,6 +869,10 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
private RecipientIdentifier.Group getGroupRecipientIdentifier(final byte[] groupId) {
|
||||
return new RecipientIdentifier.Group(getGroupId(groupId));
|
||||
}
|
||||
|
||||
private static GroupId getGroupId(byte[] groupId) throws DBusExecutionException {
|
||||
try {
|
||||
return GroupId.unknownVersion(groupId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue