implement Dbus stickerpack method (#740)

implement uploadStickerPack

update documentation
This commit is contained in:
John Freed 2021-09-26 08:59:38 +02:00 committed by GitHub
parent 982e887c9f
commit 1ca0e75ef1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

View file

@ -248,6 +248,12 @@ version() -> version<s>::
isRegistred -> result<b>:: isRegistred -> result<b>::
* result : Currently always returns 1=true * result : Currently always returns 1=true
uploadStickerPack(stickerPackPath<s>) -> url<s>::
* stickerPackPath : Path to the manifest.json file or a zip file in the same directory
* url : URL of sticker pack after successful upload
Exception: Failure
== Signals == Signals
SyncMessageReceived (timestamp<x>, sender<s>, destination<s>, groupId<ay>,message<s>, attachments<as>):: SyncMessageReceived (timestamp<x>, sender<s>, destination<s>, groupId<ay>,message<s>, attachments<as>)::

View file

@ -107,6 +107,8 @@ public interface Signal extends DBusInterface {
byte[] joinGroup(final String groupLink) throws Error.Failure; byte[] joinGroup(final String groupLink) throws Error.Failure;
String uploadStickerPack(String stickerPackPath) throws Error.Failure;
class MessageReceived extends DBusSignal { class MessageReceived extends DBusSignal {
private final long timestamp; private final long timestamp;

View file

@ -5,6 +5,7 @@ import org.asamk.signal.BaseConfig;
import org.asamk.signal.manager.AttachmentInvalidException; import org.asamk.signal.manager.AttachmentInvalidException;
import org.asamk.signal.manager.Manager; import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.NotMasterDeviceException; import org.asamk.signal.manager.NotMasterDeviceException;
import org.asamk.signal.manager.StickerPackInvalidException;
import org.asamk.signal.manager.UntrustedIdentityException; import org.asamk.signal.manager.UntrustedIdentityException;
import org.asamk.signal.manager.api.Message; import org.asamk.signal.manager.api.Message;
import org.asamk.signal.manager.api.RecipientIdentifier; import org.asamk.signal.manager.api.RecipientIdentifier;
@ -536,6 +537,18 @@ public class DbusSignalImpl implements Signal {
} }
} }
@Override
public String uploadStickerPack(String stickerPackPath) {
File path = new File(stickerPackPath);
try {
return m.uploadStickerPack(path).toString();
} catch (IOException e) {
throw new Error.Failure("Upload error (maybe image size is too large):" + e.getMessage());
} catch (StickerPackInvalidException e) {
throw new Error.Failure("Invalid sticker pack: " + e.getMessage());
}
}
private static void checkSendMessageResult(long timestamp, SendMessageResult result) throws DBusExecutionException { private static void checkSendMessageResult(long timestamp, SendMessageResult result) throws DBusExecutionException {
var error = ErrorUtils.getErrorMessageFromSendMessageResult(result); var error = ErrorUtils.getErrorMessageFromSendMessageResult(result);