mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 11:00:38 +00:00
Command to check if number is registered (#391)
* Added the isRegistered command * Minor fixes * Corrected description * Added AsamK's suggestions Fixes #178
This commit is contained in:
parent
a475bc50e9
commit
1c5de83370
4 changed files with 119 additions and 0 deletions
|
@ -383,6 +383,28 @@ public class Manager implements Closeable {
|
|||
return account.isRegistered();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used for checking a set of phone numbers for registration on Signal
|
||||
*
|
||||
* @param numbers The set of phone number in question
|
||||
* @return A map of numbers to booleans. True if registered, false otherwise. Should never be null
|
||||
* @throws IOException if its unable to check if the users are registered
|
||||
*/
|
||||
public Map<String, Boolean> areUsersRegistered(Set<String> numbers) throws IOException {
|
||||
// Note "contactDetails" has no optionals. It only gives us info on users who are registered
|
||||
List<ContactTokenDetails> contactDetails = this.accountManager.getContacts(numbers);
|
||||
|
||||
// Make the initial map with all numbers set to false for now
|
||||
Map<String, Boolean> usersRegistered = numbers.stream().collect(Collectors.toMap(x -> x, x -> false));
|
||||
|
||||
// Override the contacts we did obtain
|
||||
for (ContactTokenDetails contactDetail : contactDetails) {
|
||||
usersRegistered.put(contactDetail.getNumber(), true);
|
||||
}
|
||||
|
||||
return usersRegistered;
|
||||
}
|
||||
|
||||
public void register(boolean voiceVerification, String captcha) throws IOException {
|
||||
account.setPassword(KeyUtils.createPassword());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue