mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-09-01 06:28:11 +00:00
* Show and enforce the terminated state of a group A group admin can permanently terminate a group. Afterwards the group is read-only for everyone, not even an admin can send messages or start calls; members keep access to the existing history. Other clients silently drop messages sent to a terminated group. Read the DecryptedGroup.terminated flag through GroupInfo.isTerminated() and: - surface it in listGroups (json and plain text) and as the DBus IsTerminated group property - refuse to send to a terminated group locally (messages, reactions, typing and group stories) rather than send one that other clients ignore - drop incoming messages addressed to a terminated group * Add terminateGroup command to terminate a group for everyone Let a group admin permanently terminate a GroupV2 group via the TerminateGroupAction (Groups.proto field 28, change epoch 7) the pinned library already exposes as GroupsV2Operations.createTerminateGroup(). - GroupV2Helper.terminateGroup builds and commits the change - GroupHelper.terminateGroup resolves/refreshes the group (v2 only), sends the update to members and syncs storage, with the same conflict-retry as updateGroup - exposed through Manager.terminateGroup, the terminateGroup CLI/JSON-RPC command and the DBus Group.terminateGroup method --------- Co-authored-by: FailSpy <FailSpy@users.noreply.github.com>
55 lines
2.0 KiB
Java
55 lines
2.0 KiB
Java
package org.asamk.signal.commands;
|
|
|
|
import net.sourceforge.argparse4j.inf.Namespace;
|
|
import net.sourceforge.argparse4j.inf.Subparser;
|
|
|
|
import org.asamk.signal.commands.exceptions.CommandException;
|
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
|
import org.asamk.signal.manager.Manager;
|
|
import org.asamk.signal.manager.api.GroupNotFoundException;
|
|
import org.asamk.signal.manager.api.NotAGroupMemberException;
|
|
import org.asamk.signal.output.OutputWriter;
|
|
import org.asamk.signal.util.CommandUtil;
|
|
|
|
import java.io.IOException;
|
|
|
|
import static org.asamk.signal.util.SendMessageResultUtils.outputResult;
|
|
|
|
public class TerminateGroupCommand implements JsonRpcLocalCommand {
|
|
|
|
@Override
|
|
public String getName() {
|
|
return "terminateGroup";
|
|
}
|
|
|
|
@Override
|
|
public void attachToSubparser(final Subparser subparser) {
|
|
subparser.help(
|
|
"Permanently terminate a group for all members. Requires admin privileges; afterwards nobody can send messages or start calls.");
|
|
subparser.addArgument("-g", "--group-id", "--group").required(true).help("Specify the group ID.");
|
|
}
|
|
|
|
@Override
|
|
public void handleCommand(
|
|
final Namespace ns,
|
|
final Manager m,
|
|
final OutputWriter outputWriter
|
|
) throws CommandException {
|
|
final var groupId = CommandUtil.getGroupId(ns.getString("group-id"));
|
|
|
|
try {
|
|
final var results = m.terminateGroup(groupId);
|
|
outputResult(outputWriter, results);
|
|
} catch (IOException e) {
|
|
throw new IOErrorException("Failed to send message: "
|
|
+ e.getMessage()
|
|
+ " ("
|
|
+ e.getClass().getSimpleName()
|
|
+ ")", e);
|
|
} catch (GroupNotFoundException | NotAGroupMemberException e) {
|
|
throw new UserErrorException("Failed to terminate group: " + e.getMessage());
|
|
}
|
|
}
|
|
}
|