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