mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Small improvements
This commit is contained in:
parent
2e4d346bc8
commit
43face8ead
12 changed files with 35 additions and 35 deletions
|
@ -11,11 +11,11 @@ public class Commands {
|
|||
|
||||
static {
|
||||
addCommand(new AddDeviceCommand());
|
||||
addCommand(new GetAttachmentCommand());
|
||||
addCommand(new BlockCommand());
|
||||
addCommand(new DaemonCommand());
|
||||
addCommand(new DeleteLocalAccountDataCommand());
|
||||
addCommand(new FinishLinkCommand());
|
||||
addCommand(new GetAttachmentCommand());
|
||||
addCommand(new GetUserStatusCommand());
|
||||
addCommand(new JoinGroupCommand());
|
||||
addCommand(new JsonRpcDispatcherCommand());
|
||||
|
|
|
@ -26,27 +26,20 @@ public class GetAttachmentCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.addArgument("--id")
|
||||
.required(true)
|
||||
.help("The ID of the attachment file.");
|
||||
var mut = subparser.addMutuallyExclusiveGroup()
|
||||
.required(true);
|
||||
mut.addArgument("--recipient")
|
||||
.help("Sender of the attachment");
|
||||
mut.addArgument("-g", "--group-id")
|
||||
.help("Group in which the attachment was received");
|
||||
subparser.addArgument("--id").required(true).help("The ID of the attachment file.");
|
||||
var mut = subparser.addMutuallyExclusiveGroup().required(true);
|
||||
mut.addArgument("--recipient").help("Sender of the attachment");
|
||||
mut.addArgument("-g", "--group-id").help("Group in which the attachment was received");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
|
||||
final var id = ns.getString("id");
|
||||
|
||||
try(InputStream attachment = m.retrieveAttachment(id)) {
|
||||
try (InputStream attachment = m.retrieveAttachment(id)) {
|
||||
if (outputWriter instanceof PlainTextWriter writer) {
|
||||
final var bytes = attachment.readAllBytes();
|
||||
final var base64 = Base64.getEncoder().encodeToString(bytes);
|
||||
|
|
|
@ -5,5 +5,5 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|||
import java.io.InputStream;
|
||||
|
||||
public record JsonAttachmentData(
|
||||
@JsonSerialize(using=JsonStreamSerializer.class) InputStream data
|
||||
@JsonSerialize(using = JsonStreamSerializer.class) InputStream data
|
||||
) {}
|
||||
|
|
|
@ -43,11 +43,7 @@ record JsonStoryMessage(
|
|||
}
|
||||
|
||||
public record Gradient(
|
||||
String startColor,
|
||||
String endColor,
|
||||
List<String> colors,
|
||||
List<Float> positions,
|
||||
Integer angle
|
||||
String startColor, String endColor, List<String> colors, List<Float> positions, Integer angle
|
||||
) {
|
||||
|
||||
static Gradient from(MessageEnvelope.Story.TextAttachment.Gradient gradient) {
|
||||
|
|
|
@ -11,9 +11,7 @@ public class JsonStreamSerializer extends JsonSerializer<InputStream> {
|
|||
|
||||
@Override
|
||||
public void serialize(
|
||||
final InputStream value,
|
||||
final JsonGenerator jsonGenerator,
|
||||
final SerializerProvider serializers
|
||||
final InputStream value, final JsonGenerator jsonGenerator, final SerializerProvider serializers
|
||||
) throws IOException {
|
||||
jsonGenerator.writeBinary(value, -1);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package org.asamk.signal.util;
|
|||
|
||||
public class Hex {
|
||||
|
||||
private final static char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
private final static char[] HEX_DIGITS = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
|
||||
};
|
||||
|
||||
private Hex() {
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue