mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Replace collect(Collectors.toList()) with toList()
This commit is contained in:
parent
06e93b84da
commit
62687d103f
41 changed files with 106 additions and 199 deletions
|
@ -40,7 +40,6 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public interface Manager extends Closeable {
|
||||
|
||||
|
@ -90,7 +89,7 @@ public interface Manager extends Closeable {
|
|||
.filter(File::isFile)
|
||||
.map(File::getName)
|
||||
.filter(file -> PhoneNumberFormatter.isValidNumber(file, null))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
String getSelfNumber();
|
||||
|
|
|
@ -445,7 +445,7 @@ public class ManagerImpl implements Manager {
|
|||
d.getCreated(),
|
||||
d.getLastSeen(),
|
||||
d.getId() == account.getDeviceId());
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -517,7 +517,7 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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) {
|
||||
|
@ -628,7 +628,7 @@ public class ManagerImpl implements Manager {
|
|||
.map(sendMessageResult -> SendMessageResult.from(sendMessageResult,
|
||||
account.getRecipientStore(),
|
||||
account.getRecipientStore()::resolveRecipientAddress))
|
||||
.collect(Collectors.toList()));
|
||||
.toList());
|
||||
}
|
||||
}
|
||||
return new SendMessageResults(timestamp, results);
|
||||
|
@ -657,7 +657,7 @@ public class ManagerImpl implements Manager {
|
|||
.map(r -> SendMessageResult.from(r,
|
||||
account.getRecipientStore(),
|
||||
account.getRecipientStore()::resolveRecipientAddress))
|
||||
.collect(Collectors.toList()));
|
||||
.toList());
|
||||
}
|
||||
}
|
||||
return new SendMessageResults(timestamp, results);
|
||||
|
@ -1283,7 +1283,7 @@ public class ManagerImpl implements Manager {
|
|||
.getContacts()
|
||||
.stream()
|
||||
.map(p -> new Pair<>(account.getRecipientStore().resolveRecipientAddress(p.first()), p.second()))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1319,11 +1319,7 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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) {
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MultiAccountManagerImpl implements MultiAccountManager {
|
||||
|
||||
|
@ -46,7 +45,7 @@ public class MultiAccountManagerImpl implements MultiAccountManager {
|
|||
@Override
|
||||
public List<String> getAccountNumbers() {
|
||||
synchronized (managers) {
|
||||
return managers.stream().map(Manager::getSelfNumber).collect(Collectors.toList());
|
||||
return managers.stream().map(Manager::getSelfNumber).toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -135,9 +135,7 @@ public record MessageEnvelope(
|
|||
.transform(p -> p.getPaymentNotification().isPresent() ? Payment.from(p) : null)
|
||||
.orNull()),
|
||||
dataMessage.getAttachments()
|
||||
.transform(a -> a.stream()
|
||||
.map(as -> Attachment.from(as, fileProvider))
|
||||
.collect(Collectors.toList()))
|
||||
.transform(a -> a.stream().map(as -> Attachment.from(as, fileProvider)).toList())
|
||||
.or(List.of()),
|
||||
Optional.ofNullable(dataMessage.getRemoteDelete()
|
||||
.transform(SignalServiceDataMessage.RemoteDelete::getTargetSentTimestamp)
|
||||
|
@ -146,17 +144,15 @@ public record MessageEnvelope(
|
|||
dataMessage.getSharedContacts()
|
||||
.transform(a -> a.stream()
|
||||
.map(sharedContact -> SharedContact.from(sharedContact, fileProvider))
|
||||
.collect(Collectors.toList()))
|
||||
.toList())
|
||||
.or(List.of()),
|
||||
dataMessage.getMentions()
|
||||
.transform(a -> a.stream()
|
||||
.map(m -> Mention.from(m, recipientResolver, addressResolver))
|
||||
.collect(Collectors.toList()))
|
||||
.toList())
|
||||
.or(List.of()),
|
||||
dataMessage.getPreviews()
|
||||
.transform(a -> a.stream()
|
||||
.map(preview -> Preview.from(preview, fileProvider))
|
||||
.collect(Collectors.toList()))
|
||||
.transform(a -> a.stream().map(preview -> Preview.from(preview, fileProvider)).toList())
|
||||
.or(List.of()));
|
||||
}
|
||||
|
||||
|
@ -223,19 +219,18 @@ public record MessageEnvelope(
|
|||
: quote.getMentions()
|
||||
.stream()
|
||||
.map(m -> Mention.from(m, recipientResolver, addressResolver))
|
||||
.collect(Collectors.toList()),
|
||||
.toList(),
|
||||
quote.getAttachments() == null
|
||||
? List.of()
|
||||
: quote.getAttachments()
|
||||
.stream()
|
||||
.map(a -> Attachment.from(a, fileProvider))
|
||||
.collect(Collectors.toList()));
|
||||
: quote.getAttachments().stream().map(a -> Attachment.from(a, fileProvider)).toList());
|
||||
}
|
||||
}
|
||||
|
||||
public record Payment(String note, byte[] receipt) {
|
||||
|
||||
static Payment from(SignalServiceDataMessage.Payment payment) {
|
||||
return new Payment(payment.getPaymentNotification().get().getNote(), payment.getPaymentNotification().get().getReceipt());
|
||||
return new Payment(payment.getPaymentNotification().get().getNote(),
|
||||
payment.getPaymentNotification().get().getReceipt());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,15 +346,9 @@ public record MessageEnvelope(
|
|||
Optional.ofNullable(sharedContact.getAvatar()
|
||||
.transform(avatar1 -> Avatar.from(avatar1, fileProvider))
|
||||
.orNull()),
|
||||
sharedContact.getPhone()
|
||||
.transform(p -> p.stream().map(Phone::from).collect(Collectors.toList()))
|
||||
.or(List.of()),
|
||||
sharedContact.getEmail()
|
||||
.transform(p -> p.stream().map(Email::from).collect(Collectors.toList()))
|
||||
.or(List.of()),
|
||||
sharedContact.getAddress()
|
||||
.transform(p -> p.stream().map(Address::from).collect(Collectors.toList()))
|
||||
.or(List.of()),
|
||||
sharedContact.getPhone().transform(p -> p.stream().map(Phone::from).toList()).or(List.of()),
|
||||
sharedContact.getEmail().transform(p -> p.stream().map(Email::from).toList()).or(List.of()),
|
||||
sharedContact.getAddress().transform(p -> p.stream().map(Address::from).toList()).or(List.of()),
|
||||
Optional.ofNullable(sharedContact.getOrganization().orNull()));
|
||||
}
|
||||
|
||||
|
@ -528,12 +517,12 @@ public record MessageEnvelope(
|
|||
syncMessage.getRead()
|
||||
.transform(r -> r.stream()
|
||||
.map(rm -> Read.from(rm, recipientResolver, addressResolver))
|
||||
.collect(Collectors.toList()))
|
||||
.toList())
|
||||
.or(List.of()),
|
||||
syncMessage.getViewed()
|
||||
.transform(r -> r.stream()
|
||||
.map(rm -> Viewed.from(rm, recipientResolver, addressResolver))
|
||||
.collect(Collectors.toList()))
|
||||
.toList())
|
||||
.or(List.of()),
|
||||
Optional.ofNullable(syncMessage.getViewOnceOpen()
|
||||
.transform(rm -> ViewOnceOpen.from(rm, recipientResolver, addressResolver))
|
||||
|
@ -583,11 +572,7 @@ public record MessageEnvelope(
|
|||
return new Blocked(blockedListMessage.getAddresses()
|
||||
.stream()
|
||||
.map(d -> addressResolver.resolveRecipientAddress(recipientResolver.resolveRecipient(d)))
|
||||
.collect(Collectors.toList()),
|
||||
blockedListMessage.getGroupIds()
|
||||
.stream()
|
||||
.map(GroupId::unknownVersion)
|
||||
.collect(Collectors.toList()));
|
||||
.toList(), blockedListMessage.getGroupIds().stream().map(GroupId::unknownVersion).toList());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -701,7 +686,7 @@ public record MessageEnvelope(
|
|||
Optional.ofNullable(callMessage.getHangupMessage().transform(Hangup::from).orNull()),
|
||||
Optional.ofNullable(callMessage.getBusyMessage().transform(Busy::from).orNull()),
|
||||
callMessage.getIceUpdateMessages()
|
||||
.transform(m -> m.stream().map(IceUpdate::from).collect(Collectors.toList()))
|
||||
.transform(m -> m.stream().map(IceUpdate::from).toList())
|
||||
.or(List.of()),
|
||||
Optional.ofNullable(callMessage.getOpaqueMessage().transform(Opaque::from).orNull()));
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ import java.util.Collection;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GroupHelper {
|
||||
|
||||
|
@ -630,10 +629,7 @@ public class GroupHelper {
|
|||
var group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.UPDATE)
|
||||
.withId(g.getGroupId().serialize())
|
||||
.withName(g.name)
|
||||
.withMembers(g.getMembers()
|
||||
.stream()
|
||||
.map(addressResolver::resolveSignalServiceAddress)
|
||||
.collect(Collectors.toList()));
|
||||
.withMembers(g.getMembers().stream().map(addressResolver::resolveSignalServiceAddress).toList());
|
||||
|
||||
try {
|
||||
final var attachment = createGroupAvatarAttachment(g.getGroupId());
|
||||
|
@ -682,6 +678,6 @@ public class GroupHelper {
|
|||
.map(sendMessageResult -> SendMessageResult.from(sendMessageResult,
|
||||
recipientResolver,
|
||||
account.getRecipientStore()::resolveRecipientAddress))
|
||||
.collect(Collectors.toList()));
|
||||
.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ public class GroupV2Helper {
|
|||
.map(addressResolver::resolveSignalServiceAddress)
|
||||
.map(SignalServiceAddress::getAci)
|
||||
.map(ACI::uuid)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
return commitChange(groupInfoV2,
|
||||
groupOperations.createLeaveAndPromoteMembersToAdmin(selfAci.uuid(), adminUuids));
|
||||
|
|
|
@ -33,7 +33,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SendHelper {
|
||||
|
||||
|
@ -227,9 +226,7 @@ public class SendHelper {
|
|||
}
|
||||
final var messageSender = dependencies.getMessageSender();
|
||||
final var recipientIdList = new ArrayList<>(g.getMembersWithout(account.getSelfRecipientId()));
|
||||
final var addresses = recipientIdList.stream()
|
||||
.map(addressResolver::resolveSignalServiceAddress)
|
||||
.collect(Collectors.toList());
|
||||
final var addresses = recipientIdList.stream().map(addressResolver::resolveSignalServiceAddress).toList();
|
||||
return messageSender.sendTyping(addresses,
|
||||
unidentifiedAccessHelper.getAccessFor(recipientIdList),
|
||||
message,
|
||||
|
@ -255,9 +252,7 @@ public class SendHelper {
|
|||
// isRecipientUpdate is true if we've already sent this message to some recipients in the past, otherwise false.
|
||||
final var isRecipientUpdate = false;
|
||||
final var recipientIdList = new ArrayList<>(recipientIds);
|
||||
final var addresses = recipientIdList.stream()
|
||||
.map(addressResolver::resolveSignalServiceAddress)
|
||||
.collect(Collectors.toList());
|
||||
final var addresses = recipientIdList.stream().map(addressResolver::resolveSignalServiceAddress).toList();
|
||||
return messageSender.sendDataMessage(addresses,
|
||||
unidentifiedAccessHelper.getAccessFor(recipientIdList),
|
||||
isRecipientUpdate,
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.io.IOException;
|
|||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class StorageHelper {
|
||||
|
||||
|
@ -72,7 +71,7 @@ public class StorageHelper {
|
|||
.getStorageIds()
|
||||
.stream()
|
||||
.filter(id -> !id.isUnknown() && id.getType() != ManifestRecord.Identifier.Type.ACCOUNT_VALUE)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
for (final var record : getSignalStorageRecords(storageIds)) {
|
||||
if (record.getType() == ManifestRecord.Identifier.Type.GROUPV2_VALUE) {
|
||||
|
|
|
@ -35,7 +35,6 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SyncHelper {
|
||||
|
||||
|
@ -89,7 +88,7 @@ public class SyncHelper {
|
|||
groupInfo.getMembers()
|
||||
.stream()
|
||||
.map(addressResolver::resolveSignalServiceAddress)
|
||||
.collect(Collectors.toList()),
|
||||
.toList(),
|
||||
groupHelper.createGroupAvatarAttachment(groupInfo.getGroupId()),
|
||||
groupInfo.isMember(account.getSelfRecipientId()),
|
||||
Optional.of(groupInfo.messageExpirationTime),
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.whispersystems.signalservice.internal.util.Util.getSecretBytes;
|
||||
|
||||
|
@ -133,7 +132,7 @@ public class UnidentifiedAccessHelper {
|
|||
}
|
||||
|
||||
public List<Optional<UnidentifiedAccessPair>> getAccessFor(List<RecipientId> recipients) {
|
||||
return recipients.stream().map(this::getAccessFor).collect(Collectors.toList());
|
||||
return recipients.stream().map(this::getAccessFor).toList();
|
||||
}
|
||||
|
||||
public Optional<UnidentifiedAccessPair> getAccessFor(RecipientId recipient) {
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.whispersystems.signalservice.internal.util.Hex;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RetrieveStickerPackJob implements Job {
|
||||
|
||||
|
@ -63,7 +62,7 @@ public class RetrieveStickerPackJob implements Job {
|
|||
.map(c -> new JsonStickerPack.JsonSticker(c.getEmoji(),
|
||||
String.valueOf(c.getId()),
|
||||
c.getContentType()))
|
||||
.collect(Collectors.toList()));
|
||||
.toList());
|
||||
context.getStickerPackStore().storeManifest(packId, jsonManifest);
|
||||
} catch (IOException e) {
|
||||
logger.warn("Failed to retrieve sticker pack {}: {}",
|
||||
|
|
|
@ -262,9 +262,7 @@ public class GroupStore {
|
|||
g1.messageExpirationTime,
|
||||
g1.blocked,
|
||||
g1.archived,
|
||||
g1.members.stream()
|
||||
.map(m -> new Storage.GroupV1.Member(m.id(), null, null))
|
||||
.collect(Collectors.toList()));
|
||||
g1.members.stream().map(m -> new Storage.GroupV1.Member(m.id(), null, null)).toList());
|
||||
}
|
||||
|
||||
final var g2 = (GroupInfoV2) g;
|
||||
|
@ -272,10 +270,10 @@ public class GroupStore {
|
|||
Base64.getEncoder().encodeToString(g2.getMasterKey().serialize()),
|
||||
g2.isBlocked(),
|
||||
g2.isPermissionDenied());
|
||||
}).collect(Collectors.toList()));
|
||||
}).toList());
|
||||
}
|
||||
|
||||
public record Storage(@JsonDeserialize(using = GroupsDeserializer.class) List<Object> groups) {
|
||||
public record Storage(@JsonDeserialize(using = GroupsDeserializer.class) List<Record> groups) {
|
||||
|
||||
private record GroupV1(
|
||||
String groupId,
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class IdentityKeyStore implements org.whispersystems.libsignal.state.IdentityKeyStore {
|
||||
|
||||
|
@ -165,7 +164,7 @@ public class IdentityKeyStore implements org.whispersystems.libsignal.state.Iden
|
|||
.map(f -> resolver.resolveRecipient(Long.parseLong(f.getName())))
|
||||
.filter(Objects::nonNull)
|
||||
.map(this::loadIdentityLocked)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public void mergeRecipients(final RecipientId recipientId, final RecipientId toBeMergedRecipientId) {
|
||||
|
|
|
@ -13,7 +13,6 @@ import java.nio.file.Files;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class MessageCache {
|
||||
|
@ -46,7 +45,7 @@ public class MessageCache {
|
|||
return Stream.empty();
|
||||
}
|
||||
return Arrays.stream(files).filter(File::isFile);
|
||||
}).map(CachedMessage::new).collect(Collectors.toList());
|
||||
}).map(CachedMessage::new).toList();
|
||||
}
|
||||
|
||||
public CachedMessage cacheMessage(SignalServiceEnvelope envelope, RecipientId recipientId) {
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.nio.file.Files;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SignedPreKeyStore implements org.whispersystems.libsignal.state.SignedPreKeyStore {
|
||||
|
||||
|
@ -47,7 +46,7 @@ public class SignedPreKeyStore implements org.whispersystems.libsignal.state.Sig
|
|||
return Arrays.stream(files)
|
||||
.filter(f -> signedPreKeyFileNamePattern.matcher(f.getName()).matches())
|
||||
.map(this::loadSignedPreKeyRecord)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,7 +44,7 @@ public class LegacyJsonIdentityKeyStore {
|
|||
.collect(Collectors.toSet())
|
||||
.stream()
|
||||
.map(this::getIdentity)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public IdentityKeyPair getIdentityKeyPair() {
|
||||
|
|
|
@ -203,7 +203,7 @@ public class RecipientStore implements RecipientResolver, ContactsStore, Profile
|
|||
toBeMerged.add(new Pair<>(pair.first(), pair.second().get()));
|
||||
}
|
||||
return pair.first();
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
for (var pair : toBeMerged) {
|
||||
recipientMergeHandler.mergeRecipients(pair.first(), pair.second());
|
||||
|
@ -231,7 +231,7 @@ public class RecipientStore implements RecipientResolver, ContactsStore, Profile
|
|||
.stream()
|
||||
.filter(e -> e.getValue().getContact() != null)
|
||||
.map(e -> new Pair<>(e.getKey(), e.getValue().getContact()))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -518,7 +518,7 @@ public class RecipientStore implements RecipientResolver, ContactsStore, Profile
|
|||
: base64.encodeToString(recipient.getProfileKeyCredential().serialize()),
|
||||
contact,
|
||||
profile);
|
||||
}).collect(Collectors.toList()), lastId);
|
||||
}).toList(), lastId);
|
||||
|
||||
// Write to memory first to prevent corrupting the file in case of serialization errors
|
||||
try (var inMemoryOutput = new ByteArrayOutputStream()) {
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.util.Objects;
|
|||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SenderKeyRecordStore implements org.whispersystems.libsignal.groups.state.SenderKeyStore {
|
||||
|
||||
|
@ -148,7 +147,7 @@ public class SenderKeyRecordStore implements org.whispersystems.libsignal.groups
|
|||
return new Key(recipientId, Integer.parseInt(matcher.group(2)), UUID.fromString(matcher.group(3)));
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
private File getSenderKeyFile(Key key) {
|
||||
|
|
|
@ -188,7 +188,7 @@ public class SenderKeySharedStore {
|
|||
.map(entry -> new Storage.SharedSenderKey(entry.recipientId().id(),
|
||||
entry.deviceId(),
|
||||
pair.getKey().asUuid().toString()));
|
||||
}).collect(Collectors.toList()));
|
||||
}).toList());
|
||||
|
||||
// Write to memory first to prevent corrupting the file in case of serialization errors
|
||||
try (var inMemoryOutput = new ByteArrayOutputStream()) {
|
||||
|
|
|
@ -59,13 +59,10 @@ public class SessionStore implements SignalServiceSessionStore {
|
|||
|
||||
@Override
|
||||
public List<SessionRecord> loadExistingSessions(final List<SignalProtocolAddress> addresses) throws NoSessionException {
|
||||
final var keys = addresses.stream().map(this::getKey).collect(Collectors.toList());
|
||||
final var keys = addresses.stream().map(this::getKey).toList();
|
||||
|
||||
synchronized (cachedSessions) {
|
||||
final var sessions = keys.stream()
|
||||
.map(this::loadSessionLocked)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
final var sessions = keys.stream().map(this::loadSessionLocked).filter(Objects::nonNull).toList();
|
||||
|
||||
if (sessions.size() != addresses.size()) {
|
||||
String message = "Mismatch! Asked for "
|
||||
|
@ -90,7 +87,7 @@ public class SessionStore implements SignalServiceSessionStore {
|
|||
// get all sessions for recipient except main device session
|
||||
.filter(key -> key.deviceId() != 1 && key.recipientId().equals(recipientId))
|
||||
.map(Key::deviceId)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,7 +243,7 @@ public class SessionStore implements SignalServiceSessionStore {
|
|||
return new Key(recipientId, Integer.parseInt(matcher.group(2)));
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
private File getSessionFile(Key key) {
|
||||
|
|
|
@ -62,7 +62,7 @@ public class StickerStore {
|
|||
.map(s -> new Storage.Sticker(Base64.getEncoder().encodeToString(s.getPackId().serialize()),
|
||||
Base64.getEncoder().encodeToString(s.getPackKey()),
|
||||
s.isInstalled()))
|
||||
.collect(Collectors.toList()));
|
||||
.toList());
|
||||
}
|
||||
|
||||
public record Storage(List<Storage.Sticker> stickers) {
|
||||
|
|
|
@ -37,7 +37,6 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
||||
|
||||
|
@ -317,7 +316,7 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
.filter(Objects::nonNull)
|
||||
.map(m -> exportMultiAccountManager(connection, m, noReceiveOnStart))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
for (var t : initThreads) {
|
||||
try {
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
|||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GetUserStatusCommand implements JsonRpcLocalCommand {
|
||||
|
||||
|
@ -53,7 +52,7 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
|
|||
final var number = entry.getValue().first();
|
||||
final var uuid = entry.getValue().second();
|
||||
return new JsonUserStatus(entry.getKey(), number, uuid == null ? null : uuid.toString(), uuid != null);
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
|
||||
jsonWriter.write(jsonUserStatuses);
|
||||
} else {
|
||||
|
|
|
@ -9,8 +9,6 @@ import org.asamk.signal.output.JsonWriter;
|
|||
import org.asamk.signal.output.OutputWriter;
|
||||
import org.asamk.signal.output.PlainTextWriter;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ListAccountsCommand implements JsonRpcMultiLocalCommand {
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +27,7 @@ public class ListAccountsCommand implements JsonRpcMultiLocalCommand {
|
|||
) throws CommandException {
|
||||
final var accountNumbers = c.getAccountNumbers();
|
||||
if (outputWriter instanceof JsonWriter jsonWriter) {
|
||||
final var jsonAccounts = accountNumbers.stream().map(JsonAccount::new).collect(Collectors.toList());
|
||||
final var jsonAccounts = accountNumbers.stream().map(JsonAccount::new).toList();
|
||||
jsonWriter.write(jsonAccounts);
|
||||
} else if (outputWriter instanceof PlainTextWriter plainTextWriter) {
|
||||
for (final var number : accountNumbers) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.asamk.signal.output.OutputWriter;
|
|||
import org.asamk.signal.output.PlainTextWriter;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ListContactsCommand implements JsonRpcLocalCommand {
|
||||
|
||||
|
@ -48,7 +47,7 @@ public class ListContactsCommand implements JsonRpcLocalCommand {
|
|||
contact.getName(),
|
||||
contact.isBlocked(),
|
||||
contact.getMessageExpirationTime());
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
|
||||
writer.write(jsonContacts);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ListDevicesCommand implements JsonRpcLocalCommand {
|
||||
|
||||
|
@ -56,7 +55,7 @@ public class ListDevicesCommand implements JsonRpcLocalCommand {
|
|||
final var writer = (JsonWriter) outputWriter;
|
||||
final var jsonDevices = devices.stream()
|
||||
.map(d -> new JsonDevice(d.id(), d.name(), d.created(), d.lastSeen()))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
writer.write(jsonDevices);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
|
|||
group.permissionEditDetails().name(),
|
||||
group.permissionSendMessage().name(),
|
||||
groupInviteLink == null ? null : groupInviteLink.getUrl());
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
|
||||
jsonWriter.write(jsonGroups);
|
||||
} else {
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.slf4j.LoggerFactory;
|
|||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ListIdentitiesCommand implements JsonRpcLocalCommand {
|
||||
|
||||
|
@ -76,7 +75,7 @@ public class ListIdentitiesCommand implements JsonRpcLocalCommand {
|
|||
: Base64.getEncoder().encodeToString(scannableSafetyNumber),
|
||||
id.trustLevel().name(),
|
||||
id.dateAdded().getTime());
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
|
||||
writer.write(jsonIdentities);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.slf4j.LoggerFactory;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class UpdateGroupCommand implements JsonRpcLocalCommand {
|
||||
|
@ -160,8 +159,7 @@ public class UpdateGroupCommand implements JsonRpcLocalCommand {
|
|||
groupMessageResults = results;
|
||||
} else {
|
||||
groupMessageResults = new SendGroupMessageResults(results.timestamp(),
|
||||
Stream.concat(groupMessageResults.results().stream(), results.results().stream())
|
||||
.collect(Collectors.toList()));
|
||||
Stream.concat(groupMessageResults.results().stream(), results.results().stream()).toList());
|
||||
}
|
||||
}
|
||||
outputResult(outputWriter, groupMessageResults, isNewGroup ? groupId : null);
|
||||
|
|
|
@ -160,7 +160,7 @@ public class DbusManagerImpl implements Manager {
|
|||
(long) device.get("Created").getValue(),
|
||||
(long) device.get("LastSeen").getValue(),
|
||||
thisDevice.equals(d.getObjectPath()));
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -191,7 +191,7 @@ public class DbusManagerImpl implements Manager {
|
|||
@Override
|
||||
public List<Group> getGroups() {
|
||||
final var groups = signal.listGroups();
|
||||
return groups.stream().map(Signal.StructGroup::getObjectPath).map(this::getGroup).collect(Collectors.toList());
|
||||
return groups.stream().map(Signal.StructGroup::getObjectPath).map(this::getGroup).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -216,7 +216,7 @@ public class DbusManagerImpl implements Manager {
|
|||
final String name, final Set<RecipientIdentifier.Single> members, final File avatarFile
|
||||
) throws IOException, AttachmentInvalidException {
|
||||
final var newGroupId = signal.createGroup(emptyIfNull(name),
|
||||
members.stream().map(RecipientIdentifier.Single::getIdentifier).collect(Collectors.toList()),
|
||||
members.stream().map(RecipientIdentifier.Single::getIdentifier).toList(),
|
||||
avatarFile == null ? "" : avatarFile.getPath());
|
||||
return new Pair<>(GroupId.unknownVersion(newGroupId), new SendGroupMessageResults(0, List.of()));
|
||||
}
|
||||
|
@ -254,28 +254,22 @@ public class DbusManagerImpl implements Manager {
|
|||
: GroupPermission.EVERY_MEMBER.name());
|
||||
}
|
||||
if (updateGroup.getMembers() != null) {
|
||||
group.addMembers(updateGroup.getMembers()
|
||||
.stream()
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList()));
|
||||
group.addMembers(updateGroup.getMembers().stream().map(RecipientIdentifier.Single::getIdentifier).toList());
|
||||
}
|
||||
if (updateGroup.getRemoveMembers() != null) {
|
||||
group.removeMembers(updateGroup.getRemoveMembers()
|
||||
.stream()
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList()));
|
||||
.toList());
|
||||
}
|
||||
if (updateGroup.getAdmins() != null) {
|
||||
group.addAdmins(updateGroup.getAdmins()
|
||||
.stream()
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList()));
|
||||
group.addAdmins(updateGroup.getAdmins().stream().map(RecipientIdentifier.Single::getIdentifier).toList());
|
||||
}
|
||||
if (updateGroup.getRemoveAdmins() != null) {
|
||||
group.removeAdmins(updateGroup.getRemoveAdmins()
|
||||
.stream()
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList()));
|
||||
.toList());
|
||||
}
|
||||
if (updateGroup.isResetGroupLink()) {
|
||||
group.resetLink();
|
||||
|
@ -375,9 +369,7 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public SendMessageResults sendEndSessionMessage(final Set<RecipientIdentifier.Single> recipients) throws IOException {
|
||||
signal.sendEndSessionMessage(recipients.stream()
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList()));
|
||||
signal.sendEndSessionMessage(recipients.stream().map(RecipientIdentifier.Single::getIdentifier).toList());
|
||||
return new SendMessageResults(0, Map.of());
|
||||
}
|
||||
|
||||
|
@ -632,7 +624,7 @@ public class DbusManagerImpl implements Manager {
|
|||
.filter(r -> r instanceof RecipientIdentifier.Single)
|
||||
.map(RecipientIdentifier.Single.class::cast)
|
||||
.map(RecipientIdentifier.Single::getIdentifier)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
if (singleRecipients.size() > 0) {
|
||||
timestamp = recipientsHandler.apply(singleRecipients);
|
||||
}
|
||||
|
@ -644,7 +636,7 @@ public class DbusManagerImpl implements Manager {
|
|||
.filter(r -> r instanceof RecipientIdentifier.Group)
|
||||
.map(RecipientIdentifier.Group.class::cast)
|
||||
.map(RecipientIdentifier.Group::groupId)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
for (final var groupId : groupRecipients) {
|
||||
timestamp = groupHandler.apply(groupId.serialize());
|
||||
}
|
||||
|
@ -826,7 +818,7 @@ public class DbusManagerImpl implements Manager {
|
|||
getValue(a, "isVoiceNote"),
|
||||
getValue(a, "isGif"),
|
||||
getValue(a, "isBorderless"));
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||
|
||||
|
@ -126,11 +125,11 @@ public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler
|
|||
.stream()
|
||||
.filter(a -> a.id().isPresent())
|
||||
.map(this::getAttachmentMap)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
extras.put("attachments", new Variant<>(attachments, "aa{sv}"));
|
||||
}
|
||||
if (message.mentions().size() > 0) {
|
||||
var mentions = message.mentions().stream().map(this::getMentionMap).collect(Collectors.toList());
|
||||
var mentions = message.mentions().stream().map(this::getMentionMap).toList();
|
||||
extras.put("mentions", new Variant<>(mentions, "aa{sv}"));
|
||||
}
|
||||
extras.put("expiresInSeconds", new Variant<>(message.expiresInSeconds()));
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.net.URI;
|
|||
import java.nio.channels.OverlappingFileLockException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
||||
|
||||
|
@ -111,9 +110,6 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
|||
|
||||
@Override
|
||||
public List<DBusPath> listAccounts() {
|
||||
return c.getAccountNumbers()
|
||||
.stream()
|
||||
.map(u -> new DBusPath(DbusConfig.getObjectPath(u)))
|
||||
.collect(Collectors.toList());
|
||||
return c.getAccountNumbers().stream().map(u -> new DBusPath(DbusConfig.getObjectPath(u))).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,9 +191,7 @@ public class DbusSignalImpl implements Signal {
|
|||
|
||||
@Override
|
||||
public long sendMessage(final String message, final List<String> attachments, final String recipient) {
|
||||
var recipients = new ArrayList<String>(1);
|
||||
recipients.add(recipient);
|
||||
return sendMessage(message, attachments, recipients);
|
||||
return sendMessage(message, attachments, List.of(recipient));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -219,9 +217,7 @@ public class DbusSignalImpl implements Signal {
|
|||
public long sendRemoteDeleteMessage(
|
||||
final long targetSentTimestamp, final String recipient
|
||||
) {
|
||||
var recipients = new ArrayList<String>(1);
|
||||
recipients.add(recipient);
|
||||
return sendRemoteDeleteMessage(targetSentTimestamp, recipients);
|
||||
return sendRemoteDeleteMessage(targetSentTimestamp, List.of(recipient));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -266,9 +262,7 @@ public class DbusSignalImpl implements Signal {
|
|||
final long targetSentTimestamp,
|
||||
final String recipient
|
||||
) {
|
||||
var recipients = new ArrayList<String>(1);
|
||||
recipients.add(recipient);
|
||||
return sendMessageReaction(emoji, remove, targetAuthor, targetSentTimestamp, recipients);
|
||||
return sendMessageReaction(emoji, remove, targetAuthor, targetSentTimestamp, List.of(recipient));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -301,10 +295,8 @@ public class DbusSignalImpl implements Signal {
|
|||
final String recipient, final boolean stop
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity {
|
||||
try {
|
||||
var recipients = new ArrayList<String>(1);
|
||||
recipients.add(recipient);
|
||||
final var results = m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START,
|
||||
getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
|
||||
getSingleRecipientIdentifiers(List.of(recipient), m.getSelfNumber()).stream()
|
||||
.map(RecipientIdentifier.class::cast)
|
||||
.collect(Collectors.toSet()));
|
||||
checkSendMessageResults(results.timestamp(), results.results());
|
||||
|
@ -499,11 +491,7 @@ public class DbusSignalImpl implements Signal {
|
|||
@Override
|
||||
public List<byte[]> getGroupIds() {
|
||||
var groups = m.getGroups();
|
||||
var ids = new ArrayList<byte[]>(groups.size());
|
||||
for (var group : groups) {
|
||||
ids.add(group.groupId().serialize());
|
||||
}
|
||||
return ids;
|
||||
return groups.stream().map(g -> g.groupId().serialize()).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -595,9 +583,8 @@ public class DbusSignalImpl implements Signal {
|
|||
|
||||
@Override
|
||||
public List<Boolean> isRegistered(List<String> numbers) {
|
||||
var results = new ArrayList<Boolean>();
|
||||
if (numbers.isEmpty()) {
|
||||
return results;
|
||||
return List.of();
|
||||
}
|
||||
|
||||
Map<String, Pair<String, UUID>> registered;
|
||||
|
@ -610,7 +597,7 @@ public class DbusSignalImpl implements Signal {
|
|||
return numbers.stream().map(number -> {
|
||||
var uuid = registered.get(number).second();
|
||||
return uuid != null;
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -682,7 +669,7 @@ public class DbusSignalImpl implements Signal {
|
|||
.map(a -> a.number().orElse(null))
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -844,7 +831,7 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
|
||||
private static List<String> getRecipientStrings(final Set<RecipientAddress> members) {
|
||||
return members.stream().map(RecipientAddress::getLegacyIdentifier).collect(Collectors.toList());
|
||||
return members.stream().map(RecipientAddress::getLegacyIdentifier).toList();
|
||||
}
|
||||
|
||||
private static Set<RecipientIdentifier.Single> getSingleRecipientIdentifiers(
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.asamk.signal.manager.api.MessageEnvelope;
|
|||
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
record JsonCallMessage(
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) Offer offerMessage,
|
||||
|
@ -21,7 +20,7 @@ record JsonCallMessage(
|
|||
callMessage.answer().map(Answer::from).orElse(null),
|
||||
callMessage.busy().map(Busy::from).orElse(null),
|
||||
callMessage.hangup().map(Hangup::from).orElse(null),
|
||||
callMessage.iceUpdate().stream().map(IceUpdate::from).collect(Collectors.toList()));
|
||||
callMessage.iceUpdate().stream().map(IceUpdate::from).toList());
|
||||
}
|
||||
|
||||
record Offer(long id, String sdp, String type, String opaque) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
record JsonDataMessage(
|
||||
long timestamp,
|
||||
|
@ -36,20 +35,20 @@ record JsonDataMessage(
|
|||
final var mentions = dataMessage.mentions().size() > 0 ? dataMessage.mentions()
|
||||
.stream()
|
||||
.map(JsonMention::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
.toList() : null;
|
||||
final var remoteDelete = dataMessage.remoteDeleteId().isPresent()
|
||||
? new JsonRemoteDelete(dataMessage.remoteDeleteId().get())
|
||||
: null;
|
||||
final var attachments = dataMessage.attachments().size() > 0 ? dataMessage.attachments()
|
||||
.stream()
|
||||
.map(JsonAttachment::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
.toList() : null;
|
||||
final var sticker = dataMessage.sticker().isPresent() ? JsonSticker.from(dataMessage.sticker().get()) : null;
|
||||
|
||||
final var contacts = dataMessage.sharedContacts().size() > 0 ? dataMessage.sharedContacts()
|
||||
.stream()
|
||||
.map(JsonSharedContact::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
.toList() : null;
|
||||
return new JsonDataMessage(timestamp,
|
||||
message,
|
||||
expiresInSeconds,
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.asamk.signal.json;
|
|||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
public record JsonPayment(String note, byte[] receipt) {
|
||||
|
||||
static JsonPayment from(MessageEnvelope.Data.Payment payment) {
|
||||
return new JsonPayment(payment.note(), payment.receipt());
|
||||
}
|
||||
|
|
|
@ -4,10 +4,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public record JsonQuote(
|
||||
long id,
|
||||
|
@ -27,15 +25,14 @@ public record JsonQuote(
|
|||
final var authorUuid = address.uuid().map(UUID::toString).orElse(null);
|
||||
final var text = quote.text().orElse(null);
|
||||
|
||||
final var mentions = quote.mentions().size() > 0 ? quote.mentions()
|
||||
.stream()
|
||||
.map(JsonMention::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
final var mentions = quote.mentions().size() > 0
|
||||
? quote.mentions().stream().map(JsonMention::from).toList()
|
||||
: null;
|
||||
|
||||
final var attachments = quote.attachments().size() > 0 ? quote.attachments()
|
||||
.stream()
|
||||
.map(JsonQuotedAttachment::from)
|
||||
.collect(Collectors.toList()) : new ArrayList<JsonQuotedAttachment>();
|
||||
.toList() : List.<JsonQuotedAttachment>of();
|
||||
|
||||
return new JsonQuote(id, author, authorNumber, authorUuid, text, mentions, attachments);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public record JsonSharedContact(
|
||||
JsonContactName name,
|
||||
|
@ -20,20 +19,18 @@ public record JsonSharedContact(
|
|||
final var name = JsonContactName.from(contact.name());
|
||||
final var avatar = contact.avatar().isPresent() ? JsonContactAvatar.from(contact.avatar().get()) : null;
|
||||
|
||||
final var phone = contact.phone().size() > 0 ? contact.phone()
|
||||
.stream()
|
||||
.map(JsonContactPhone::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
final var phone = contact.phone().size() > 0
|
||||
? contact.phone().stream().map(JsonContactPhone::from).toList()
|
||||
: null;
|
||||
|
||||
final var email = contact.email().size() > 0 ? contact.email()
|
||||
.stream()
|
||||
.map(JsonContactEmail::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
final var email = contact.email().size() > 0
|
||||
? contact.email().stream().map(JsonContactEmail::from).toList()
|
||||
: null;
|
||||
|
||||
final var address = contact.address().size() > 0 ? contact.address()
|
||||
.stream()
|
||||
.map(JsonContactAddress::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
.toList() : null;
|
||||
|
||||
final var organization = contact.organization().orElse(null);
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.asamk.signal.manager.groups.GroupId;
|
|||
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
enum JsonSyncMessageType {
|
||||
CONTACTS_SYNC,
|
||||
|
@ -49,13 +48,8 @@ record JsonSyncMessage(
|
|||
.recipients()
|
||||
.stream()
|
||||
.map(RecipientAddress::getLegacyIdentifier)
|
||||
.collect(Collectors.toList());
|
||||
blockedGroupIds = syncMessage.blocked()
|
||||
.get()
|
||||
.groupIds()
|
||||
.stream()
|
||||
.map(GroupId::toBase64)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
blockedGroupIds = syncMessage.blocked().get().groupIds().stream().map(GroupId::toBase64).toList();
|
||||
} else {
|
||||
blockedNumbers = null;
|
||||
blockedGroupIds = null;
|
||||
|
@ -64,7 +58,7 @@ record JsonSyncMessage(
|
|||
final var readMessages = syncMessage.read().size() > 0 ? syncMessage.read()
|
||||
.stream()
|
||||
.map(JsonSyncReadMessage::from)
|
||||
.collect(Collectors.toList()) : null;
|
||||
.toList() : null;
|
||||
|
||||
final JsonSyncMessageType type;
|
||||
if (syncMessage.contacts().isPresent()) {
|
||||
|
|
|
@ -15,7 +15,6 @@ import java.io.IOException;
|
|||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
public class JsonRpcReader {
|
||||
|
@ -57,7 +56,7 @@ public class JsonRpcReader {
|
|||
}
|
||||
|
||||
return handleRequest(requestHandler, request);
|
||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}).filter(Objects::nonNull).toList();
|
||||
|
||||
jsonRpcSender.sendBatchResponses(responseList);
|
||||
}
|
||||
|
@ -128,8 +127,7 @@ public class JsonRpcReader {
|
|||
null), null));
|
||||
return null;
|
||||
}
|
||||
return new JsonRpcBatchMessage(StreamSupport.stream(jsonNode.spliterator(), false)
|
||||
.collect(Collectors.toList()));
|
||||
return new JsonRpcBatchMessage(StreamSupport.stream(jsonNode.spliterator(), false).toList());
|
||||
} else if (jsonNode.isObject()) {
|
||||
if (jsonNode.has("result") || jsonNode.has("error")) {
|
||||
return parseJsonRpcResponse(jsonNode);
|
||||
|
|
|
@ -53,14 +53,14 @@ public class SendMessageResultUtils {
|
|||
.map(SendMessageResultUtils::getErrorMessageFromSendMessageResult)
|
||||
.filter(Objects::nonNull)
|
||||
.map(error -> entry.getKey().getIdentifier() + ": " + error))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static List<String> getErrorMessagesFromSendMessageResults(Collection<SendMessageResult> results) {
|
||||
return results.stream()
|
||||
.map(SendMessageResultUtils::getErrorMessageFromSendMessageResult)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static String getErrorMessageFromSendMessageResult(SendMessageResult result) {
|
||||
|
@ -110,10 +110,10 @@ public class SendMessageResultUtils {
|
|||
return mapResults.entrySet().stream().flatMap(entry -> {
|
||||
final var groupId = entry.getKey() instanceof RecipientIdentifier.Group g ? g.groupId() : null;
|
||||
return entry.getValue().stream().map(r -> JsonSendMessageResult.from(r, groupId));
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
public static List<JsonSendMessageResult> getJsonSendMessageResults(Collection<SendMessageResult> results) {
|
||||
return results.stream().map(JsonSendMessageResult::from).collect(Collectors.toList());
|
||||
return results.stream().map(JsonSendMessageResult::from).toList();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue