mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Restrict blocking of group to master device
This commit is contained in:
parent
e977f38bdd
commit
997b3c6a2a
5 changed files with 13 additions and 2 deletions
|
@ -184,7 +184,7 @@ public interface Manager extends Closeable {
|
||||||
|
|
||||||
void setGroupBlocked(
|
void setGroupBlocked(
|
||||||
GroupId groupId, boolean blocked
|
GroupId groupId, boolean blocked
|
||||||
) throws GroupNotFoundException, IOException;
|
) throws GroupNotFoundException, IOException, NotMasterDeviceException;
|
||||||
|
|
||||||
void setExpirationTimer(
|
void setExpirationTimer(
|
||||||
RecipientIdentifier.Single recipient, int messageExpirationTimer
|
RecipientIdentifier.Single recipient, int messageExpirationTimer
|
||||||
|
|
|
@ -714,7 +714,10 @@ public class ManagerImpl implements Manager {
|
||||||
@Override
|
@Override
|
||||||
public void setGroupBlocked(
|
public void setGroupBlocked(
|
||||||
final GroupId groupId, final boolean blocked
|
final GroupId groupId, final boolean blocked
|
||||||
) throws GroupNotFoundException, IOException {
|
) throws GroupNotFoundException, IOException, NotMasterDeviceException {
|
||||||
|
if (!account.isMasterDevice()) {
|
||||||
|
throw new NotMasterDeviceException();
|
||||||
|
}
|
||||||
groupHelper.setGroupBlocked(groupId, blocked);
|
groupHelper.setGroupBlocked(groupId, blocked);
|
||||||
// TODO cycle our profile key
|
// TODO cycle our profile key
|
||||||
syncHelper.sendBlockedList();
|
syncHelper.sendBlockedList();
|
||||||
|
|
|
@ -52,6 +52,8 @@ public class BlockCommand implements JsonRpcLocalCommand {
|
||||||
for (var groupId : CommandUtil.getGroupIds(groupIdStrings)) {
|
for (var groupId : CommandUtil.getGroupIds(groupIdStrings)) {
|
||||||
try {
|
try {
|
||||||
m.setGroupBlocked(groupId, true);
|
m.setGroupBlocked(groupId, true);
|
||||||
|
} catch (NotMasterDeviceException e) {
|
||||||
|
throw new UserErrorException("This command doesn't work on linked devices.");
|
||||||
} catch (GroupNotFoundException e) {
|
} catch (GroupNotFoundException e) {
|
||||||
logger.warn("Group not found {}: {}", groupId.toBase64(), e.getMessage());
|
logger.warn("Group not found {}: {}", groupId.toBase64(), e.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -51,6 +51,8 @@ public class UnblockCommand implements JsonRpcLocalCommand {
|
||||||
for (var groupId : CommandUtil.getGroupIds(groupIdStrings)) {
|
for (var groupId : CommandUtil.getGroupIds(groupIdStrings)) {
|
||||||
try {
|
try {
|
||||||
m.setGroupBlocked(groupId, false);
|
m.setGroupBlocked(groupId, false);
|
||||||
|
} catch (NotMasterDeviceException e) {
|
||||||
|
throw new UserErrorException("This command doesn't work on linked devices.");
|
||||||
} catch (GroupNotFoundException e) {
|
} catch (GroupNotFoundException e) {
|
||||||
logger.warn("Unknown group id: {}", groupId);
|
logger.warn("Unknown group id: {}", groupId);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -405,6 +405,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
public void setGroupBlocked(final byte[] groupId, final boolean blocked) {
|
public void setGroupBlocked(final byte[] groupId, final boolean blocked) {
|
||||||
try {
|
try {
|
||||||
m.setGroupBlocked(getGroupId(groupId), blocked);
|
m.setGroupBlocked(getGroupId(groupId), blocked);
|
||||||
|
} catch (NotMasterDeviceException e) {
|
||||||
|
throw new Error.Failure("This command doesn't work on linked devices.");
|
||||||
} catch (GroupNotFoundException e) {
|
} catch (GroupNotFoundException e) {
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
throw new Error.GroupNotFound(e.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -1060,6 +1062,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
private void setIsBlocked(final boolean isBlocked) {
|
private void setIsBlocked(final boolean isBlocked) {
|
||||||
try {
|
try {
|
||||||
m.setGroupBlocked(groupId, isBlocked);
|
m.setGroupBlocked(groupId, isBlocked);
|
||||||
|
} catch (NotMasterDeviceException e) {
|
||||||
|
throw new Error.Failure("This command doesn't work on linked devices.");
|
||||||
} catch (GroupNotFoundException e) {
|
} catch (GroupNotFoundException e) {
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
throw new Error.GroupNotFound(e.getMessage());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue