mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-05-17 13:11:00 +00:00
Reformat files
This commit is contained in:
parent
398faa50b0
commit
d0ee90dbbc
@ -1,9 +1,7 @@
|
|||||||
package org.asamk.signal.manager.api;
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
public record CallOffer(
|
public record CallOffer(
|
||||||
long callId,
|
long callId, Type type, byte[] opaque
|
||||||
Type type,
|
|
||||||
byte[] opaque
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
package org.asamk.signal.manager.api;
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
public record ReceiveConfig(boolean ignoreAttachments, boolean ignoreStories, boolean ignoreAvatars, boolean ignoreStickers, boolean sendReadReceipts) {}
|
public record ReceiveConfig(
|
||||||
|
boolean ignoreAttachments,
|
||||||
|
boolean ignoreStories,
|
||||||
|
boolean ignoreAvatars,
|
||||||
|
boolean ignoreStickers,
|
||||||
|
boolean sendReadReceipts
|
||||||
|
) {}
|
||||||
|
|||||||
@ -3,8 +3,5 @@ package org.asamk.signal.manager.api;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public record TurnServer(
|
public record TurnServer(
|
||||||
String username,
|
String username, String password, List<String> urls
|
||||||
String password,
|
) {}
|
||||||
List<String> urls
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|||||||
@ -192,8 +192,10 @@ public final class ProfileHelper {
|
|||||||
final var streamDetails = avatar != null && avatar.isPresent()
|
final var streamDetails = avatar != null && avatar.isPresent()
|
||||||
? Utils.createStreamDetails(avatar.get())
|
? Utils.createStreamDetails(avatar.get())
|
||||||
.first()
|
.first()
|
||||||
: forceUploadAvatar && avatar == null ? context.getAvatarStore()
|
: forceUploadAvatar && avatar == null
|
||||||
.retrieveProfileAvatar(account.getSelfRecipientAddress()) : null;
|
? context.getAvatarStore()
|
||||||
|
.retrieveProfileAvatar(account.getSelfRecipientAddress())
|
||||||
|
: null;
|
||||||
try (streamDetails) {
|
try (streamDetails) {
|
||||||
final var avatarUploadParams = streamDetails != null
|
final var avatarUploadParams = streamDetails != null
|
||||||
? AvatarUploadParams.forAvatar(streamDetails)
|
? AvatarUploadParams.forAvatar(streamDetails)
|
||||||
|
|||||||
@ -78,8 +78,10 @@ public class StickerUtils {
|
|||||||
throw new StickerPackInvalidException("Could not find find " + pack.cover().file());
|
throw new StickerPackInvalidException("Could not find find " + pack.cover().file());
|
||||||
}
|
}
|
||||||
|
|
||||||
var contentType = pack.cover().contentType() != null && !pack.cover().contentType().isEmpty() ? pack.cover()
|
var contentType = pack.cover().contentType() != null && !pack.cover().contentType().isEmpty()
|
||||||
.contentType() : getContentType(rootPath, zip, pack.cover().file());
|
? pack.cover()
|
||||||
|
.contentType()
|
||||||
|
: getContentType(rootPath, zip, pack.cover().file());
|
||||||
cover = new SignalServiceStickerManifestUpload.StickerInfo(data.first(),
|
cover = new SignalServiceStickerManifestUpload.StickerInfo(data.first(),
|
||||||
data.second(),
|
data.second(),
|
||||||
Optional.ofNullable(pack.cover().emoji()).orElse(""),
|
Optional.ofNullable(pack.cover().emoji()).orElse(""),
|
||||||
|
|||||||
@ -23,10 +23,7 @@ public class AcceptCallCommand implements JsonRpcLocalCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void attachToSubparser(final Subparser subparser) {
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
subparser.help("Accept an incoming voice call.");
|
subparser.help("Accept an incoming voice call.");
|
||||||
subparser.addArgument("--call-id")
|
subparser.addArgument("--call-id").type(long.class).required(true).help("The call ID to accept.");
|
||||||
.type(long.class)
|
|
||||||
.required(true)
|
|
||||||
.help("The call ID to accept.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -21,10 +21,7 @@ public class HangupCallCommand implements JsonRpcLocalCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void attachToSubparser(final Subparser subparser) {
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
subparser.help("Hang up an active voice call.");
|
subparser.help("Hang up an active voice call.");
|
||||||
subparser.addArgument("--call-id")
|
subparser.addArgument("--call-id").type(long.class).required(true).help("The call ID to hang up.");
|
||||||
.type(long.class)
|
|
||||||
.required(true)
|
|
||||||
.help("The call ID to hang up.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -5,13 +5,10 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
|||||||
|
|
||||||
import org.asamk.signal.commands.exceptions.CommandException;
|
import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.api.CallInfo;
|
|
||||||
import org.asamk.signal.output.JsonWriter;
|
import org.asamk.signal.output.JsonWriter;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
import org.asamk.signal.output.PlainTextWriter;
|
import org.asamk.signal.output.PlainTextWriter;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ListCallsCommand implements JsonRpcLocalCommand {
|
public class ListCallsCommand implements JsonRpcLocalCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -21,10 +21,7 @@ public class RejectCallCommand implements JsonRpcLocalCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void attachToSubparser(final Subparser subparser) {
|
public void attachToSubparser(final Subparser subparser) {
|
||||||
subparser.help("Reject an incoming voice call.");
|
subparser.help("Reject an incoming voice call.");
|
||||||
subparser.addArgument("--call-id")
|
subparser.addArgument("--call-id").type(long.class).required(true).help("The call ID to reject.");
|
||||||
.type(long.class)
|
|
||||||
.required(true)
|
|
||||||
.help("The call ID to reject.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -82,7 +82,11 @@ public class SendPollCreateCommand implements JsonRpcLocalCommand {
|
|||||||
throw new UserErrorException("Poll options must not be empty");
|
throw new UserErrorException("Poll options must not be empty");
|
||||||
}
|
}
|
||||||
if (option.length() > MAX_POLL_OPTION_LENGTH) {
|
if (option.length() > MAX_POLL_OPTION_LENGTH) {
|
||||||
throw new UserErrorException("Poll option \"" + option + "\" exceeds the maximum length of " + MAX_POLL_OPTION_LENGTH + " characters");
|
throw new UserErrorException("Poll option \""
|
||||||
|
+ option
|
||||||
|
+ "\" exceeds the maximum length of "
|
||||||
|
+ MAX_POLL_OPTION_LENGTH
|
||||||
|
+ " characters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,15 +18,13 @@ public record JsonCallEvent(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
public static JsonCallEvent from(CallInfo callInfo, String reason) {
|
public static JsonCallEvent from(CallInfo callInfo, String reason) {
|
||||||
return new JsonCallEvent(
|
return new JsonCallEvent(callInfo.callId(),
|
||||||
callInfo.callId(),
|
|
||||||
callInfo.state().name(),
|
callInfo.state().name(),
|
||||||
callInfo.recipient().number().orElse(null),
|
callInfo.recipient().number().orElse(null),
|
||||||
callInfo.recipient().aci().orElse(null),
|
callInfo.recipient().aci().orElse(null),
|
||||||
callInfo.isOutgoing(),
|
callInfo.isOutgoing(),
|
||||||
callInfo.inputDeviceName(),
|
callInfo.inputDeviceName(),
|
||||||
callInfo.outputDeviceName(),
|
callInfo.outputDeviceName(),
|
||||||
reason
|
reason);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,11 +2,8 @@ package org.asamk.signal.json;
|
|||||||
|
|
||||||
import org.asamk.signal.manager.api.CallInfo;
|
import org.asamk.signal.manager.api.CallInfo;
|
||||||
import org.asamk.signal.manager.api.RecipientAddress;
|
import org.asamk.signal.manager.api.RecipientAddress;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
@ -17,7 +14,12 @@ class JsonCallEventTest {
|
|||||||
@Test
|
@Test
|
||||||
void fromWithNumberAndUuid() {
|
void fromWithNumberAndUuid() {
|
||||||
var recipient = new RecipientAddress("a1b2c3d4-e5f6-7890-abcd-ef1234567890", null, "+15551234567", null);
|
var recipient = new RecipientAddress("a1b2c3d4-e5f6-7890-abcd-ef1234567890", null, "+15551234567", null);
|
||||||
var callInfo = new CallInfo(123L, CallInfo.State.CONNECTED, recipient, "signal_input_123", "signal_output_123", true);
|
var callInfo = new CallInfo(123L,
|
||||||
|
CallInfo.State.CONNECTED,
|
||||||
|
recipient,
|
||||||
|
"signal_input_123",
|
||||||
|
"signal_output_123",
|
||||||
|
true);
|
||||||
|
|
||||||
var event = JsonCallEvent.from(callInfo, null);
|
var event = JsonCallEvent.from(callInfo, null);
|
||||||
|
|
||||||
@ -34,7 +36,12 @@ class JsonCallEventTest {
|
|||||||
@Test
|
@Test
|
||||||
void fromWithUuidOnly() {
|
void fromWithUuidOnly() {
|
||||||
var recipient = new RecipientAddress("a1b2c3d4-e5f6-7890-abcd-ef1234567890", null, null, null);
|
var recipient = new RecipientAddress("a1b2c3d4-e5f6-7890-abcd-ef1234567890", null, null, null);
|
||||||
var callInfo = new CallInfo(456L, CallInfo.State.RINGING_INCOMING, recipient, "signal_input_456", "signal_output_456", false);
|
var callInfo = new CallInfo(456L,
|
||||||
|
CallInfo.State.RINGING_INCOMING,
|
||||||
|
recipient,
|
||||||
|
"signal_input_456",
|
||||||
|
"signal_output_456",
|
||||||
|
false);
|
||||||
|
|
||||||
var event = JsonCallEvent.from(callInfo, null);
|
var event = JsonCallEvent.from(callInfo, null);
|
||||||
|
|
||||||
@ -48,7 +55,12 @@ class JsonCallEventTest {
|
|||||||
@Test
|
@Test
|
||||||
void fromWithNumberOnly() {
|
void fromWithNumberOnly() {
|
||||||
var recipient = new RecipientAddress(null, null, "+15559876543", null);
|
var recipient = new RecipientAddress(null, null, "+15559876543", null);
|
||||||
var callInfo = new CallInfo(789L, CallInfo.State.RINGING_OUTGOING, recipient, "signal_input_789", "signal_output_789", true);
|
var callInfo = new CallInfo(789L,
|
||||||
|
CallInfo.State.RINGING_OUTGOING,
|
||||||
|
recipient,
|
||||||
|
"signal_input_789",
|
||||||
|
"signal_output_789",
|
||||||
|
true);
|
||||||
|
|
||||||
var event = JsonCallEvent.from(callInfo, null);
|
var event = JsonCallEvent.from(callInfo, null);
|
||||||
|
|
||||||
@ -81,7 +93,12 @@ class JsonCallEventTest {
|
|||||||
@Test
|
@Test
|
||||||
void fromConnectingState() {
|
void fromConnectingState() {
|
||||||
var recipient = new RecipientAddress("uuid-5678", null, "+15552222222", null);
|
var recipient = new RecipientAddress("uuid-5678", null, "+15552222222", null);
|
||||||
var callInfo = new CallInfo(200L, CallInfo.State.CONNECTING, recipient, "signal_input_200", "signal_output_200", true);
|
var callInfo = new CallInfo(200L,
|
||||||
|
CallInfo.State.CONNECTING,
|
||||||
|
recipient,
|
||||||
|
"signal_input_200",
|
||||||
|
"signal_output_200",
|
||||||
|
true);
|
||||||
|
|
||||||
var event = JsonCallEvent.from(callInfo, null);
|
var event = JsonCallEvent.from(callInfo, null);
|
||||||
|
|
||||||
@ -97,8 +114,17 @@ class JsonCallEventTest {
|
|||||||
void fromWithVariousEndReasons() {
|
void fromWithVariousEndReasons() {
|
||||||
var recipient = new RecipientAddress("uuid-1234", null, "+15551111111", null);
|
var recipient = new RecipientAddress("uuid-1234", null, "+15551111111", null);
|
||||||
|
|
||||||
var reasons = new String[]{"local_hangup", "remote_hangup", "rejected", "remote_busy",
|
var reasons = new String[]{
|
||||||
"ring_timeout", "ice_failed", "tunnel_exit", "tunnel_error", "shutdown"};
|
"local_hangup",
|
||||||
|
"remote_hangup",
|
||||||
|
"rejected",
|
||||||
|
"remote_busy",
|
||||||
|
"ring_timeout",
|
||||||
|
"ice_failed",
|
||||||
|
"tunnel_exit",
|
||||||
|
"tunnel_error",
|
||||||
|
"shutdown"
|
||||||
|
};
|
||||||
|
|
||||||
for (var reason : reasons) {
|
for (var reason : reasons) {
|
||||||
var callInfo = new CallInfo(1L, CallInfo.State.ENDED, recipient, null, null, false);
|
var callInfo = new CallInfo(1L, CallInfo.State.ENDED, recipient, null, null, false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user