mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Refactor group store
This commit is contained in:
parent
a1014ba39c
commit
5b8c0c4e2d
14 changed files with 644 additions and 473 deletions
|
@ -46,7 +46,7 @@ public class JoinGroupCommand implements LocalCommand {
|
|||
|
||||
final var results = m.joinGroup(linkUrl);
|
||||
var newGroupId = results.first();
|
||||
if (!m.getGroup(newGroupId).isMember(m.getSelfAddress())) {
|
||||
if (!m.getGroup(newGroupId).isMember(m.getSelfRecipientId())) {
|
||||
writer.println("Requested to join group \"{}\"", newGroupId.toBase64());
|
||||
} else {
|
||||
writer.println("Joined group \"{}\"", newGroupId.toBase64());
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.asamk.signal.PlainTextWriterImpl;
|
|||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.storage.groups.GroupInfo;
|
||||
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
@ -23,7 +24,7 @@ public class ListGroupsCommand implements LocalCommand {
|
|||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ListGroupsCommand.class);
|
||||
|
||||
private static Set<String> resolveMembers(Manager m, Set<SignalServiceAddress> addresses) {
|
||||
private static Set<String> resolveMembers(Manager m, Set<RecipientId> addresses) {
|
||||
return addresses.stream()
|
||||
.map(m::resolveSignalServiceAddress)
|
||||
.map(SignalServiceAddress::getLegacyIdentifier)
|
||||
|
@ -40,7 +41,7 @@ public class ListGroupsCommand implements LocalCommand {
|
|||
"Id: {} Name: {} Active: {} Blocked: {} Members: {} Pending members: {} Requesting members: {} Link: {}",
|
||||
group.getGroupId().toBase64(),
|
||||
group.getTitle(),
|
||||
group.isMember(m.getSelfAddress()),
|
||||
group.isMember(m.getSelfRecipientId()),
|
||||
group.isBlocked(),
|
||||
resolveMembers(m, group.getMembers()),
|
||||
resolveMembers(m, group.getPendingMembers()),
|
||||
|
@ -50,7 +51,7 @@ public class ListGroupsCommand implements LocalCommand {
|
|||
writer.println("Id: {} Name: {} Active: {} Blocked: {}",
|
||||
group.getGroupId().toBase64(),
|
||||
group.getTitle(),
|
||||
group.isMember(m.getSelfAddress()),
|
||||
group.isMember(m.getSelfRecipientId()),
|
||||
group.isBlocked());
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +81,7 @@ public class ListGroupsCommand implements LocalCommand {
|
|||
|
||||
jsonGroups.add(new JsonGroup(group.getGroupId().toBase64(),
|
||||
group.getTitle(),
|
||||
group.isMember(m.getSelfAddress()),
|
||||
group.isMember(m.getSelfRecipientId()),
|
||||
group.isBlocked(),
|
||||
resolveMembers(m, group.getMembers()),
|
||||
resolveMembers(m, group.getPendingMembers()),
|
||||
|
|
|
@ -472,7 +472,7 @@ public class DbusSignalImpl implements Signal {
|
|||
if (group == null) {
|
||||
return false;
|
||||
} else {
|
||||
return group.isMember(m.getSelfAddress());
|
||||
return group.isMember(m.getSelfRecipientId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue