import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.SignatureException;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
unidentifiedAccessHelper::getAccessFor,
this::resolveSignalServiceAddress);
final GroupV2Helper groupV2Helper = new GroupV2Helper(profileHelper::getRecipientProfileKeyCredential,
- this::getRecipientProfile,
+ profileHelper::getRecipientProfile,
account::getSelfRecipientId,
dependencies.getGroupsV2Operations(),
dependencies.getGroupsV2Api(),
account.getRecipientStore(),
this::handleIdentityFailure,
this::getGroupInfo,
+ profileHelper::getRecipientProfile,
this::refreshRegisteredUser);
this.groupHelper = new GroupHelper(account,
dependencies,
contactHelper,
attachmentHelper,
syncHelper,
- this::getRecipientProfile,
+ profileHelper::getRecipientProfile,
jobExecutor);
this.identityHelper = new IdentityHelper(account,
dependencies,
try {
preKeyHelper.refreshPreKeysIfNecessary();
if (account.getAci() == null) {
- account.setAci(dependencies.getAccountManager().getOwnAci());
+ account.setAci(ACI.parseOrNull(dependencies.getAccountManager().getWhoAmI().getAci()));
}
updateAccountAttributes(null);
} catch (AuthorizationFailedException e) {
d.getCreated(),
d.getLastSeen(),
d.getId() == account.getDeviceId());
- }).collect(Collectors.toList());
+ }).toList();
}
@Override
@Override
public List<Group> getGroups() {
- return account.getGroupStore().getGroups().stream().map(this::toGroup).collect(Collectors.toList());
+ return account.getGroupStore().getGroups().stream().map(this::toGroup).toList();
}
private Group toGroup(final GroupInfo groupInfo) {
.map(sendMessageResult -> SendMessageResult.from(sendMessageResult,
account.getRecipientStore(),
account.getRecipientStore()::resolveRecipientAddress))
- .collect(Collectors.toList()));
+ .toList());
}
}
return new SendMessageResults(timestamp, results);
.map(r -> SendMessageResult.from(r,
account.getRecipientStore(),
account.getRecipientStore()::resolveRecipientAddress))
- .collect(Collectors.toList()));
+ .toList());
}
}
return new SendMessageResults(timestamp, results);
logger.debug("Starting receiving messages");
while (!Thread.interrupted()) {
try {
- receiveMessagesInternal(1L, TimeUnit.HOURS, false, (envelope, e) -> {
+ receiveMessagesInternal(Duration.ofMinutes(1), false, (envelope, e) -> {
synchronized (messageHandlers) {
Stream.concat(messageHandlers.stream(), weakHandlers.stream()).forEach(h -> {
try {
}
@Override
- public void receiveMessages(long timeout, TimeUnit unit, ReceiveMessageHandler handler) throws IOException {
- receiveMessages(timeout, unit, true, handler);
+ public void receiveMessages(Duration timeout, ReceiveMessageHandler handler) throws IOException {
+ receiveMessages(timeout, true, handler);
}
@Override
public void receiveMessages(ReceiveMessageHandler handler) throws IOException {
- receiveMessages(1L, TimeUnit.HOURS, false, handler);
+ receiveMessages(Duration.ofMinutes(1), false, handler);
}
private void receiveMessages(
- long timeout, TimeUnit unit, boolean returnOnTimeout, ReceiveMessageHandler handler
+ Duration timeout, boolean returnOnTimeout, ReceiveMessageHandler handler
) throws IOException {
if (isReceiving()) {
throw new IllegalStateException("Already receiving message.");
isReceivingSynchronous = true;
receiveThread = Thread.currentThread();
try {
- receiveMessagesInternal(timeout, unit, returnOnTimeout, handler);
+ receiveMessagesInternal(timeout, returnOnTimeout, handler);
} finally {
receiveThread = null;
hasCaughtUpWithOldMessages = false;
}
private void receiveMessagesInternal(
- long timeout, TimeUnit unit, boolean returnOnTimeout, ReceiveMessageHandler handler
+ Duration timeout, boolean returnOnTimeout, ReceiveMessageHandler handler
) throws IOException {
retryFailedReceivedMessages(handler);
}
logger.debug("Checking for new message from server");
try {
- var result = signalWebSocket.readOrEmpty(unit.toMillis(timeout), envelope1 -> {
+ var result = signalWebSocket.readOrEmpty(timeout.toMillis(), envelope1 -> {
final var recipientId = envelope1.hasSourceUuid()
? resolveRecipient(envelope1.getSourceAddress())
: null;
.getContacts()
.stream()
.map(p -> new Pair<>(account.getRecipientStore().resolveRecipientAddress(p.first()), p.second()))
- .collect(Collectors.toList());
+ .toList();
}
@Override
@Override
public List<Identity> getIdentities() {
- return account.getIdentityKeyStore()
- .getIdentities()
- .stream()
- .map(this::toIdentity)
- .collect(Collectors.toList());
+ return account.getIdentityKeyStore().getIdentities().stream().map(this::toIdentity).toList();
}
private Identity toIdentity(final IdentityInfo identityInfo) {