mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Refactor isRegistered
This commit is contained in:
parent
1c4a32fef4
commit
375c9d60cf
1 changed files with 10 additions and 10 deletions
|
@ -468,8 +468,7 @@ public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegistered() {
|
public boolean isRegistered() {
|
||||||
var result = isRegistered(List.of(m.getUsername()));
|
return true;
|
||||||
return result.get(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -480,21 +479,22 @@ public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Boolean> isRegistered(List<String> numbers) {
|
public List<Boolean> isRegistered(List<String> numbers) {
|
||||||
var results = new ArrayList<Boolean> ();
|
var results = new ArrayList<Boolean>();
|
||||||
Map<String, Pair<String, UUID>> registered;
|
|
||||||
if (numbers.isEmpty()) {
|
if (numbers.isEmpty()) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, Pair<String, UUID>> registered;
|
||||||
try {
|
try {
|
||||||
registered = m.areUsersRegistered(new HashSet<String>(numbers));
|
registered = m.areUsersRegistered(new HashSet<>(numbers));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new Error.Failure(e.getMessage());
|
throw new Error.Failure(e.getMessage());
|
||||||
}
|
}
|
||||||
for (String number : numbers) {
|
|
||||||
UUID uuid = registered.get(number).second();
|
return numbers.stream().map(number -> {
|
||||||
results.add(uuid != null);
|
var uuid = registered.get(number).second();
|
||||||
}
|
return uuid != null;
|
||||||
return results;
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue