mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-07 14:30:38 +00:00
implement Dbus isRegistered() methods
isRegistered(number<s>) returns a boolean isRegistered(numbers<as>) returns an array of Booleans
This commit is contained in:
parent
6c29d90503
commit
1ad09ff222
4 changed files with 321 additions and 118 deletions
|
@ -81,7 +81,9 @@ public interface Signal extends DBusInterface {
|
|||
byte[] groupId, String name, List<String> members, String avatar
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
|
||||
|
||||
boolean isRegistered();
|
||||
boolean isRegistered(String number) throws Error.Failure, Error.InvalidNumber;
|
||||
|
||||
List<Boolean> isRegistered(List<String> numbers) throws Error.Failure, Error.InvalidNumber;
|
||||
|
||||
void updateProfile(
|
||||
String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
|
||||
|
|
|
@ -35,6 +35,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;
|
||||
|
||||
|
@ -388,8 +389,28 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegistered() {
|
||||
return true;
|
||||
public boolean isRegistered(String number) {
|
||||
List<Boolean> result = isRegistered(List.of(number));
|
||||
return result.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Boolean> isRegistered(List<String> numbers) {
|
||||
List<Boolean> results = new ArrayList<Boolean> ();
|
||||
if (numbers.isEmpty()) {
|
||||
return results;
|
||||
}
|
||||
try {
|
||||
Map<String, Pair<String, UUID>> registered;
|
||||
registered = m.areUsersRegistered(new HashSet<String>(numbers));
|
||||
for (String number : numbers) {
|
||||
UUID uuid = registered.get(number).second();
|
||||
results.add(uuid != null);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue