mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-08-22 04:56:04 +00:00
Reformat files
This commit is contained in:
parent
fd3f572499
commit
3c319f8b4a
@ -336,8 +336,7 @@ public class ProvisioningManagerImpl implements ProvisioningManager, Closeable {
|
||||
|
||||
try (signalAccount) {
|
||||
if (signalAccount.getDeviceId() <= 0) {
|
||||
logger.debug("Account has invalid deviceId {}, allowing relink.",
|
||||
signalAccount.getDeviceId());
|
||||
logger.debug("Account has invalid deviceId {}, allowing relink.", signalAccount.getDeviceId());
|
||||
return true;
|
||||
}
|
||||
if (signalAccount.isPrimaryDevice()) {
|
||||
|
||||
@ -357,7 +357,8 @@ public class ContactRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
||||
logger.warn("Received invalid contact identity key from storage");
|
||||
}
|
||||
}
|
||||
account.getRecipientStore().storePniSignatureVerified(connection, recipientId, contactProto.pniSignatureVerified);
|
||||
account.getRecipientStore()
|
||||
.storePniSignatureVerified(connection, recipientId, contactProto.pniSignatureVerified);
|
||||
account.getRecipientStore()
|
||||
.storeStorageRecord(connection, recipientId, contactRecord.getId(), contactProto.encode());
|
||||
}
|
||||
|
||||
@ -31,8 +31,7 @@ public class StickerPackRecordProcessor extends DefaultStorageRecordProcessor<Si
|
||||
@Override
|
||||
protected boolean isInvalid(final SignalStickerPackRecord remote) {
|
||||
return remote.getProto().packId.size() != PACK_ID_LENGTH || (
|
||||
remote.getProto().deletedAtTimestamp == 0
|
||||
&& remote.getProto().packKey.size() != PACK_KEY_LENGTH
|
||||
remote.getProto().deletedAtTimestamp == 0 && remote.getProto().packKey.size() != PACK_KEY_LENGTH
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ import org.whispersystems.signalservice.api.push.exceptions.ResumeLocationInvali
|
||||
import org.whispersystems.signalservice.api.util.StreamDetails;
|
||||
import org.whispersystems.signalservice.internal.push.http.ResumableUploadSpec;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@ -15,6 +14,8 @@ import java.io.InputStream;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class AttachmentUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AttachmentUtils.class);
|
||||
@ -60,7 +61,10 @@ public class AttachmentUtils {
|
||||
private static ProbedStream probeImageDimensions(StreamDetails streamDetails) throws IOException {
|
||||
final var contentType = streamDetails.getContentType();
|
||||
final var length = streamDetails.getLength();
|
||||
if (contentType == null || !contentType.startsWith("image/") || length <= 0 || length > MAX_DIMENSION_PROBE_SIZE) {
|
||||
if (contentType == null
|
||||
|| !contentType.startsWith("image/")
|
||||
|| length <= 0
|
||||
|| length > MAX_DIMENSION_PROBE_SIZE) {
|
||||
return new ProbedStream(streamDetails.getStream(), 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -3,12 +3,13 @@ package org.asamk.signal.manager.util;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.whispersystems.signalservice.api.util.StreamDetails;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@ -17,7 +18,9 @@ class AttachmentUtilsTest {
|
||||
@Test
|
||||
public void createAttachmentStream_setsWidthAndHeightForImage() throws Exception {
|
||||
final var imageBytes = pngBytes(37, 21);
|
||||
final var streamDetails = new StreamDetails(new ByteArrayInputStream(imageBytes), "image/png", imageBytes.length);
|
||||
final var streamDetails = new StreamDetails(new ByteArrayInputStream(imageBytes),
|
||||
"image/png",
|
||||
imageBytes.length);
|
||||
|
||||
final var attachment = AttachmentUtils.createAttachmentStream(streamDetails, Optional.of("meme.png"), null);
|
||||
|
||||
@ -29,7 +32,9 @@ class AttachmentUtilsTest {
|
||||
@Test
|
||||
public void createAttachmentStream_leavesWidthAndHeightZeroForNonImage() throws Exception {
|
||||
final var bytes = "not an image".getBytes();
|
||||
final var streamDetails = new StreamDetails(new ByteArrayInputStream(bytes), "application/octet-stream", bytes.length);
|
||||
final var streamDetails = new StreamDetails(new ByteArrayInputStream(bytes),
|
||||
"application/octet-stream",
|
||||
bytes.length);
|
||||
|
||||
final var attachment = AttachmentUtils.createAttachmentStream(streamDetails, Optional.of("file.bin"), null);
|
||||
|
||||
|
||||
@ -33,9 +33,7 @@ public class SendStoryCommand implements JsonRpcLocalCommand {
|
||||
subparser.addArgument("-a", "--attachment")
|
||||
.required(true)
|
||||
.help("Specify the file path to the image or video to post as a story.");
|
||||
subparser.addArgument("--no-replies")
|
||||
.action(Arguments.storeTrue())
|
||||
.help("Disable replies on this story.");
|
||||
subparser.addArgument("--no-replies").action(Arguments.storeTrue()).help("Disable replies on this story.");
|
||||
subparser.addArgument("-g", "--group-id")
|
||||
.help("Specify a group to post the story to. Without this, posts to My Story.");
|
||||
}
|
||||
|
||||
@ -42,7 +42,8 @@ public class SubmitRateLimitChallengeCommand implements JsonRpcLocalCommand {
|
||||
throw new IOErrorException("Submit challenge error: " + e.getMessage(), e);
|
||||
} catch (CaptchaRejectedException e) {
|
||||
throw new CaptchaRejectedErrorException(
|
||||
"Captcha rejected, it may be outdated, already used or solved from a different IP address.", e);
|
||||
"Captcha rejected, it may be outdated, already used or solved from a different IP address.",
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -548,11 +548,7 @@ public class DbusManagerImpl implements Manager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendMessageResults sendStory(
|
||||
String attachment,
|
||||
boolean allowsReplies,
|
||||
Optional<GroupId> groupId
|
||||
) {
|
||||
public SendMessageResults sendStory(String attachment, boolean allowsReplies, Optional<GroupId> groupId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@ -76,7 +76,8 @@ public class HttpServerHandler implements AutoCloseable {
|
||||
// If we're listening on any local address (0.0.0.0 or ::), skip Host header validation
|
||||
final var addr = address == null ? null : address.getAddress();
|
||||
if (addr != null && addr.isAnyLocalAddress()) {
|
||||
logger.warn("HTTP server has no authentication; Host header validation DISABLED because listening on {}", address);
|
||||
logger.warn("HTTP server has no authentication; Host header validation DISABLED because listening on {}",
|
||||
address);
|
||||
} else {
|
||||
logger.warn("HTTP server has no authentication; Host header is pinned to {}", allowedHosts);
|
||||
}
|
||||
@ -114,7 +115,8 @@ public class HttpServerHandler implements AutoCloseable {
|
||||
private void handleRpcEndpoint(HttpExchange httpExchange) throws IOException {
|
||||
if (!isHostAllowed(httpExchange)) {
|
||||
logger.warn("Rejected RPC request with invalid Host header: {} from {}",
|
||||
httpExchange.getRequestHeaders().getFirst("Host"), httpExchange.getRemoteAddress());
|
||||
httpExchange.getRequestHeaders().getFirst("Host"),
|
||||
httpExchange.getRemoteAddress());
|
||||
sendResponse(421, null, httpExchange);
|
||||
return;
|
||||
}
|
||||
@ -167,7 +169,8 @@ public class HttpServerHandler implements AutoCloseable {
|
||||
private void handleEventsEndpoint(HttpExchange httpExchange) throws IOException {
|
||||
if (!isHostAllowed(httpExchange)) {
|
||||
logger.warn("Rejected Events request with invalid Host header: {} from {}",
|
||||
httpExchange.getRequestHeaders().getFirst("Host"), httpExchange.getRemoteAddress());
|
||||
httpExchange.getRequestHeaders().getFirst("Host"),
|
||||
httpExchange.getRemoteAddress());
|
||||
sendResponse(421, null, httpExchange);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "AdminDelete")
|
||||
public record JsonAdminDelete(
|
||||
@Deprecated String targetAuthor, String targetAuthorNumber, String targetAuthorUuid, long targetSentTimestamp
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "Attachment")
|
||||
record JsonAttachment(
|
||||
String contentType,
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
@ -9,6 +8,8 @@ import java.math.BigInteger;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import static org.asamk.signal.manager.util.Utils.callIdUnsigned;
|
||||
|
||||
@JsonSchema(title = "CallMessage")
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "Contact")
|
||||
public record JsonContact(
|
||||
String number,
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
import org.asamk.signal.util.Util;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "ContactAddress")
|
||||
public record JsonContactAddress(
|
||||
String type,
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "ContactAvatar")
|
||||
public record JsonContactAvatar(JsonAttachment attachment, boolean isProfile) {
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
import org.asamk.signal.util.Util;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "ContactEmail")
|
||||
public record JsonContactEmail(String value, String type, String label) {
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
import org.asamk.signal.util.Util;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "ContactName")
|
||||
public record JsonContactName(
|
||||
String nickname, String given, String family, String prefix, String suffix, String middle
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
import org.asamk.signal.util.Util;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "ContactPhone")
|
||||
public record JsonContactPhone(String value, String type, String label) {
|
||||
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "DataMessage")
|
||||
record JsonDataMessage(
|
||||
long timestamp,
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "EditMessage")
|
||||
record JsonEditMessage(long targetSentTimestamp, JsonDataMessage dataMessage) {
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "GroupInfo")
|
||||
record JsonGroupInfo(String groupId, String groupName, int revision, String type) {
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "Mention")
|
||||
public record JsonMention(@Deprecated String name, String number, String uuid, int start, int length) {
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
@ -11,6 +10,8 @@ import org.asamk.signal.manager.api.UntrustedIdentityException;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "MessageEnvelope")
|
||||
public record JsonMessageEnvelope(
|
||||
@Deprecated String source,
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "Payment")
|
||||
public record JsonPayment(String note, byte[] receipt) {
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "PinMessage")
|
||||
public record JsonPinMessage(
|
||||
@Deprecated String targetAuthor,
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "PollCreate")
|
||||
public record JsonPollCreate(
|
||||
String question, boolean allowMultiple, List<String> options
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "PollTerminate")
|
||||
public record JsonPollTerminate(long targetSentTimestamp) {
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "PollVote")
|
||||
public record JsonPollVote(
|
||||
@Deprecated String author,
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "Preview")
|
||||
public record JsonPreview(String url, String title, String description, JsonAttachment image) {
|
||||
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "Quote")
|
||||
public record JsonQuote(
|
||||
long id,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "QuotedAttachment")
|
||||
public record JsonQuotedAttachment(
|
||||
String contentType, String filename, @JsonInclude(JsonInclude.Include.NON_NULL) JsonAttachment thumbnail
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "Reaction")
|
||||
public record JsonReaction(
|
||||
String emoji,
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "ReceiptMessage")
|
||||
record JsonReceiptMessage(long when, boolean isDelivery, boolean isRead, boolean isViewed, List<Long> timestamps) {
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.RecipientAddress;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "RecipientAddress")
|
||||
public record JsonRecipientAddress(String uuid, String number, String username) {
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.GroupId;
|
||||
import org.asamk.signal.manager.api.SendMessageResult;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "SendMessageResult")
|
||||
public record JsonSendMessageResult(
|
||||
JsonRecipientAddress recipientAddress,
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "SharedContact")
|
||||
public record JsonSharedContact(
|
||||
JsonContactName name,
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
import org.asamk.signal.util.Hex;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "Sticker")
|
||||
public record JsonSticker(String packId, int stickerId) {
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "StoryContext")
|
||||
record JsonStoryContext(
|
||||
String authorNumber, String authorUuid, long sentTimestamp
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.Color;
|
||||
import org.asamk.signal.manager.api.GroupId;
|
||||
@ -9,6 +8,8 @@ import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "StoryMessage")
|
||||
record JsonStoryMessage(
|
||||
boolean allowsReplies,
|
||||
|
||||
@ -2,7 +2,6 @@ package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
@ -10,6 +9,8 @@ import org.asamk.signal.manager.api.RecipientAddress;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "SyncDataMessage")
|
||||
record JsonSyncDataMessage(
|
||||
@Deprecated String destination,
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "SyncReadMessage")
|
||||
record JsonSyncReadMessage(
|
||||
@Deprecated String sender, String senderNumber, String senderUuid, long timestamp
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "SyncStoryMessage")
|
||||
record JsonSyncStoryMessage(
|
||||
String destinationNumber, String destinationUuid, @JsonUnwrapped JsonStoryMessage dataMessage
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.TextStyle;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "TextStyle")
|
||||
public record JsonTextStyle(String style, int start, int length) {
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.GroupId;
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "TypingMessage")
|
||||
record JsonTypingMessage(
|
||||
String action, long timestamp, @JsonInclude(JsonInclude.Include.NON_NULL) String groupId
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
import org.asamk.signal.manager.api.MessageEnvelope;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import io.micronaut.jsonschema.JsonSchema;
|
||||
|
||||
@JsonSchema(title = "UnpinMessage")
|
||||
public record JsonUnpinMessage(
|
||||
@Deprecated String targetAuthor, String targetAuthorNumber, String targetAuthorUuid, long targetSentTimestamp
|
||||
|
||||
@ -79,7 +79,9 @@ public class Util {
|
||||
for (var param : params) {
|
||||
final var paramParts = param.split("=", 2);
|
||||
var name = URLDecoder.decode(paramParts[0], StandardCharsets.UTF_8);
|
||||
var value = paramParts.length == 1 ? null : URLDecoder.decode(paramParts[1].replace("+", "%2B"), StandardCharsets.UTF_8);
|
||||
var value = paramParts.length == 1
|
||||
? null
|
||||
: URLDecoder.decode(paramParts[1].replace("+", "%2B"), StandardCharsets.UTF_8);
|
||||
map.put(name, value);
|
||||
}
|
||||
return map;
|
||||
|
||||
@ -30,7 +30,9 @@ class SseInitialFlushTest {
|
||||
private HttpServerHandler handler;
|
||||
private int port;
|
||||
|
||||
/** Finds a free local port. */
|
||||
/**
|
||||
* Finds a free local port.
|
||||
*/
|
||||
private static int freePort() throws Exception {
|
||||
try (var ss = new ServerSocket(0)) {
|
||||
ss.setReuseAddress(true);
|
||||
|
||||
@ -53,8 +53,7 @@ class SubscribeCallEventsTest {
|
||||
}
|
||||
}
|
||||
|
||||
private record ManagedManager(Manager manager, ManagerMock.State state) {
|
||||
}
|
||||
private record ManagedManager(Manager manager, ManagerMock.State state) {}
|
||||
|
||||
private static ManagedManager createManager(final String selfNumber) {
|
||||
final var state = new ManagerMock.State();
|
||||
@ -172,7 +171,9 @@ class SubscribeCallEventsTest {
|
||||
handler.handleConnection(manager.manager());
|
||||
|
||||
// The implementation allows multiple subscriptions, so two calls add two listeners
|
||||
assertEquals(2, manager.state().addCallEventListenerCount.get(), "multiple subscribeCallEvents should add multiple listeners");
|
||||
assertEquals(2,
|
||||
manager.state().addCallEventListenerCount.get(),
|
||||
"multiple subscribeCallEvents should add multiple listeners");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -263,6 +264,8 @@ class SubscribeCallEventsTest {
|
||||
var handler = new SignalJsonRpcDispatcherHandler(writer, feeder::getLine, true);
|
||||
handler.handleConnection(multi);
|
||||
|
||||
assertEquals(0, manager1.state().addCallEventListenerCount.get(), "call events should not be auto-subscribed in multi mode");
|
||||
assertEquals(0,
|
||||
manager1.state().addCallEventListenerCount.get(),
|
||||
"call events should not be auto-subscribed in multi mode");
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,8 +34,7 @@ public final class ManagerMock {
|
||||
}
|
||||
|
||||
public static Manager create(final String selfNumber, final State state) {
|
||||
return (Manager) Proxy.newProxyInstance(
|
||||
Manager.class.getClassLoader(),
|
||||
return (Manager) Proxy.newProxyInstance(Manager.class.getClassLoader(),
|
||||
new Class<?>[]{Manager.class},
|
||||
(proxy, method, args) -> {
|
||||
final var methodName = method.getName();
|
||||
@ -69,8 +68,7 @@ public final class ManagerMock {
|
||||
default:
|
||||
return defaultValue(method.getReturnType());
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private static Object defaultValue(final Class<?> returnType) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user