mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Reformat files
This commit is contained in:
parent
3533500b73
commit
f2005593ec
148 changed files with 1056 additions and 578 deletions
|
@ -27,39 +27,44 @@ public interface Signal extends DBusInterface {
|
|||
void unsubscribeReceive();
|
||||
|
||||
long sendMessage(
|
||||
String message, List<String> attachments, String recipient
|
||||
String message,
|
||||
List<String> attachments,
|
||||
String recipient
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||
|
||||
long sendMessage(
|
||||
String message, List<String> attachments, List<String> recipients
|
||||
String message,
|
||||
List<String> attachments,
|
||||
List<String> recipients
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||
|
||||
void sendTyping(
|
||||
String recipient, boolean stop
|
||||
) throws Error.Failure, Error.UntrustedIdentity;
|
||||
void sendTyping(String recipient, boolean stop) throws Error.Failure, Error.UntrustedIdentity;
|
||||
|
||||
void sendReadReceipt(
|
||||
String recipient, List<Long> messageIds
|
||||
) throws Error.Failure, Error.UntrustedIdentity;
|
||||
void sendReadReceipt(String recipient, List<Long> messageIds) throws Error.Failure, Error.UntrustedIdentity;
|
||||
|
||||
void sendViewedReceipt(
|
||||
String recipient, List<Long> messageIds
|
||||
) throws Error.Failure, Error.UntrustedIdentity;
|
||||
void sendViewedReceipt(String recipient, List<Long> messageIds) throws Error.Failure, Error.UntrustedIdentity;
|
||||
|
||||
long sendRemoteDeleteMessage(long targetSentTimestamp, String recipient) throws Error.Failure, Error.InvalidNumber;
|
||||
|
||||
long sendRemoteDeleteMessage(
|
||||
long targetSentTimestamp, String recipient
|
||||
) throws Error.Failure, Error.InvalidNumber;
|
||||
|
||||
long sendRemoteDeleteMessage(
|
||||
long targetSentTimestamp, List<String> recipients
|
||||
long targetSentTimestamp,
|
||||
List<String> recipients
|
||||
) throws Error.Failure, Error.InvalidNumber;
|
||||
|
||||
long sendMessageReaction(
|
||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, String recipient
|
||||
String emoji,
|
||||
boolean remove,
|
||||
String targetAuthor,
|
||||
long targetSentTimestamp,
|
||||
String recipient
|
||||
) throws Error.InvalidNumber, Error.Failure;
|
||||
|
||||
long sendMessageReaction(
|
||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
|
||||
String emoji,
|
||||
boolean remove,
|
||||
String targetAuthor,
|
||||
long targetSentTimestamp,
|
||||
List<String> recipients
|
||||
) throws Error.InvalidNumber, Error.Failure;
|
||||
|
||||
long sendPaymentNotification(byte[] receipt, String note, String recipient) throws Error.Failure;
|
||||
|
@ -68,9 +73,7 @@ public interface Signal extends DBusInterface {
|
|||
|
||||
void sendSyncRequest() throws Error.Failure;
|
||||
|
||||
long sendNoteToSelfMessage(
|
||||
String message, List<String> attachments
|
||||
) throws Error.AttachmentInvalid, Error.Failure;
|
||||
long sendNoteToSelfMessage(String message, List<String> attachments) throws Error.AttachmentInvalid, Error.Failure;
|
||||
|
||||
void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||
|
||||
|
@ -79,19 +82,27 @@ public interface Signal extends DBusInterface {
|
|||
void deleteContact(final String recipient) throws Error.Failure;
|
||||
|
||||
long sendGroupMessage(
|
||||
String message, List<String> attachments, byte[] groupId
|
||||
String message,
|
||||
List<String> attachments,
|
||||
byte[] groupId
|
||||
) throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId;
|
||||
|
||||
void sendGroupTyping(
|
||||
final byte[] groupId, final boolean stop
|
||||
final byte[] groupId,
|
||||
final boolean stop
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
|
||||
|
||||
long sendGroupRemoteDeleteMessage(
|
||||
long targetSentTimestamp, byte[] groupId
|
||||
long targetSentTimestamp,
|
||||
byte[] groupId
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
|
||||
|
||||
long sendGroupMessageReaction(
|
||||
String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, byte[] groupId
|
||||
String emoji,
|
||||
boolean remove,
|
||||
String targetAuthor,
|
||||
long targetSentTimestamp,
|
||||
byte[] groupId
|
||||
) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
|
||||
|
||||
String getContactName(String number) throws Error.InvalidNumber;
|
||||
|
@ -119,12 +130,17 @@ public interface Signal extends DBusInterface {
|
|||
List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
|
||||
|
||||
byte[] createGroup(
|
||||
String name, List<String> members, String avatar
|
||||
String name,
|
||||
List<String> members,
|
||||
String avatar
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber;
|
||||
|
||||
@Deprecated
|
||||
byte[] updateGroup(
|
||||
byte[] groupId, String name, List<String> members, String avatar
|
||||
byte[] groupId,
|
||||
String name,
|
||||
List<String> members,
|
||||
String avatar
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
|
||||
|
||||
@Deprecated
|
||||
|
@ -156,7 +172,11 @@ public interface Signal extends DBusInterface {
|
|||
) throws Error.Failure;
|
||||
|
||||
void updateProfile(
|
||||
String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
|
||||
String name,
|
||||
String about,
|
||||
String aboutEmoji,
|
||||
String avatarPath,
|
||||
boolean removeAvatar
|
||||
) throws Error.Failure;
|
||||
|
||||
void removePin();
|
||||
|
|
|
@ -13,11 +13,14 @@ import java.util.List;
|
|||
public interface SignalControl extends DBusInterface {
|
||||
|
||||
void register(
|
||||
String number, boolean voiceVerification
|
||||
String number,
|
||||
boolean voiceVerification
|
||||
) throws Error.Failure, Error.InvalidNumber, Error.RequiresCaptcha;
|
||||
|
||||
void registerWithCaptcha(
|
||||
String number, boolean voiceVerification, String captcha
|
||||
String number,
|
||||
boolean voiceVerification,
|
||||
String captcha
|
||||
) throws Error.Failure, Error.InvalidNumber, Error.RequiresCaptcha;
|
||||
|
||||
void verify(String number, String verificationCode) throws Error.Failure, Error.InvalidNumber;
|
||||
|
|
|
@ -292,7 +292,8 @@ public class App {
|
|||
}
|
||||
|
||||
private RegistrationManager loadRegistrationManager(
|
||||
final String account, final SignalAccountFiles signalAccountFiles
|
||||
final String account,
|
||||
final SignalAccountFiles signalAccountFiles
|
||||
) throws UnexpectedErrorException {
|
||||
try {
|
||||
return signalAccountFiles.initRegistrationManager(account);
|
||||
|
@ -306,7 +307,8 @@ public class App {
|
|||
}
|
||||
|
||||
private Manager loadManager(
|
||||
final String account, final SignalAccountFiles signalAccountFiles
|
||||
final String account,
|
||||
final SignalAccountFiles signalAccountFiles
|
||||
) throws CommandException {
|
||||
logger.trace("Loading account file for {}", account);
|
||||
try {
|
||||
|
|
|
@ -101,9 +101,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
writer.println();
|
||||
}
|
||||
|
||||
private void printDataMessage(
|
||||
PlainTextWriter writer, MessageEnvelope.Data message
|
||||
) {
|
||||
private void printDataMessage(PlainTextWriter writer, MessageEnvelope.Data message) {
|
||||
writer.println("Message timestamp: {}", DateUtils.formatTimestamp(message.timestamp()));
|
||||
if (message.isViewOnce()) {
|
||||
writer.println("=VIEW ONCE=");
|
||||
|
@ -197,16 +195,12 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void printEditMessage(
|
||||
PlainTextWriter writer, MessageEnvelope.Edit message
|
||||
) {
|
||||
private void printEditMessage(PlainTextWriter writer, MessageEnvelope.Edit message) {
|
||||
writer.println("Edit: Target message timestamp: {}", DateUtils.formatTimestamp(message.targetSentTimestamp()));
|
||||
printDataMessage(writer.indentedWriter(), message.dataMessage());
|
||||
}
|
||||
|
||||
private void printStoryMessage(
|
||||
PlainTextWriter writer, MessageEnvelope.Story message
|
||||
) {
|
||||
private void printStoryMessage(PlainTextWriter writer, MessageEnvelope.Story message) {
|
||||
writer.println("Story: with replies: {}", message.allowsReplies());
|
||||
if (message.groupId().isPresent()) {
|
||||
writer.println("Group info:");
|
||||
|
@ -226,9 +220,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void printTypingMessage(
|
||||
final PlainTextWriter writer, final MessageEnvelope.Typing typingMessage
|
||||
) {
|
||||
private void printTypingMessage(final PlainTextWriter writer, final MessageEnvelope.Typing typingMessage) {
|
||||
writer.println("Action: {}", typingMessage.type());
|
||||
writer.println("Timestamp: {}", DateUtils.formatTimestamp(typingMessage.timestamp()));
|
||||
if (typingMessage.groupId().isPresent()) {
|
||||
|
@ -238,9 +230,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void printReceiptMessage(
|
||||
final PlainTextWriter writer, final MessageEnvelope.Receipt receiptMessage
|
||||
) {
|
||||
private void printReceiptMessage(final PlainTextWriter writer, final MessageEnvelope.Receipt receiptMessage) {
|
||||
writer.println("When: {}", DateUtils.formatTimestamp(receiptMessage.when()));
|
||||
if (receiptMessage.type() == MessageEnvelope.Receipt.Type.DELIVERY) {
|
||||
writer.println("Is delivery receipt");
|
||||
|
@ -257,9 +247,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void printCallMessage(
|
||||
final PlainTextWriter writer, final MessageEnvelope.Call callMessage
|
||||
) {
|
||||
private void printCallMessage(final PlainTextWriter writer, final MessageEnvelope.Call callMessage) {
|
||||
if (callMessage.destinationDeviceId().isPresent()) {
|
||||
final var deviceId = callMessage.destinationDeviceId().get();
|
||||
writer.println("Destination device id: {}", deviceId);
|
||||
|
@ -302,9 +290,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void printSyncMessage(
|
||||
final PlainTextWriter writer, final MessageEnvelope.Sync syncMessage
|
||||
) {
|
||||
private void printSyncMessage(final PlainTextWriter writer, final MessageEnvelope.Sync syncMessage) {
|
||||
if (syncMessage.contacts().isPresent()) {
|
||||
final var contactsMessage = syncMessage.contacts().get();
|
||||
var type = contactsMessage.isComplete() ? "complete" : "partial";
|
||||
|
@ -392,9 +378,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void printPreview(
|
||||
final PlainTextWriter writer, final MessageEnvelope.Data.Preview preview
|
||||
) {
|
||||
private void printPreview(final PlainTextWriter writer, final MessageEnvelope.Data.Preview preview) {
|
||||
writer.println("Title: {}", preview.title());
|
||||
writer.println("Description: {}", preview.description());
|
||||
writer.println("Date: {}", DateUtils.formatTimestamp(preview.date()));
|
||||
|
@ -405,25 +389,19 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void printSticker(
|
||||
final PlainTextWriter writer, final MessageEnvelope.Data.Sticker sticker
|
||||
) {
|
||||
private void printSticker(final PlainTextWriter writer, final MessageEnvelope.Data.Sticker sticker) {
|
||||
writer.println("Pack id: {}", Hex.toStringCondensed(sticker.packId().serialize()));
|
||||
writer.println("Sticker id: {}", sticker.stickerId());
|
||||
}
|
||||
|
||||
private void printReaction(
|
||||
final PlainTextWriter writer, final MessageEnvelope.Data.Reaction reaction
|
||||
) {
|
||||
private void printReaction(final PlainTextWriter writer, final MessageEnvelope.Data.Reaction reaction) {
|
||||
writer.println("Emoji: {}", reaction.emoji());
|
||||
writer.println("Target author: {}", formatContact(reaction.targetAuthor()));
|
||||
writer.println("Target timestamp: {}", DateUtils.formatTimestamp(reaction.targetSentTimestamp()));
|
||||
writer.println("Is remove: {}", reaction.isRemove());
|
||||
}
|
||||
|
||||
private void printQuote(
|
||||
final PlainTextWriter writer, final MessageEnvelope.Data.Quote quote
|
||||
) {
|
||||
private void printQuote(final PlainTextWriter writer, final MessageEnvelope.Data.Quote quote) {
|
||||
writer.println("Id: {}", quote.id());
|
||||
writer.println("Author: {}", formatContact(quote.author()));
|
||||
if (quote.text().isPresent()) {
|
||||
|
@ -541,17 +519,13 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void printGroupContext(
|
||||
final PlainTextWriter writer, final MessageEnvelope.Data.GroupContext groupContext
|
||||
) {
|
||||
private void printGroupContext(final PlainTextWriter writer, final MessageEnvelope.Data.GroupContext groupContext) {
|
||||
printGroupInfo(writer, groupContext.groupId());
|
||||
writer.println("Revision: {}", groupContext.revision());
|
||||
writer.println("Type: {}", groupContext.isGroupUpdate() ? "UPDATE" : "DELIVER");
|
||||
}
|
||||
|
||||
private void printStoryContext(
|
||||
final PlainTextWriter writer, final MessageEnvelope.Data.StoryContext storyContext
|
||||
) {
|
||||
private void printStoryContext(final PlainTextWriter writer, final MessageEnvelope.Data.StoryContext storyContext) {
|
||||
writer.println("Sender: {}", formatContact(storyContext.author()));
|
||||
writer.println("Sent timestamp: {}", storyContext.sentTimestamp());
|
||||
}
|
||||
|
@ -567,15 +541,11 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void printMention(
|
||||
PlainTextWriter writer, MessageEnvelope.Data.Mention mention
|
||||
) {
|
||||
private void printMention(PlainTextWriter writer, MessageEnvelope.Data.Mention mention) {
|
||||
writer.println("- {}: {} (length: {})", formatContact(mention.recipient()), mention.start(), mention.length());
|
||||
}
|
||||
|
||||
private void printTextStyle(
|
||||
PlainTextWriter writer, TextStyle textStyle
|
||||
) {
|
||||
private void printTextStyle(PlainTextWriter writer, TextStyle textStyle) {
|
||||
writer.println("- {}: {} (length: {})", textStyle.style().name(), textStyle.start(), textStyle.length());
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,9 @@ public class AddDeviceCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 URI linkUri;
|
||||
try {
|
||||
|
|
|
@ -36,7 +36,9 @@ public class AddStickerPackCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 uris = ns.<String>getList("uri");
|
||||
for (final var uri : uris) {
|
||||
|
|
|
@ -35,7 +35,9 @@ public class BlockCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 contacts = ns.<String>getList("recipient");
|
||||
final var recipients = CommandUtil.getSingleRecipientIdentifiers(contacts, m.getSelfNumber());
|
||||
|
|
|
@ -20,13 +20,15 @@ public class CommandHandler {
|
|||
}
|
||||
|
||||
public void handleProvisioningCommand(
|
||||
final ProvisioningCommand command, final ProvisioningManager provisioningManager
|
||||
final ProvisioningCommand command,
|
||||
final ProvisioningManager provisioningManager
|
||||
) throws CommandException {
|
||||
command.handleCommand(ns, provisioningManager, outputWriter);
|
||||
}
|
||||
|
||||
public void handleRegistrationCommand(
|
||||
final RegistrationCommand command, final RegistrationManager registrationManager
|
||||
final RegistrationCommand command,
|
||||
final RegistrationManager registrationManager
|
||||
) throws CommandException {
|
||||
command.handleCommand(ns, registrationManager);
|
||||
}
|
||||
|
@ -36,7 +38,8 @@ public class CommandHandler {
|
|||
}
|
||||
|
||||
public void handleMultiLocalCommand(
|
||||
final MultiLocalCommand command, MultiAccountManager multiAccountManager
|
||||
final MultiLocalCommand command,
|
||||
MultiAccountManager multiAccountManager
|
||||
) throws CommandException {
|
||||
command.handleCommand(ns, multiAccountManager, outputWriter);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,9 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
Shutdown.installHandler();
|
||||
logger.info("Starting daemon in single-account mode for " + m.getSelfNumber());
|
||||
|
@ -117,7 +119,9 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final MultiAccountManager c,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
Shutdown.installHandler();
|
||||
logger.info("Starting daemon in multi-account mode");
|
||||
|
|
|
@ -60,7 +60,9 @@ public class DeleteLocalAccountDataCommand implements RegistrationCommand, JsonR
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
Map<String, Object> request, RegistrationManager m, JsonWriter jsonWriter
|
||||
Map<String, Object> request,
|
||||
RegistrationManager m,
|
||||
JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
|
||||
handleCommand(commandNamespace, m);
|
||||
|
|
|
@ -33,7 +33,9 @@ public class FinishChangeNumberCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 newNumber = ns.getString("number");
|
||||
final var verificationCode = ns.getString("verification-code");
|
||||
|
|
|
@ -32,7 +32,9 @@ public class FinishLinkCommand implements JsonRpcMultiCommand<FinishLinkCommand.
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final FinishLinkParams request, final MultiAccountManager m, final JsonWriter jsonWriter
|
||||
final FinishLinkParams request,
|
||||
final MultiAccountManager m,
|
||||
final JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
if (request.deviceLinkUri() == null) {
|
||||
throw new UserErrorException("Missing deviceLinkUri.");
|
||||
|
|
|
@ -35,7 +35,9 @@ public class GetAttachmentCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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");
|
||||
|
|
|
@ -37,7 +37,9 @@ public class GetAvatarCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 contactRecipient = ns.getString("contact");
|
||||
final var profileRecipient = ns.getString("profile");
|
||||
|
|
|
@ -35,7 +35,9 @@ public class GetStickerCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 packId = StickerPackId.deserialize(Hex.toByteArray(ns.getString("pack-id")));
|
||||
|
|
|
@ -43,7 +43,9 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
// Get a map of registration statuses
|
||||
Map<String, UserStatus> registered;
|
||||
|
|
|
@ -33,7 +33,9 @@ public class JoinGroupCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 GroupInviteLinkUrl linkUrl;
|
||||
var uri = ns.getString("uri");
|
||||
|
|
|
@ -59,7 +59,9 @@ public class JsonRpcDispatcherCommand implements LocalCommand, MultiLocalCommand
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
Shutdown.installHandler();
|
||||
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
|
||||
|
@ -79,7 +81,9 @@ public class JsonRpcDispatcherCommand implements LocalCommand, MultiLocalCommand
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final MultiAccountManager c,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
Shutdown.installHandler();
|
||||
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
|
||||
|
|
|
@ -18,9 +18,7 @@ public interface JsonRpcLocalCommand extends JsonRpcSingleCommand<Map<String, Ob
|
|||
return new TypeReference<>() {};
|
||||
}
|
||||
|
||||
default void handleCommand(
|
||||
Map<String, Object> request, Manager m, JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
default void handleCommand(Map<String, Object> request, Manager m, JsonWriter jsonWriter) throws CommandException {
|
||||
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
|
||||
handleCommand(commandNamespace, m, jsonWriter);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ public interface JsonRpcMultiLocalCommand extends JsonRpcMultiCommand<Map<String
|
|||
}
|
||||
|
||||
default void handleCommand(
|
||||
Map<String, Object> request, MultiAccountManager c, JsonWriter jsonWriter
|
||||
Map<String, Object> request,
|
||||
MultiAccountManager c,
|
||||
JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
|
||||
handleCommand(commandNamespace, c, jsonWriter);
|
||||
|
|
|
@ -33,7 +33,9 @@ public class LinkCommand implements ProvisioningCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final ProvisioningManager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final ProvisioningManager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
final var writer = (PlainTextWriter) outputWriter;
|
||||
|
||||
|
|
|
@ -23,7 +23,9 @@ public class ListAccountsCommand implements JsonRpcMultiLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final MultiAccountManager c,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
final var accountNumbers = c.getAccountNumbers();
|
||||
switch (outputWriter) {
|
||||
|
|
|
@ -47,7 +47,9 @@ public class ListContactsCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 allRecipients = Boolean.TRUE.equals(ns.getBoolean("all-recipients"));
|
||||
final var blocked = ns.getBoolean("blocked");
|
||||
|
|
|
@ -33,7 +33,9 @@ public class ListDevicesCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
List<Device> devices;
|
||||
try {
|
||||
|
|
|
@ -48,9 +48,7 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
|
|||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private static void printGroupPlainText(
|
||||
PlainTextWriter writer, Group group, boolean detailed
|
||||
) {
|
||||
private static void printGroupPlainText(PlainTextWriter writer, Group group, boolean detailed) {
|
||||
if (detailed) {
|
||||
final var groupInviteLink = group.groupInviteLinkUrl();
|
||||
|
||||
|
@ -79,7 +77,9 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
var groups = m.getGroups();
|
||||
|
||||
|
|
|
@ -46,7 +46,9 @@ public class ListIdentitiesCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
var number = ns.getString("number");
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@ public class ListStickerPacksCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager c, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager c,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
final var stickerPacks = c.getStickerPacks();
|
||||
switch (outputWriter) {
|
||||
|
|
|
@ -44,7 +44,9 @@ public class QuitGroupCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 groupId = CommandUtil.getGroupId(ns.getString("group-id"));
|
||||
|
||||
|
|
|
@ -66,7 +66,9 @@ public class ReceiveCommand implements LocalCommand, JsonRpcSingleCommand<Receiv
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
Shutdown.installHandler();
|
||||
final var timeout = ns.getDouble("timeout");
|
||||
|
@ -98,7 +100,9 @@ public class ReceiveCommand implements LocalCommand, JsonRpcSingleCommand<Receiv
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final ReceiveParams request, final Manager m, final JsonWriter jsonWriter
|
||||
final ReceiveParams request,
|
||||
final Manager m,
|
||||
final JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
final var timeout = request.timeout() == null ? 3.0 : request.timeout();
|
||||
final var maxMessagesRaw = request.maxMessages() == null ? -1 : request.maxMessages();
|
||||
|
|
|
@ -63,13 +63,18 @@ public class RegisterCommand implements RegistrationCommand, JsonRpcRegistration
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final RegistrationParams request, final RegistrationManager m, final JsonWriter jsonWriter
|
||||
final RegistrationParams request,
|
||||
final RegistrationManager m,
|
||||
final JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
register(m, Boolean.TRUE.equals(request.voice()), request.captcha(), Boolean.TRUE.equals(request.reregister()));
|
||||
}
|
||||
|
||||
private void register(
|
||||
final RegistrationManager m, final boolean voiceVerification, final String captcha, final boolean reregister
|
||||
final RegistrationManager m,
|
||||
final boolean voiceVerification,
|
||||
final String captcha,
|
||||
final boolean reregister
|
||||
) throws CommandException {
|
||||
try {
|
||||
m.register(voiceVerification, captcha, reregister);
|
||||
|
|
|
@ -40,7 +40,9 @@ public class RemoteDeleteCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
|
||||
final var recipientStrings = ns.<String>getList("recipient");
|
||||
|
|
|
@ -31,7 +31,9 @@ public class RemoveContactCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
var recipientString = ns.getString("recipient");
|
||||
var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
|
||||
|
|
|
@ -30,7 +30,9 @@ public class RemoveDeviceCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
try {
|
||||
final var deviceId = ns.getInt("device-id");
|
||||
|
|
|
@ -27,7 +27,9 @@ public class RemovePinCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
try {
|
||||
m.setRegistrationLockPin(Optional.empty());
|
||||
|
|
|
@ -108,7 +108,9 @@ public class SendCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 notifySelf = Boolean.TRUE.equals(ns.getBoolean("notify-self"));
|
||||
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
|
||||
|
@ -257,7 +259,8 @@ public class SendCommand implements JsonRpcLocalCommand {
|
|||
}
|
||||
|
||||
private List<Message.Mention> parseMentions(
|
||||
final String selfNumber, final List<String> mentionStrings
|
||||
final String selfNumber,
|
||||
final List<String> mentionStrings
|
||||
) throws UserErrorException {
|
||||
final var mentionPattern = Pattern.compile("(\\d+):(\\d+):(.+)");
|
||||
final var mentions = new ArrayList<Message.Mention>();
|
||||
|
|
|
@ -24,7 +24,9 @@ public class SendContactsCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
try {
|
||||
m.sendContacts();
|
||||
|
|
|
@ -31,7 +31,9 @@ public class SendMessageRequestResponseCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 recipientStrings = ns.<String>getList("recipient");
|
||||
final var groupIdStrings = ns.<String>getList("group-id");
|
||||
|
|
|
@ -31,7 +31,9 @@ public class SendPaymentNotificationCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 recipientString = ns.getString("recipient");
|
||||
final var recipientIdentifier = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
|
||||
|
|
|
@ -53,7 +53,9 @@ public class SendReactionCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
|
||||
final var recipientStrings = ns.<String>getList("recipient");
|
||||
|
|
|
@ -35,7 +35,9 @@ public class SendReceiptCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 recipientString = ns.getString("recipient");
|
||||
final var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
|
||||
|
|
|
@ -24,7 +24,9 @@ public class SendSyncRequestCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
try {
|
||||
m.requestAllSyncData();
|
||||
|
|
|
@ -38,7 +38,9 @@ public class SendTypingCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 recipientStrings = ns.<String>getList("recipient");
|
||||
final var groupIdStrings = ns.<String>getList("group-id");
|
||||
|
|
|
@ -29,7 +29,9 @@ public class SetPinCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
try {
|
||||
var registrationLockPin = ns.getString("pin");
|
||||
|
|
|
@ -39,7 +39,9 @@ public class StartChangeNumberCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 newNumber = ns.getString("number");
|
||||
final var voiceVerification = Boolean.TRUE.equals(ns.getBoolean("voice"));
|
||||
|
|
|
@ -23,7 +23,9 @@ public class StartLinkCommand implements JsonRpcMultiCommand<Void> {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Void request, final MultiAccountManager m, final JsonWriter jsonWriter
|
||||
final Void request,
|
||||
final MultiAccountManager m,
|
||||
final JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
final URI deviceLinkUri;
|
||||
try {
|
||||
|
|
|
@ -33,7 +33,9 @@ public class TrustCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
var recipientString = ns.getString("recipient");
|
||||
var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
|
||||
|
|
|
@ -35,7 +35,9 @@ public class UnblockCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 contacts = ns.<String>getList("recipient");
|
||||
final var recipients = CommandUtil.getSingleRecipientIdentifiers(contacts, m.getSelfNumber());
|
||||
|
|
|
@ -28,7 +28,9 @@ public class UnregisterCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
try {
|
||||
if (Boolean.TRUE.equals(ns.getBoolean("delete-account"))) {
|
||||
|
|
|
@ -47,7 +47,9 @@ public class UpdateAccountCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 deviceName = ns.getString("device-name");
|
||||
final var unrestrictedUnidentifiedSender = ns.getBoolean("unrestricted-unidentified-sender");
|
||||
|
|
|
@ -38,7 +38,9 @@ public class UpdateConfigurationCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 readReceipts = ns.getBoolean("read-receipts");
|
||||
final var unidentifiedDeliveryIndicators = ns.getBoolean("unidentified-delivery-indicators");
|
||||
|
|
|
@ -33,7 +33,9 @@ public class UpdateContactCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
var recipientString = ns.getString("recipient");
|
||||
var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
|
||||
|
|
|
@ -102,7 +102,9 @@ public class UpdateGroupCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 groupIdString = ns.getString("group-id");
|
||||
var groupId = CommandUtil.getGroupId(groupIdString);
|
||||
|
@ -180,7 +182,9 @@ public class UpdateGroupCommand implements JsonRpcLocalCommand {
|
|||
}
|
||||
|
||||
private void outputResult(
|
||||
final OutputWriter outputWriter, final SendGroupMessageResults results, final GroupId groupId
|
||||
final OutputWriter outputWriter,
|
||||
final SendGroupMessageResults results,
|
||||
final GroupId groupId
|
||||
) {
|
||||
switch (outputWriter) {
|
||||
case PlainTextWriter writer -> {
|
||||
|
|
|
@ -36,7 +36,9 @@ public class UpdateProfileCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
var givenName = ns.getString("given-name");
|
||||
var familyName = ns.getString("family-name");
|
||||
|
|
|
@ -36,7 +36,9 @@ public class UploadStickerPackCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
var path = new File(ns.getString("path"));
|
||||
|
||||
|
|
|
@ -55,13 +55,17 @@ public class VerifyCommand implements RegistrationCommand, JsonRpcRegistrationCo
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final VerifyParams request, final RegistrationManager m, final JsonWriter jsonWriter
|
||||
final VerifyParams request,
|
||||
final RegistrationManager m,
|
||||
final JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
verify(m, request.verificationCode(), request.pin());
|
||||
}
|
||||
|
||||
private void verify(
|
||||
final RegistrationManager m, final String verificationCode, final String pin
|
||||
final RegistrationManager m,
|
||||
final String verificationCode,
|
||||
final String pin
|
||||
) throws UserErrorException, IOErrorException {
|
||||
try {
|
||||
m.verifyAccount(verificationCode, pin);
|
||||
|
|
|
@ -35,14 +35,18 @@ public class VersionCommand implements JsonRpcLocalCommand, JsonRpcMultiLocalCom
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final Manager m,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
outputVersion(outputWriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
|
||||
final Namespace ns,
|
||||
final MultiAccountManager c,
|
||||
final OutputWriter outputWriter
|
||||
) throws CommandException {
|
||||
outputVersion(outputWriter);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,8 @@ public class DbusCommandHandler {
|
|||
}
|
||||
|
||||
private static String tryGetSingleAccountObjectPath(
|
||||
final DBusConnection dBusConn, final String busname
|
||||
final DBusConnection dBusConn,
|
||||
final String busname
|
||||
) throws DBusException, CommandException {
|
||||
var control = dBusConn.getRemoteObject(busname, DbusConfig.getObjectPath(), SignalControl.class);
|
||||
try {
|
||||
|
|
|
@ -28,7 +28,10 @@ public class DbusHandler implements AutoCloseable {
|
|||
private final boolean noReceiveOnStart;
|
||||
|
||||
public DbusHandler(
|
||||
final boolean isDbusSystem, final String busname, final Manager m, final boolean noReceiveOnStart
|
||||
final boolean isDbusSystem,
|
||||
final String busname,
|
||||
final Manager m,
|
||||
final boolean noReceiveOnStart
|
||||
) {
|
||||
this.isDbusSystem = isDbusSystem;
|
||||
this.dbusRunner = (connection) -> {
|
||||
|
|
|
@ -12,9 +12,7 @@ public class DbusInterfacePropertiesHandler {
|
|||
private final String interfaceName;
|
||||
private final List<DbusProperty<?>> properties;
|
||||
|
||||
public DbusInterfacePropertiesHandler(
|
||||
final String interfaceName, final List<DbusProperty<?>> properties
|
||||
) {
|
||||
public DbusInterfacePropertiesHandler(final String interfaceName, final List<DbusProperty<?>> properties) {
|
||||
this.interfaceName = interfaceName;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
|
|
@ -201,14 +201,18 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public void startChangeNumber(
|
||||
final String newNumber, final boolean voiceVerification, final String captcha
|
||||
final String newNumber,
|
||||
final boolean voiceVerification,
|
||||
final String captcha
|
||||
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishChangeNumber(
|
||||
final String newNumber, final String verificationCode, final String pin
|
||||
final String newNumber,
|
||||
final String verificationCode,
|
||||
final String pin
|
||||
) throws IncorrectPinException, PinLockedException, IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
@ -270,7 +274,8 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public SendGroupMessageResults quitGroup(
|
||||
final GroupId groupId, final Set<RecipientIdentifier.Single> groupAdmins
|
||||
final GroupId groupId,
|
||||
final Set<RecipientIdentifier.Single> groupAdmins
|
||||
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException {
|
||||
if (!groupAdmins.isEmpty()) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -296,7 +301,9 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public Pair<GroupId, SendGroupMessageResults> createGroup(
|
||||
final String name, final Set<RecipientIdentifier.Single> members, final String avatarFile
|
||||
final String name,
|
||||
final Set<RecipientIdentifier.Single> members,
|
||||
final String avatarFile
|
||||
) throws IOException, AttachmentInvalidException {
|
||||
final var newGroupId = signal.createGroup(emptyIfNull(name),
|
||||
members.stream().map(RecipientIdentifier.Single::getIdentifier).toList(),
|
||||
|
@ -306,7 +313,8 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public SendGroupMessageResults updateGroup(
|
||||
final GroupId groupId, final UpdateGroup updateGroup
|
||||
final GroupId groupId,
|
||||
final UpdateGroup updateGroup
|
||||
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException {
|
||||
final var group = getRemoteObject(signal.getGroup(groupId.serialize()), Signal.Group.class);
|
||||
if (updateGroup.getName() != null) {
|
||||
|
@ -380,7 +388,8 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public SendMessageResults sendTypingMessage(
|
||||
final TypingAction action, final Set<RecipientIdentifier> recipients
|
||||
final TypingAction action,
|
||||
final Set<RecipientIdentifier> recipients
|
||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
||||
return handleMessage(recipients, numbers -> {
|
||||
numbers.forEach(n -> signal.sendTyping(n, action == TypingAction.STOP));
|
||||
|
@ -395,24 +404,22 @@ public class DbusManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SendMessageResults sendReadReceipt(
|
||||
final RecipientIdentifier.Single sender, final List<Long> messageIds
|
||||
) {
|
||||
public SendMessageResults sendReadReceipt(final RecipientIdentifier.Single sender, final List<Long> messageIds) {
|
||||
signal.sendReadReceipt(sender.getIdentifier(), messageIds);
|
||||
return new SendMessageResults(0, Map.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendMessageResults sendViewedReceipt(
|
||||
final RecipientIdentifier.Single sender, final List<Long> messageIds
|
||||
) {
|
||||
public SendMessageResults sendViewedReceipt(final RecipientIdentifier.Single sender, final List<Long> messageIds) {
|
||||
signal.sendViewedReceipt(sender.getIdentifier(), messageIds);
|
||||
return new SendMessageResults(0, Map.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendMessageResults sendMessage(
|
||||
final Message message, final Set<RecipientIdentifier> recipients, final boolean notifySelf
|
||||
final Message message,
|
||||
final Set<RecipientIdentifier> recipients,
|
||||
final boolean notifySelf
|
||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
||||
return handleMessage(recipients,
|
||||
numbers -> signal.sendMessage(message.messageText(), message.attachments(), numbers),
|
||||
|
@ -422,14 +429,17 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public SendMessageResults sendEditMessage(
|
||||
final Message message, final Set<RecipientIdentifier> recipients, final long editTargetTimestamp
|
||||
final Message message,
|
||||
final Set<RecipientIdentifier> recipients,
|
||||
final long editTargetTimestamp
|
||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendMessageResults sendRemoteDeleteMessage(
|
||||
final long targetSentTimestamp, final Set<RecipientIdentifier> recipients
|
||||
final long targetSentTimestamp,
|
||||
final Set<RecipientIdentifier> recipients
|
||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
||||
return handleMessage(recipients,
|
||||
numbers -> signal.sendRemoteDeleteMessage(targetSentTimestamp, numbers),
|
||||
|
@ -466,7 +476,9 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public SendMessageResults sendPaymentNotificationMessage(
|
||||
final byte[] receipt, final String note, final RecipientIdentifier.Single recipient
|
||||
final byte[] receipt,
|
||||
final String note,
|
||||
final RecipientIdentifier.Single recipient
|
||||
) throws IOException {
|
||||
final var timestamp = signal.sendPaymentNotification(receipt, note, recipient.getIdentifier());
|
||||
return new SendMessageResults(timestamp, Map.of());
|
||||
|
@ -502,14 +514,17 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public void setContactName(
|
||||
final RecipientIdentifier.Single recipient, final String givenName, final String familyName
|
||||
final RecipientIdentifier.Single recipient,
|
||||
final String givenName,
|
||||
final String familyName
|
||||
) throws NotPrimaryDeviceException {
|
||||
signal.setContactName(recipient.getIdentifier(), givenName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContactsBlocked(
|
||||
final Collection<RecipientIdentifier.Single> recipients, final boolean blocked
|
||||
final Collection<RecipientIdentifier.Single> recipients,
|
||||
final boolean blocked
|
||||
) throws NotPrimaryDeviceException, IOException {
|
||||
for (final var recipient : recipients) {
|
||||
signal.setContactBlocked(recipient.getIdentifier(), blocked);
|
||||
|
@ -518,7 +533,8 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public void setGroupsBlocked(
|
||||
final Collection<GroupId> groupIds, final boolean blocked
|
||||
final Collection<GroupId> groupIds,
|
||||
final boolean blocked
|
||||
) throws GroupNotFoundException, IOException {
|
||||
for (final var groupId : groupIds) {
|
||||
setGroupProperty(groupId, "IsBlocked", blocked);
|
||||
|
@ -532,7 +548,8 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public void setExpirationTimer(
|
||||
final RecipientIdentifier.Single recipient, final int messageExpirationTimer
|
||||
final RecipientIdentifier.Single recipient,
|
||||
final int messageExpirationTimer
|
||||
) throws IOException {
|
||||
signal.setExpirationTimer(recipient.getIdentifier(), messageExpirationTimer);
|
||||
}
|
||||
|
@ -597,7 +614,9 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public void receiveMessages(
|
||||
Optional<Duration> timeout, Optional<Integer> maxMessages, ReceiveMessageHandler handler
|
||||
Optional<Duration> timeout,
|
||||
Optional<Integer> maxMessages,
|
||||
ReceiveMessageHandler handler
|
||||
) throws IOException, AlreadyReceivingException {
|
||||
if (receiveThread != null) {
|
||||
throw new AlreadyReceivingException("Already receiving message.");
|
||||
|
@ -784,7 +803,8 @@ public class DbusManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public boolean trustIdentityVerified(
|
||||
final RecipientIdentifier.Single recipient, final IdentityVerificationCode verificationCode
|
||||
final RecipientIdentifier.Single recipient,
|
||||
final IdentityVerificationCode verificationCode
|
||||
) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
@ -1124,9 +1144,7 @@ public class DbusManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T getValue(
|
||||
final Map<String, Variant<?>> stringVariantMap, final String field
|
||||
) {
|
||||
private <T> T getValue(final Map<String, Variant<?>> stringVariantMap, final String field) {
|
||||
return (T) stringVariantMap.get(field).getValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,9 @@ public class DbusMultiAccountManagerImpl implements MultiAccountManager {
|
|||
private final String busname;
|
||||
|
||||
public DbusMultiAccountManagerImpl(
|
||||
final SignalControl signalControl, DBusConnection connection, final String busname
|
||||
final SignalControl signalControl,
|
||||
DBusConnection connection,
|
||||
final String busname
|
||||
) {
|
||||
this.signalControl = signalControl;
|
||||
this.connection = connection;
|
||||
|
|
|
@ -27,7 +27,9 @@ public class DbusProvisioningManagerImpl implements ProvisioningManager {
|
|||
}
|
||||
|
||||
public DbusProvisioningManagerImpl(
|
||||
final SignalControl signalControl, DBusConnection connection, URI deviceLinkUri
|
||||
final SignalControl signalControl,
|
||||
DBusConnection connection,
|
||||
URI deviceLinkUri
|
||||
) {
|
||||
this.signalControl = signalControl;
|
||||
this.connection = connection;
|
||||
|
|
|
@ -27,7 +27,9 @@ public class DbusRegistrationManagerImpl implements RegistrationManager {
|
|||
|
||||
@Override
|
||||
public void register(
|
||||
final boolean voiceVerification, final String captcha, final boolean forceRegister
|
||||
final boolean voiceVerification,
|
||||
final String captcha,
|
||||
final boolean forceRegister
|
||||
) throws IOException, CaptchaRequiredException {
|
||||
if (forceRegister) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -41,7 +43,8 @@ public class DbusRegistrationManagerImpl implements RegistrationManager {
|
|||
|
||||
@Override
|
||||
public void verifyAccount(
|
||||
final String verificationCode, final String pin
|
||||
final String verificationCode,
|
||||
final String pin
|
||||
) throws IOException, PinLockedException, IncorrectPinException {
|
||||
if (pin == null) {
|
||||
signalControl.verify(number, verificationCode);
|
||||
|
|
|
@ -49,14 +49,17 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
|||
|
||||
@Override
|
||||
public void register(
|
||||
final String number, final boolean voiceVerification
|
||||
final String number,
|
||||
final boolean voiceVerification
|
||||
) throws Error.Failure, Error.InvalidNumber {
|
||||
registerWithCaptcha(number, voiceVerification, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerWithCaptcha(
|
||||
final String number, final boolean voiceVerification, final String captcha
|
||||
final String number,
|
||||
final boolean voiceVerification,
|
||||
final String captcha
|
||||
) throws Error.Failure, Error.InvalidNumber {
|
||||
if (!Manager.isValidNumber(number, null)) {
|
||||
throw new SignalControl.Error.InvalidNumber(
|
||||
|
@ -86,7 +89,9 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
|||
|
||||
@Override
|
||||
public void verifyWithPin(
|
||||
final String number, final String verificationCode, final String pin
|
||||
final String number,
|
||||
final String verificationCode,
|
||||
final String pin
|
||||
) throws Error.Failure, Error.InvalidNumber {
|
||||
try (final RegistrationManager registrationManager = c.getNewRegistrationManager(number)) {
|
||||
registrationManager.verifyAccount(verificationCode, pin);
|
||||
|
|
|
@ -81,7 +81,10 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
private static final Logger logger = LoggerFactory.getLogger(DbusSignalImpl.class);
|
||||
|
||||
public DbusSignalImpl(
|
||||
final Manager m, DBusConnection connection, final String objectPath, final boolean noReceiveOnStart
|
||||
final Manager m,
|
||||
DBusConnection connection,
|
||||
final String objectPath,
|
||||
final boolean noReceiveOnStart
|
||||
) {
|
||||
this.m = m;
|
||||
this.connection = connection;
|
||||
|
@ -258,16 +261,12 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long sendRemoteDeleteMessage(
|
||||
final long targetSentTimestamp, final String recipient
|
||||
) {
|
||||
public long sendRemoteDeleteMessage(final long targetSentTimestamp, final String recipient) {
|
||||
return sendRemoteDeleteMessage(targetSentTimestamp, List.of(recipient));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long sendRemoteDeleteMessage(
|
||||
final long targetSentTimestamp, final List<String> recipients
|
||||
) {
|
||||
public long sendRemoteDeleteMessage(final long targetSentTimestamp, final List<String> recipients) {
|
||||
try {
|
||||
final var results = m.sendRemoteDeleteMessage(targetSentTimestamp,
|
||||
getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
|
||||
|
@ -323,7 +322,9 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
|
||||
@Override
|
||||
public long sendPaymentNotification(
|
||||
final byte[] receipt, final String note, final String recipient
|
||||
final byte[] receipt,
|
||||
final String note,
|
||||
final String recipient
|
||||
) throws Error.Failure {
|
||||
try {
|
||||
final var results = m.sendPaymentNotificationMessage(receipt,
|
||||
|
@ -338,7 +339,8 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
|
||||
@Override
|
||||
public void sendTyping(
|
||||
final String recipient, final boolean stop
|
||||
final String recipient,
|
||||
final boolean stop
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity {
|
||||
try {
|
||||
final var results = m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START,
|
||||
|
@ -355,7 +357,8 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
|
||||
@Override
|
||||
public void sendReadReceipt(
|
||||
final String recipient, final List<Long> messageIds
|
||||
final String recipient,
|
||||
final List<Long> messageIds
|
||||
) throws Error.Failure, Error.UntrustedIdentity {
|
||||
final var results = m.sendReadReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds);
|
||||
checkSendMessageResults(results);
|
||||
|
@ -363,7 +366,8 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
|
||||
@Override
|
||||
public void sendViewedReceipt(
|
||||
final String recipient, final List<Long> messageIds
|
||||
final String recipient,
|
||||
final List<Long> messageIds
|
||||
) throws Error.Failure, Error.UntrustedIdentity {
|
||||
final var results = m.sendViewedReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds);
|
||||
checkSendMessageResults(results);
|
||||
|
@ -389,7 +393,8 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
|
||||
@Override
|
||||
public long sendNoteToSelfMessage(
|
||||
final String messageText, final List<String> attachments
|
||||
final String messageText,
|
||||
final List<String> attachments
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.UntrustedIdentity {
|
||||
try {
|
||||
final var message = new Message(messageText,
|
||||
|
@ -461,7 +466,8 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
|
||||
@Override
|
||||
public void sendGroupTyping(
|
||||
final byte[] groupId, final boolean stop
|
||||
final byte[] groupId,
|
||||
final boolean stop
|
||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity {
|
||||
try {
|
||||
final var results = m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START,
|
||||
|
@ -475,9 +481,7 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long sendGroupRemoteDeleteMessage(
|
||||
final long targetSentTimestamp, final byte[] groupId
|
||||
) {
|
||||
public long sendGroupRemoteDeleteMessage(final long targetSentTimestamp, final byte[] groupId) {
|
||||
try {
|
||||
final var results = m.sendRemoteDeleteMessage(targetSentTimestamp,
|
||||
Set.of(getGroupRecipientIdentifier(groupId)));
|
||||
|
@ -621,7 +625,9 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
|
||||
@Override
|
||||
public byte[] createGroup(
|
||||
final String name, final List<String> members, final String avatar
|
||||
final String name,
|
||||
final List<String> members,
|
||||
final String avatar
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber {
|
||||
return updateGroupInternal(new byte[0], name, members, avatar);
|
||||
}
|
||||
|
@ -900,7 +906,8 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
}
|
||||
|
||||
private static void checkGroupSendMessageResults(
|
||||
long timestamp, Collection<SendMessageResult> results
|
||||
long timestamp,
|
||||
Collection<SendMessageResult> results
|
||||
) throws DBusExecutionException {
|
||||
if (results.size() == 1) {
|
||||
checkSendMessageResult(timestamp, results.stream().findFirst().get());
|
||||
|
@ -927,7 +934,8 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
}
|
||||
|
||||
private static Set<RecipientIdentifier.Single> getSingleRecipientIdentifiers(
|
||||
final Collection<String> recipientStrings, final String localNumber
|
||||
final Collection<String> recipientStrings,
|
||||
final String localNumber
|
||||
) throws DBusExecutionException {
|
||||
final var identifiers = new HashSet<RecipientIdentifier.Single>();
|
||||
for (var recipientString : recipientStrings) {
|
||||
|
@ -937,7 +945,8 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
|
|||
}
|
||||
|
||||
private static RecipientIdentifier.Single getSingleRecipientIdentifier(
|
||||
final String recipientString, final String localNumber
|
||||
final String recipientString,
|
||||
final String localNumber
|
||||
) throws DBusExecutionException {
|
||||
try {
|
||||
return RecipientIdentifier.Single.fromString(recipientString, localNumber);
|
||||
|
|
|
@ -240,7 +240,9 @@ public class HttpServerHandler implements AutoCloseable {
|
|||
}
|
||||
|
||||
private List<Pair<Manager, Manager.ReceiveMessageHandler>> subscribeReceiveHandlers(
|
||||
final List<Manager> managers, final ServerSentEventSender sender, Callable unsubscribe
|
||||
final List<Manager> managers,
|
||||
final ServerSentEventSender sender,
|
||||
Callable unsubscribe
|
||||
) {
|
||||
return managers.stream().map(m1 -> {
|
||||
final var receiveMessageHandler = new JsonReceiveMessageHandler(m1, s -> {
|
||||
|
|
|
@ -28,9 +28,7 @@ public record JsonMessageEnvelope(
|
|||
@JsonInclude(JsonInclude.Include.NON_NULL) JsonTypingMessage typingMessage
|
||||
) {
|
||||
|
||||
public static JsonMessageEnvelope from(
|
||||
MessageEnvelope envelope, Throwable exception, Manager m
|
||||
) {
|
||||
public static JsonMessageEnvelope from(MessageEnvelope envelope, Throwable exception, Manager m) {
|
||||
final RecipientAddress sourceAddress;
|
||||
final Integer sourceDevice;
|
||||
if (envelope.sourceAddress().isPresent()) {
|
||||
|
|
|
@ -38,7 +38,9 @@ public final class JsonRpcRequest extends JsonRpcMessage {
|
|||
private ValueNode id;
|
||||
|
||||
public static JsonRpcRequest forNotification(
|
||||
final String method, final ContainerNode<?> params, final ValueNode id
|
||||
final String method,
|
||||
final ContainerNode<?> params,
|
||||
final ValueNode id
|
||||
) {
|
||||
return new JsonRpcRequest("2.0", method, params, id);
|
||||
}
|
||||
|
@ -47,7 +49,10 @@ public final class JsonRpcRequest extends JsonRpcMessage {
|
|||
}
|
||||
|
||||
private JsonRpcRequest(
|
||||
final String jsonrpc, final String method, final ContainerNode<?> params, final ValueNode id
|
||||
final String jsonrpc,
|
||||
final String method,
|
||||
final ContainerNode<?> params,
|
||||
final ValueNode id
|
||||
) {
|
||||
this.jsonrpc = jsonrpc;
|
||||
this.method = method;
|
||||
|
|
|
@ -56,7 +56,9 @@ public class SignalJsonRpcCommandHandler {
|
|||
}
|
||||
|
||||
public JsonNode handleRequest(
|
||||
final ObjectMapper objectMapper, final String method, ContainerNode<?> params
|
||||
final ObjectMapper objectMapper,
|
||||
final String method,
|
||||
ContainerNode<?> params
|
||||
) throws JsonRpcException {
|
||||
var command = getCommand(method);
|
||||
if (c != null) {
|
||||
|
@ -197,7 +199,9 @@ public class SignalJsonRpcCommandHandler {
|
|||
}
|
||||
|
||||
private JsonNode runCommand(
|
||||
final ObjectMapper objectMapper, final ContainerNode<?> params, final CommandRunner<?> command
|
||||
final ObjectMapper objectMapper,
|
||||
final ContainerNode<?> params,
|
||||
final CommandRunner<?> command
|
||||
) throws JsonRpcException {
|
||||
final Object[] result = {null};
|
||||
final JsonWriter commandJsonWriter = s -> {
|
||||
|
|
|
@ -43,7 +43,9 @@ public class SignalJsonRpcDispatcherHandler {
|
|||
private SignalJsonRpcCommandHandler commandHandler;
|
||||
|
||||
public SignalJsonRpcDispatcherHandler(
|
||||
final JsonWriter jsonWriter, final Supplier<String> lineSupplier, final boolean noReceiveOnStart
|
||||
final JsonWriter jsonWriter,
|
||||
final Supplier<String> lineSupplier,
|
||||
final boolean noReceiveOnStart
|
||||
) {
|
||||
this.noReceiveOnStart = noReceiveOnStart;
|
||||
this.objectMapper = Util.createJsonObjectMapper();
|
||||
|
@ -167,7 +169,9 @@ public class SignalJsonRpcDispatcherHandler {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Void request, final Manager m, final JsonWriter jsonWriter
|
||||
final Void request,
|
||||
final Manager m,
|
||||
final JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
final var subscriptionId = subscribeReceive(m, false);
|
||||
jsonWriter.write(subscriptionId);
|
||||
|
@ -175,7 +179,9 @@ public class SignalJsonRpcDispatcherHandler {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final Void request, final MultiAccountManager c, final JsonWriter jsonWriter
|
||||
final Void request,
|
||||
final MultiAccountManager c,
|
||||
final JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
final var subscriptionId = subscribeReceive(c.getManagers(), false);
|
||||
jsonWriter.write(subscriptionId);
|
||||
|
@ -196,7 +202,9 @@ public class SignalJsonRpcDispatcherHandler {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final JsonNode request, final Manager m, final JsonWriter jsonWriter
|
||||
final JsonNode request,
|
||||
final Manager m,
|
||||
final JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
final var subscriptionId = getSubscriptionId(request);
|
||||
if (subscriptionId == null) {
|
||||
|
@ -210,7 +218,9 @@ public class SignalJsonRpcDispatcherHandler {
|
|||
|
||||
@Override
|
||||
public void handleCommand(
|
||||
final JsonNode request, final MultiAccountManager c, final JsonWriter jsonWriter
|
||||
final JsonNode request,
|
||||
final MultiAccountManager c,
|
||||
final JsonWriter jsonWriter
|
||||
) throws CommandException {
|
||||
final var subscriptionId = getSubscriptionId(request);
|
||||
if (subscriptionId == null) {
|
||||
|
|
|
@ -39,7 +39,9 @@ public class SocketHandler implements AutoCloseable {
|
|||
}
|
||||
|
||||
public SocketHandler(
|
||||
final ServerSocketChannel serverChannel, final MultiAccountManager c, final boolean noReceiveOnStart
|
||||
final ServerSocketChannel serverChannel,
|
||||
final MultiAccountManager c,
|
||||
final boolean noReceiveOnStart
|
||||
) {
|
||||
this.serverChannel = serverChannel;
|
||||
this.socketHandler = channel -> getSignalJsonRpcDispatcherHandler(channel).handleConnection(c);
|
||||
|
|
|
@ -83,7 +83,8 @@ public class LogConfigurator extends ContextAwareBase implements Configurator {
|
|||
}
|
||||
|
||||
private ConsoleAppender<ILoggingEvent> createLoggingConsoleAppender(
|
||||
final LoggerContext lc, final LayoutWrappingEncoder<ILoggingEvent> layoutEncoder
|
||||
final LoggerContext lc,
|
||||
final LayoutWrappingEncoder<ILoggingEvent> layoutEncoder
|
||||
) {
|
||||
return new ConsoleAppender<>() {{
|
||||
setContext(lc);
|
||||
|
@ -95,7 +96,8 @@ public class LogConfigurator extends ContextAwareBase implements Configurator {
|
|||
}
|
||||
|
||||
private FileAppender<ILoggingEvent> createLoggingFileAppender(
|
||||
final LoggerContext lc, final LayoutWrappingEncoder<ILoggingEvent> layoutEncoder
|
||||
final LoggerContext lc,
|
||||
final LayoutWrappingEncoder<ILoggingEvent> layoutEncoder
|
||||
) {
|
||||
return new FileAppender<>() {{
|
||||
setContext(lc);
|
||||
|
|
|
@ -249,9 +249,7 @@ public final class Scrubber {
|
|||
return scrub(in, IPV4_PATTERN, (matcher, output) -> output.append(IPV4_CENSOR));
|
||||
}
|
||||
|
||||
private static CharSequence scrub(
|
||||
CharSequence in, Pattern pattern, ProcessMatch processMatch
|
||||
) {
|
||||
private static CharSequence scrub(CharSequence in, Pattern pattern, ProcessMatch processMatch) {
|
||||
final StringBuilder output = new StringBuilder(in.length());
|
||||
final Matcher matcher = pattern.matcher(in);
|
||||
|
||||
|
|
|
@ -84,7 +84,8 @@ public class CommandUtil {
|
|||
}
|
||||
|
||||
public static Set<RecipientIdentifier.Single> getSingleRecipientIdentifiers(
|
||||
final Collection<String> recipientStrings, final String localNumber
|
||||
final Collection<String> recipientStrings,
|
||||
final String localNumber
|
||||
) throws UserErrorException {
|
||||
if (recipientStrings == null) {
|
||||
return Set.of();
|
||||
|
@ -97,7 +98,8 @@ public class CommandUtil {
|
|||
}
|
||||
|
||||
public static RecipientIdentifier.Single getSingleRecipientIdentifier(
|
||||
final String recipientString, final String localNumber
|
||||
final String recipientString,
|
||||
final String localNumber
|
||||
) throws UserErrorException {
|
||||
try {
|
||||
return RecipientIdentifier.Single.fromString(recipientString, localNumber);
|
||||
|
|
|
@ -41,7 +41,8 @@ public class SendMessageResultUtils {
|
|||
}
|
||||
|
||||
public static void outputResult(
|
||||
final OutputWriter outputWriter, final SendMessageResults sendMessageResults
|
||||
final OutputWriter outputWriter,
|
||||
final SendMessageResults sendMessageResults
|
||||
) throws CommandException {
|
||||
switch (outputWriter) {
|
||||
case PlainTextWriter writer -> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue