X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/e78463ea0a81ef326b6adf85a50887de5192fcf7..1c4a32fef4a3273099f0bfdd1b0dea72d32324ae:/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java diff --git a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java index 768f6e89..82cd8f8d 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java @@ -41,6 +41,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -73,7 +74,9 @@ public class DbusSignalImpl implements Signal { } catch (IOException | InvalidKeyException e) { throw new Error.Failure(e.getClass().getSimpleName() + " Add device link failed. " + e.getMessage()); } catch (URISyntaxException e) { - throw new Error.InvalidUri(e.getClass().getSimpleName() + " Device link uri has invalid format: " + e.getMessage()); + throw new Error.InvalidUri(e.getClass().getSimpleName() + + " Device link uri has invalid format: " + + e.getMessage()); } } @@ -97,9 +100,7 @@ public class DbusSignalImpl implements Signal { throw new Error.Failure("Failed to get linked devices: " + e.getMessage()); } - return devices.stream() - .map(d -> d.getName() == null ? "" : d.getName()) - .collect(Collectors.toList()); + return devices.stream().map(d -> d.getName() == null ? "" : d.getName()).collect(Collectors.toList()); } @Override @@ -467,7 +468,33 @@ public class DbusSignalImpl implements Signal { @Override public boolean isRegistered() { - return true; + var result = isRegistered(List.of(m.getUsername())); + return result.get(0); + } + + @Override + public boolean isRegistered(String number) { + var result = isRegistered(List.of(number)); + return result.get(0); + } + + @Override + public List isRegistered(List numbers) { + var results = new ArrayList (); + Map> registered; + if (numbers.isEmpty()) { + return results; + } + try { + registered = m.areUsersRegistered(new HashSet(numbers)); + } catch (IOException e) { + throw new Error.Failure(e.getMessage()); + } + for (String number : numbers) { + UUID uuid = registered.get(number).second(); + results.add(uuid != null); + } + return results; } @Override