Add sendTyping and sendReceipt to dbus interface (#718)

* Add sendTyping and sendReceipt to dbus interface

* Resolve requested changes

* Adapt documentation
This commit is contained in:
JtheSaw 2021-09-13 17:01:26 +02:00 committed by GitHub
parent 12e85ec671
commit 11b3758416
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 0 deletions

View file

@ -5,8 +5,10 @@ import org.asamk.signal.BaseConfig;
import org.asamk.signal.manager.AttachmentInvalidException;
import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.NotMasterDeviceException;
import org.asamk.signal.manager.UntrustedIdentityException;
import org.asamk.signal.manager.api.Message;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.api.TypingAction;
import org.asamk.signal.manager.groups.GroupId;
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
import org.asamk.signal.manager.groups.GroupNotFoundException;
@ -165,6 +167,39 @@ public class DbusSignalImpl implements Signal {
}
}
@Override
public void sendTyping(
final String recipient, final boolean stop
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity {
try {
var recipients = new ArrayList<String>(1);
recipients.add(recipient);
m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START,
getSingleRecipientIdentifiers(recipients, m.getUsername()).stream()
.map(RecipientIdentifier.class::cast)
.collect(Collectors.toSet()));
} catch (IOException e) {
throw new Error.Failure(e.getMessage());
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
throw new Error.GroupNotFound(e.getMessage());
} catch (UntrustedIdentityException e) {
throw new Error.UntrustedIdentity(e.getMessage());
}
}
@Override
public void sendReadReceipt(
final String recipient, final List<Long> timestamps
) throws Error.Failure, Error.UntrustedIdentity {
try {
m.sendReadReceipt(getSingleRecipientIdentifier(recipient, m.getUsername()), timestamps);
} catch (IOException e) {
throw new Error.Failure(e.getMessage());
} catch (UntrustedIdentityException e) {
throw new Error.UntrustedIdentity(e.getMessage());
}
}
@Override
public long sendNoteToSelfMessage(
final String message, final List<String> attachments