mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-07 14:30:38 +00:00
Dbus methods isMember and isAdmin
create isAdmin method in parallel with isMember extend both to have the ability to add or remove members or admins update documentation
This commit is contained in:
parent
217afd74c4
commit
0691a91dad
3 changed files with 185 additions and 13 deletions
|
@ -1083,8 +1083,6 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isRegistered(String number) {
|
||||
if (number.isEmpty()) {
|
||||
|
@ -1260,7 +1258,6 @@ public class DbusSignalImpl implements Signal {
|
|||
DbusSignalControlImpl.verifyWithPin(number, verificationCode, pin);
|
||||
}
|
||||
|
||||
|
||||
// Create a unique list of Numbers from Identities and Contacts to really get
|
||||
// all numbers the system knows
|
||||
@Override
|
||||
|
@ -1447,6 +1444,156 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> isMember(final byte[] groupId, List<String>members, boolean setMemberStatus) {
|
||||
GroupInfo group = null;
|
||||
try {
|
||||
group = m.getGroup(GroupId.unknownVersion(groupId));
|
||||
if (group == null) {
|
||||
throw new Error.GroupNotFound("Error finding group");
|
||||
}
|
||||
if (setMemberStatus) {
|
||||
var results = m.updateGroup(group.getGroupId(),
|
||||
null,
|
||||
null,
|
||||
members,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
} else {
|
||||
var results = m.updateGroup(group.getGroupId(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
members,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
return getGroupMembers(groupId);
|
||||
} catch (NotAGroupMemberException | InvalidNumberException | AssertionError | IOException | AttachmentInvalidException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (GroupNotFoundException e) {
|
||||
throw new Error.GroupNotFound("Group not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> isMember(final String base64GroupId, List<String> members, boolean setMemberStatus) {
|
||||
GroupInfo group = null;
|
||||
byte[] groupId = null;
|
||||
try {
|
||||
groupId = GroupId.fromBase64(base64GroupId).serialize();
|
||||
return isMember(groupId, members, setMemberStatus);
|
||||
} catch (GroupIdFormatException e) {
|
||||
throw new Error.Failure("Incorrect format: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdmin(final byte[] groupId) {
|
||||
GroupInfo group = null;
|
||||
try {
|
||||
group = m.getGroup(GroupId.unknownVersion(groupId));
|
||||
} catch (AssertionError e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
}
|
||||
if (group == null) {
|
||||
throw new Error.GroupNotFound("Error finding group");
|
||||
} else {
|
||||
return group.getAdminMembers().contains(m.getSelfRecipientId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdmin(final String base64GroupId) {
|
||||
GroupInfo group = null;
|
||||
byte[] groupId = null;
|
||||
try {
|
||||
groupId = GroupId.fromBase64(base64GroupId).serialize();
|
||||
} catch (GroupIdFormatException e) {
|
||||
throw new Error.Failure("Incorrect format: " + e.getMessage());
|
||||
}
|
||||
try {
|
||||
group = m.getGroup(GroupId.unknownVersion(groupId));
|
||||
} catch (AssertionError e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
}
|
||||
if (group == null) {
|
||||
throw new Error.GroupNotFound("Error finding group");
|
||||
} else {
|
||||
return group.getAdminMembers().contains(m.getSelfRecipientId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> isAdmin(final byte[] groupId, List<String>admins, boolean setAdminStatus) {
|
||||
GroupInfo group = null;
|
||||
try {
|
||||
group = m.getGroup(GroupId.unknownVersion(groupId));
|
||||
if (group == null) {
|
||||
throw new Error.GroupNotFound("Error finding group");
|
||||
}
|
||||
if (setAdminStatus) {
|
||||
var results = m.updateGroup(group.getGroupId(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
admins,
|
||||
null,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
} else {
|
||||
var results = m.updateGroup(group.getGroupId(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
admins,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
return getGroupAdminMembers(groupId);
|
||||
} catch (NotAGroupMemberException | InvalidNumberException | AssertionError | IOException | AttachmentInvalidException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (GroupNotFoundException e) {
|
||||
throw new Error.GroupNotFound("Group not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> isAdmin(final String base64GroupId, List<String> admins, boolean setAdminStatus) {
|
||||
GroupInfo group = null;
|
||||
byte[] groupId = null;
|
||||
try {
|
||||
groupId = GroupId.fromBase64(base64GroupId).serialize();
|
||||
return isAdmin(groupId, admins, setAdminStatus);
|
||||
} catch (GroupIdFormatException e) {
|
||||
throw new Error.Failure("Incorrect format: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadStickerPack(String stickerPackPath) {
|
||||
File path = new File(stickerPackPath);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue