X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/2a20e70aabaad0106774157a78eba60428604ac1..53f47d42fc30a86a9bb6cd08f4678a756f4a4aaf:/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java diff --git a/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java b/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java index ed27ad6d..29889c3d 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java @@ -22,6 +22,7 @@ import org.asamk.signal.manager.api.StickerPackInvalidException; import org.asamk.signal.manager.api.StickerPackUrl; import org.asamk.signal.manager.api.TypingAction; import org.asamk.signal.manager.api.UpdateGroup; +import org.asamk.signal.manager.api.UserStatus; import org.asamk.signal.manager.groups.GroupId; import org.asamk.signal.manager.groups.GroupInviteLinkUrl; import org.asamk.signal.manager.groups.GroupNotFoundException; @@ -46,6 +47,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.time.Duration; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -53,7 +55,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.UUID; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Function; import java.util.function.Supplier; @@ -87,14 +88,16 @@ public class DbusManagerImpl implements Manager { } @Override - public Map> areUsersRegistered(final Set numbers) throws IOException { + public Map getUserStatus(final Set numbers) throws IOException { final var numbersList = new ArrayList<>(numbers); final var registered = signal.isRegistered(numbersList); - final var result = new HashMap>(); + final var result = new HashMap(); for (var i = 0; i < numbersList.size(); i++) { result.put(numbersList.get(i), - new Pair<>(numbersList.get(i), registered.get(i) ? RecipientAddress.UNKNOWN_UUID : null)); + new UserStatus(numbersList.get(i), + registered.get(i) ? RecipientAddress.UNKNOWN_UUID : null, + false)); } return result; } @@ -408,17 +411,21 @@ public class DbusManagerImpl implements Manager { } @Override - public void setContactBlocked( - final RecipientIdentifier.Single recipient, final boolean blocked + public void setContactsBlocked( + final Collection recipients, final boolean blocked ) throws NotMasterDeviceException, IOException { - signal.setContactBlocked(recipient.getIdentifier(), blocked); + for (final var recipient : recipients) { + signal.setContactBlocked(recipient.getIdentifier(), blocked); + } } @Override - public void setGroupBlocked( - final GroupId groupId, final boolean blocked + public void setGroupsBlocked( + final Collection groupIds, final boolean blocked ) throws GroupNotFoundException, IOException { - setGroupProperty(groupId, "IsBlocked", blocked); + for (final var groupId : groupIds) { + setGroupProperty(groupId, "IsBlocked", blocked); + } } private void setGroupProperty(final GroupId groupId, final String propertyName, final boolean blocked) { @@ -786,7 +793,7 @@ public class DbusManagerImpl implements Manager { ? Optional.empty() : Optional.of(new RecipientAddress(null, syncReceived.getDestination())), Set.of(), - new MessageEnvelope.Data(syncReceived.getTimestamp(), + Optional.of(new MessageEnvelope.Data(syncReceived.getTimestamp(), syncReceived.getGroupId().length > 0 ? Optional.of(new MessageEnvelope.Data.GroupContext(GroupId.unknownVersion( syncReceived.getGroupId()), false, 0)) @@ -806,7 +813,7 @@ public class DbusManagerImpl implements Manager { Optional.empty(), List.of(), List.of(), - List.of()))), + List.of())))), Optional.empty(), List.of(), List.of(),