X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/7e7e4150e19a65c646bb3f4ec33b5ec87224f8cf..00b3be044ea01a45a34a22c0197c754472760294:/lib/src/main/java/org/asamk/signal/manager/Manager.java diff --git a/lib/src/main/java/org/asamk/signal/manager/Manager.java b/lib/src/main/java/org/asamk/signal/manager/Manager.java index c9f2bad1..8b373e38 100644 --- a/lib/src/main/java/org/asamk/signal/manager/Manager.java +++ b/lib/src/main/java/org/asamk/signal/manager/Manager.java @@ -33,6 +33,7 @@ import java.io.Closeable; import java.io.File; import java.io.IOException; import java.net.URI; +import java.time.Duration; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -40,7 +41,6 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; public interface Manager extends Closeable { @@ -60,6 +60,7 @@ public interface Manager extends Closeable { var account = SignalAccount.load(pathConfig.dataPath(), number, true, trustNewIdentity); if (!account.isRegistered()) { + account.close(); throw new NotRegisteredException(); } @@ -89,7 +90,7 @@ public interface Manager extends Closeable { .filter(File::isFile) .map(File::getName) .filter(file -> PhoneNumberFormatter.isValidNumber(file, null)) - .collect(Collectors.toList()); + .toList(); } String getSelfNumber(); @@ -219,7 +220,7 @@ public interface Manager extends Closeable { /** * Receive new messages from server, returns if no new message arrive in a timespan of timeout. */ - void receiveMessages(long timeout, TimeUnit unit, ReceiveMessageHandler handler) throws IOException; + void receiveMessages(Duration timeout, ReceiveMessageHandler handler) throws IOException; /** * Receive new messages from server, returns only if the thread is interrupted.