X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/51c130b40651b1d01caee7175235f2632f5aa73e..d08508e6efbb0f993a6b7bd633d6406d0575db34:/src/main/java/org/asamk/signal/commands/SendCommand.java diff --git a/src/main/java/org/asamk/signal/commands/SendCommand.java b/src/main/java/org/asamk/signal/commands/SendCommand.java index 176c2d92..a805a12c 100644 --- a/src/main/java/org/asamk/signal/commands/SendCommand.java +++ b/src/main/java/org/asamk/signal/commands/SendCommand.java @@ -3,22 +3,31 @@ package org.asamk.signal.commands; import net.sourceforge.argparse4j.impl.Arguments; import net.sourceforge.argparse4j.inf.Namespace; import net.sourceforge.argparse4j.inf.Subparser; + import org.asamk.Signal; -import org.asamk.signal.AttachmentInvalidException; -import org.asamk.signal.GroupIdFormatException; -import org.asamk.signal.GroupNotFoundException; -import org.asamk.signal.NotAGroupMemberException; +import org.asamk.signal.manager.AttachmentInvalidException; +import org.asamk.signal.manager.GroupNotFoundException; +import org.asamk.signal.manager.NotAGroupMemberException; +import org.asamk.signal.util.GroupIdFormatException; import org.asamk.signal.util.IOUtils; import org.asamk.signal.util.Util; import org.freedesktop.dbus.exceptions.DBusExecutionException; import org.whispersystems.signalservice.api.push.exceptions.EncapsulatedExceptions; +import org.whispersystems.signalservice.api.util.InvalidNumberException; import java.io.IOException; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; -import static org.asamk.signal.util.ErrorUtils.*; +import static org.asamk.signal.util.ErrorUtils.handleAssertionError; +import static org.asamk.signal.util.ErrorUtils.handleDBusExecutionException; +import static org.asamk.signal.util.ErrorUtils.handleEncapsulatedExceptions; +import static org.asamk.signal.util.ErrorUtils.handleGroupIdFormatException; +import static org.asamk.signal.util.ErrorUtils.handleGroupNotFoundException; +import static org.asamk.signal.util.ErrorUtils.handleIOException; +import static org.asamk.signal.util.ErrorUtils.handleInvalidNumberException; +import static org.asamk.signal.util.ErrorUtils.handleNotAGroupMemberException; public class SendCommand implements DbusCommand { @@ -54,7 +63,7 @@ public class SendCommand implements DbusCommand { if (ns.getBoolean("endsession")) { try { - signal.sendEndSessionMessage(ns.getList("recipient")); + signal.sendEndSessionMessage(ns.getList("recipient")); return 0; } catch (IOException e) { handleIOException(e); @@ -68,6 +77,9 @@ public class SendCommand implements DbusCommand { } catch (DBusExecutionException e) { handleDBusExecutionException(e); return 1; + } catch (InvalidNumberException e) { + handleInvalidNumberException(e); + return 1; } } @@ -87,12 +99,14 @@ public class SendCommand implements DbusCommand { if (attachments == null) { attachments = new ArrayList<>(); } + long timestamp; if (ns.getString("group") != null) { byte[] groupId = Util.decodeGroupId(ns.getString("group")); - signal.sendGroupMessage(messageText, attachments, groupId); + timestamp = signal.sendGroupMessage(messageText, attachments, groupId); } else { - signal.sendMessage(messageText, attachments, ns.getList("recipient")); + timestamp = signal.sendMessage(messageText, attachments, ns.getList("recipient")); } + System.out.println(timestamp); return 0; } catch (IOException e) { handleIOException(e); @@ -119,6 +133,9 @@ public class SendCommand implements DbusCommand { } catch (GroupIdFormatException e) { handleGroupIdFormatException(e); return 1; + } catch (InvalidNumberException e) { + handleInvalidNumberException(e); + return 1; } } }