mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-05-11 12:10:18 +00:00
Reformat files
This commit is contained in:
parent
398faa50b0
commit
d0ee90dbbc
@ -1,9 +1,7 @@
|
||||
package org.asamk.signal.manager.api;
|
||||
|
||||
public record CallOffer(
|
||||
long callId,
|
||||
Type type,
|
||||
byte[] opaque
|
||||
long callId, Type type, byte[] opaque
|
||||
) {
|
||||
|
||||
public enum Type {
|
||||
|
||||
@ -268,19 +268,19 @@ public record MessageEnvelope(
|
||||
quote.getMentions() == null
|
||||
? List.of()
|
||||
: quote.getMentions()
|
||||
.stream()
|
||||
.map(m -> Mention.from(m, recipientResolver, addressResolver))
|
||||
.toList(),
|
||||
.stream()
|
||||
.map(m -> Mention.from(m, recipientResolver, addressResolver))
|
||||
.toList(),
|
||||
quote.getAttachments() == null
|
||||
? List.of()
|
||||
: quote.getAttachments().stream().map(a -> Attachment.from(a, fileProvider)).toList(),
|
||||
quote.getBodyRanges() == null
|
||||
? List.of()
|
||||
: quote.getBodyRanges()
|
||||
.stream()
|
||||
.filter(r -> r.style != null)
|
||||
.map(TextStyle::from)
|
||||
.toList());
|
||||
.stream()
|
||||
.filter(r -> r.style != null)
|
||||
.map(TextStyle::from)
|
||||
.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -599,7 +599,7 @@ public record MessageEnvelope(
|
||||
Boolean.TRUE.equals(pinnedMessage.getForever())
|
||||
? -1
|
||||
: pinnedMessage.getPinDurationInSeconds() == null
|
||||
? 0
|
||||
? 0
|
||||
: pinnedMessage.getPinDurationInSeconds());
|
||||
}
|
||||
}
|
||||
@ -1032,14 +1032,14 @@ public record MessageEnvelope(
|
||||
final var source = !envelope.isUnidentifiedSender() && serviceId != null
|
||||
? recipientResolver.resolveRecipient(serviceId)
|
||||
: envelope.isUnidentifiedSender() && content != null
|
||||
? recipientResolver.resolveRecipient(content.getSender())
|
||||
? recipientResolver.resolveRecipient(content.getSender())
|
||||
: exception instanceof ProtocolException e
|
||||
? recipientResolver.resolveRecipient(e.getSender())
|
||||
? recipientResolver.resolveRecipient(e.getSender())
|
||||
: null;
|
||||
final var sourceDevice = envelope.hasSourceDevice()
|
||||
? envelope.getSourceDevice()
|
||||
: content != null
|
||||
? content.getSenderDevice()
|
||||
? content.getSenderDevice()
|
||||
: exception instanceof ProtocolException e ? e.getSenderDevice() : 0;
|
||||
|
||||
Optional<Receipt> receipt;
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
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;
|
||||
|
||||
public record TurnServer(
|
||||
String username,
|
||||
String password,
|
||||
List<String> urls
|
||||
) {
|
||||
}
|
||||
String username, String password, List<String> urls
|
||||
) {}
|
||||
|
||||
@ -55,7 +55,7 @@ public class ContactHelper {
|
||||
final var version = contact == null
|
||||
? 1
|
||||
: contact.messageExpirationTimeVersion() == Integer.MAX_VALUE
|
||||
? Integer.MAX_VALUE
|
||||
? Integer.MAX_VALUE
|
||||
: contact.messageExpirationTimeVersion() + 1;
|
||||
account.getContactStore()
|
||||
.storeContact(recipientId,
|
||||
|
||||
@ -191,9 +191,11 @@ public final class ProfileHelper {
|
||||
if (uploadProfile) {
|
||||
final var streamDetails = avatar != null && avatar.isPresent()
|
||||
? Utils.createStreamDetails(avatar.get())
|
||||
.first()
|
||||
: forceUploadAvatar && avatar == null ? context.getAvatarStore()
|
||||
.retrieveProfileAvatar(account.getSelfRecipientAddress()) : null;
|
||||
.first()
|
||||
: forceUploadAvatar && avatar == null
|
||||
? context.getAvatarStore()
|
||||
.retrieveProfileAvatar(account.getSelfRecipientAddress())
|
||||
: null;
|
||||
try (streamDetails) {
|
||||
final var avatarUploadParams = streamDetails != null
|
||||
? AvatarUploadParams.forAvatar(streamDetails)
|
||||
|
||||
@ -524,11 +524,11 @@ public class SendHelper {
|
||||
Set<RecipientId> senderKeyTargets = groupInfo.getDistributionId() == null || groupSendEndorsements == null
|
||||
? Set.of()
|
||||
: recipientIds.stream()
|
||||
.filter(s -> this.isSenderKeyCapable(s,
|
||||
addressesMap.get(s),
|
||||
unidentifiedAccessesMap.get(s),
|
||||
groupSendEndorsements))
|
||||
.collect(Collectors.toSet());
|
||||
.filter(s -> this.isSenderKeyCapable(s,
|
||||
addressesMap.get(s),
|
||||
unidentifiedAccessesMap.get(s),
|
||||
groupSendEndorsements))
|
||||
.collect(Collectors.toSet());
|
||||
if (senderKeyTargets.size() < 2) {
|
||||
logger.debug("Too few sender-key-capable users ({}). Doing all legacy sends.", senderKeyTargets.size());
|
||||
senderKeyTargets = Set.of();
|
||||
@ -590,11 +590,11 @@ public class SendHelper {
|
||||
final var expirationMs = Instant.ofEpochMilli(groupSendEndorsementsExpirationMs);
|
||||
final var groupSendTokens = groupSendEndorsements != null && groupSecretParams != null
|
||||
? legacyTargets.stream()
|
||||
.map(groupSendEndorsements::get)
|
||||
.map(endorsement -> Optional.ofNullable(endorsement)
|
||||
.map(e -> e.toFullToken(groupSecretParams, expirationMs))
|
||||
.orElse(null))
|
||||
.toList()
|
||||
.map(groupSendEndorsements::get)
|
||||
.map(endorsement -> Optional.ofNullable(endorsement)
|
||||
.map(e -> e.toFullToken(groupSecretParams, expirationMs))
|
||||
.orElse(null))
|
||||
.toList()
|
||||
: null;
|
||||
final var sealedSenderAccesses = SealedSenderAccess.forFanOutGroupSend(groupSendTokens,
|
||||
senderCertificate,
|
||||
|
||||
@ -941,7 +941,7 @@ public class SignalAccount implements Closeable {
|
||||
profile.isUnrestrictedUnidentifiedAccess()
|
||||
? Profile.UnidentifiedAccessMode.UNRESTRICTED
|
||||
: profile.getUnidentifiedAccess() != null
|
||||
? Profile.UnidentifiedAccessMode.ENABLED
|
||||
? Profile.UnidentifiedAccessMode.ENABLED
|
||||
: Profile.UnidentifiedAccessMode.DISABLED,
|
||||
capabilities,
|
||||
null);
|
||||
|
||||
@ -877,9 +877,9 @@ public class GroupStore {
|
||||
final var members = membersString == null
|
||||
? Set.<RecipientId>of()
|
||||
: Arrays.stream(membersString.split(","))
|
||||
.map(Integer::valueOf)
|
||||
.map(recipientIdCreator::create)
|
||||
.collect(Collectors.toSet());
|
||||
.map(Integer::valueOf)
|
||||
.map(recipientIdCreator::create)
|
||||
.collect(Collectors.toSet());
|
||||
final var expirationTime = resultSet.getInt("expiration_time");
|
||||
final var blocked = resultSet.getBoolean("blocked");
|
||||
final var archived = resultSet.getBoolean("archived");
|
||||
|
||||
@ -115,7 +115,7 @@ public class LegacyJsonIdentityKeyStore {
|
||||
var trustLevel = trustedKey.hasNonNull("trustLevel") ? TrustLevel.fromInt(trustedKey.get(
|
||||
"trustLevel").asInt()) : TrustLevel.TRUSTED_UNVERIFIED;
|
||||
var added = trustedKey.hasNonNull("addedTimestamp") ? new Date(trustedKey.get("addedTimestamp")
|
||||
.asLong()) : new Date();
|
||||
.asLong()) : new Date();
|
||||
identities.add(new LegacyIdentityInfo(address, id, trustLevel, added));
|
||||
} catch (InvalidKeyException e) {
|
||||
logger.warn("Error while decoding key for {}: {}", trustedKeyName, e.getMessage());
|
||||
|
||||
@ -1606,9 +1606,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
||||
profileCapabilities == null
|
||||
? Set.of()
|
||||
: Arrays.stream(profileCapabilities.split(","))
|
||||
.map(Profile.Capability::valueOfOrNull)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet()),
|
||||
.map(Profile.Capability::valueOfOrNull)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet()),
|
||||
PhoneNumberSharingMode.valueOfOrNull(resultSet.getString("profile_phone_number_sharing")));
|
||||
}
|
||||
|
||||
|
||||
@ -321,10 +321,10 @@ public class MessageSendLogStore implements AutoCloseable {
|
||||
return content.dataMessage == null
|
||||
? null
|
||||
: content.dataMessage.group != null && content.dataMessage.group.id != null
|
||||
? content.dataMessage.group.id.toByteArray()
|
||||
? content.dataMessage.group.id.toByteArray()
|
||||
: content.dataMessage.groupV2 != null && content.dataMessage.groupV2.masterKey != null
|
||||
? GroupUtils.getGroupIdV2(new GroupMasterKey(content.dataMessage.groupV2.masterKey.toByteArray()))
|
||||
.serialize()
|
||||
? GroupUtils.getGroupIdV2(new GroupMasterKey(content.dataMessage.groupV2.masterKey.toByteArray()))
|
||||
.serialize()
|
||||
: null;
|
||||
} catch (InvalidInputException e) {
|
||||
logger.warn("Failed to parse groupId id from content");
|
||||
|
||||
@ -78,8 +78,10 @@ public class StickerUtils {
|
||||
throw new StickerPackInvalidException("Could not find find " + pack.cover().file());
|
||||
}
|
||||
|
||||
var contentType = pack.cover().contentType() != null && !pack.cover().contentType().isEmpty() ? pack.cover()
|
||||
.contentType() : getContentType(rootPath, zip, pack.cover().file());
|
||||
var contentType = pack.cover().contentType() != null && !pack.cover().contentType().isEmpty()
|
||||
? pack.cover()
|
||||
.contentType()
|
||||
: getContentType(rootPath, zip, pack.cover().file());
|
||||
cover = new SignalServiceStickerManifestUpload.StickerInfo(data.first(),
|
||||
data.second(),
|
||||
Optional.ofNullable(pack.cover().emoji()).orElse(""),
|
||||
|
||||
@ -204,9 +204,9 @@ public class App {
|
||||
private OutputWriter getOutputWriter(final Command command) throws UserErrorException {
|
||||
final var outputTypeInput = ns.<OutputType>get("output");
|
||||
final var outputType = outputTypeInput == null ? command.getSupportedOutputTypes()
|
||||
.stream()
|
||||
.findFirst()
|
||||
.orElse(null) : outputTypeInput;
|
||||
.stream()
|
||||
.findFirst()
|
||||
.orElse(null) : outputTypeInput;
|
||||
final var writer = new BufferedWriter(new OutputStreamWriter(System.out, IOUtils.getConsoleCharset()));
|
||||
final var outputWriter = outputType == null
|
||||
? null
|
||||
|
||||
@ -612,8 +612,8 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
||||
writer.println("Size: {}{}",
|
||||
attachment.size().isPresent() ? attachment.size().get() + " bytes" : "<unavailable>",
|
||||
attachment.preview().isPresent() ? " (Preview is available: "
|
||||
+ attachment.preview().get().length
|
||||
+ " bytes)" : "");
|
||||
+ attachment.preview().get().length
|
||||
+ " bytes)" : "");
|
||||
}
|
||||
if (attachment.thumbnail().isPresent()) {
|
||||
writer.println("Thumbnail:");
|
||||
|
||||
@ -23,10 +23,7 @@ public class AcceptCallCommand implements JsonRpcLocalCommand {
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.help("Accept an incoming voice call.");
|
||||
subparser.addArgument("--call-id")
|
||||
.type(long.class)
|
||||
.required(true)
|
||||
.help("The call ID to accept.");
|
||||
subparser.addArgument("--call-id").type(long.class).required(true).help("The call ID to accept.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -21,10 +21,7 @@ public class HangupCallCommand implements JsonRpcLocalCommand {
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.help("Hang up an active voice call.");
|
||||
subparser.addArgument("--call-id")
|
||||
.type(long.class)
|
||||
.required(true)
|
||||
.help("The call ID to hang up.");
|
||||
subparser.addArgument("--call-id").type(long.class).required(true).help("The call ID to hang up.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -5,13 +5,10 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.api.CallInfo;
|
||||
import org.asamk.signal.output.JsonWriter;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
import org.asamk.signal.output.PlainTextWriter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ListCallsCommand implements JsonRpcLocalCommand {
|
||||
|
||||
@Override
|
||||
|
||||
@ -109,7 +109,7 @@ public class ListContactsCommand implements JsonRpcLocalCommand {
|
||||
r.getProfile().getPhoneNumberSharingMode() == null
|
||||
? ""
|
||||
: String.valueOf(r.getProfile().getPhoneNumberSharingMode()
|
||||
== PhoneNumberSharingMode.EVERYBODY),
|
||||
== PhoneNumberSharingMode.EVERYBODY),
|
||||
r.getDiscoverable() == null ? "" : String.valueOf(r.getDiscoverable()));
|
||||
}
|
||||
}
|
||||
@ -121,17 +121,17 @@ public class ListContactsCommand implements JsonRpcLocalCommand {
|
||||
final var jsonInternal = !internal
|
||||
? null
|
||||
: new JsonContact.JsonInternal(r.getProfile()
|
||||
.getCapabilities()
|
||||
.stream()
|
||||
.map(Enum::name)
|
||||
.toList(),
|
||||
.getCapabilities()
|
||||
.stream()
|
||||
.map(Enum::name)
|
||||
.toList(),
|
||||
r.getProfile().getUnidentifiedAccessMode() == Profile.UnidentifiedAccessMode.UNKNOWN
|
||||
? null
|
||||
? null
|
||||
: r.getProfile().getUnidentifiedAccessMode().name(),
|
||||
r.getProfile().getPhoneNumberSharingMode() == null
|
||||
? null
|
||||
? null
|
||||
: r.getProfile().getPhoneNumberSharingMode()
|
||||
== PhoneNumberSharingMode.EVERYBODY,
|
||||
== PhoneNumberSharingMode.EVERYBODY,
|
||||
r.getDiscoverable());
|
||||
return new JsonContact(address.number().orElse(null),
|
||||
address.uuid().map(UUID::toString).orElse(null),
|
||||
@ -159,9 +159,9 @@ public class ListContactsCommand implements JsonRpcLocalCommand {
|
||||
r.getProfile().getAboutEmoji(),
|
||||
r.getProfile().getAvatarUrlPath() != null,
|
||||
r.getProfile().getMobileCoinAddress() == null
|
||||
? null
|
||||
? null
|
||||
: Base64.getEncoder()
|
||||
.encodeToString(r.getProfile().getMobileCoinAddress())),
|
||||
.encodeToString(r.getProfile().getMobileCoinAddress())),
|
||||
jsonInternal);
|
||||
}).toList();
|
||||
writer.write(jsonContacts);
|
||||
|
||||
@ -21,10 +21,7 @@ public class RejectCallCommand implements JsonRpcLocalCommand {
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.help("Reject an incoming voice call.");
|
||||
subparser.addArgument("--call-id")
|
||||
.type(long.class)
|
||||
.required(true)
|
||||
.help("The call ID to reject.");
|
||||
subparser.addArgument("--call-id").type(long.class).required(true).help("The call ID to reject.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -82,7 +82,11 @@ public class SendPollCreateCommand implements JsonRpcLocalCommand {
|
||||
throw new UserErrorException("Poll options must not be empty");
|
||||
}
|
||||
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) {
|
||||
return new JsonCallEvent(
|
||||
callInfo.callId(),
|
||||
return new JsonCallEvent(callInfo.callId(),
|
||||
callInfo.state().name(),
|
||||
callInfo.recipient().number().orElse(null),
|
||||
callInfo.recipient().aci().orElse(null),
|
||||
callInfo.isOutgoing(),
|
||||
callInfo.inputDeviceName(),
|
||||
callInfo.outputDeviceName(),
|
||||
reason
|
||||
);
|
||||
reason);
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ record JsonDataMessage(
|
||||
static JsonDataMessage from(MessageEnvelope.Data dataMessage, Manager m) {
|
||||
final var timestamp = dataMessage.timestamp();
|
||||
final var groupInfo = dataMessage.groupContext().isPresent() ? JsonGroupInfo.from(dataMessage.groupContext()
|
||||
.get(), m) : null;
|
||||
.get(), m) : null;
|
||||
final var storyContext = dataMessage.storyContext().isPresent()
|
||||
? JsonStoryContext.from(dataMessage.storyContext().get())
|
||||
: null;
|
||||
@ -48,32 +48,32 @@ record JsonDataMessage(
|
||||
final var quote = dataMessage.quote().isPresent() ? JsonQuote.from(dataMessage.quote().get()) : null;
|
||||
final var payment = dataMessage.payment().isPresent() ? JsonPayment.from(dataMessage.payment().get()) : null;
|
||||
final var mentions = !dataMessage.mentions().isEmpty() ? dataMessage.mentions()
|
||||
.stream()
|
||||
.map(JsonMention::from)
|
||||
.toList() : null;
|
||||
.stream()
|
||||
.map(JsonMention::from)
|
||||
.toList() : null;
|
||||
final var previews = !dataMessage.previews().isEmpty() ? dataMessage.previews()
|
||||
.stream()
|
||||
.map(JsonPreview::from)
|
||||
.toList() : null;
|
||||
.stream()
|
||||
.map(JsonPreview::from)
|
||||
.toList() : null;
|
||||
final var remoteDelete = dataMessage.remoteDeleteId().isPresent()
|
||||
? new JsonRemoteDelete(dataMessage.remoteDeleteId().get())
|
||||
: null;
|
||||
final var attachments = !dataMessage.attachments().isEmpty() ? dataMessage.attachments()
|
||||
.stream()
|
||||
.map(JsonAttachment::from)
|
||||
.toList() : null;
|
||||
.stream()
|
||||
.map(JsonAttachment::from)
|
||||
.toList() : null;
|
||||
final var sticker = dataMessage.sticker().isPresent() ? JsonSticker.from(dataMessage.sticker().get()) : null;
|
||||
final var contacts = !dataMessage.sharedContacts().isEmpty() ? dataMessage.sharedContacts()
|
||||
.stream()
|
||||
.map(JsonSharedContact::from)
|
||||
.toList() : null;
|
||||
.stream()
|
||||
.map(JsonSharedContact::from)
|
||||
.toList() : null;
|
||||
final var pollCreate = dataMessage.pollCreate().map(JsonPollCreate::from).orElse(null);
|
||||
final var pollVote = dataMessage.pollVote().map(JsonPollVote::from).orElse(null);
|
||||
final var pollTerminate = dataMessage.pollTerminate().map(JsonPollTerminate::from).orElse(null);
|
||||
final var textStyles = !dataMessage.textStyles().isEmpty() ? dataMessage.textStyles()
|
||||
.stream()
|
||||
.map(JsonTextStyle::from)
|
||||
.toList() : null;
|
||||
.stream()
|
||||
.map(JsonTextStyle::from)
|
||||
.toList() : null;
|
||||
final var pinMessage = dataMessage.pinMessage().map(JsonPinMessage::from).orElse(null);
|
||||
final var unpinMessage = dataMessage.unpinMessage().map(JsonUnpinMessage::from).orElse(null);
|
||||
final var adminDelete = dataMessage.adminDelete().map(JsonAdminDelete::from).orElse(null);
|
||||
|
||||
@ -31,14 +31,14 @@ public record JsonQuote(
|
||||
: null;
|
||||
|
||||
final var attachments = !quote.attachments().isEmpty() ? quote.attachments()
|
||||
.stream()
|
||||
.map(JsonQuotedAttachment::from)
|
||||
.toList() : List.<JsonQuotedAttachment>of();
|
||||
.stream()
|
||||
.map(JsonQuotedAttachment::from)
|
||||
.toList() : List.<JsonQuotedAttachment>of();
|
||||
|
||||
final var textStyles = !quote.textStyles().isEmpty() ? quote.textStyles()
|
||||
.stream()
|
||||
.map(JsonTextStyle::from)
|
||||
.toList() : null;
|
||||
.stream()
|
||||
.map(JsonTextStyle::from)
|
||||
.toList() : null;
|
||||
|
||||
return new JsonQuote(id, author, authorNumber, authorUuid, text, mentions, attachments, textStyles);
|
||||
}
|
||||
|
||||
@ -23,13 +23,13 @@ public record JsonSendMessageResult(
|
||||
result.isSuccess()
|
||||
? Type.SUCCESS
|
||||
: result.isRateLimitFailure()
|
||||
? Type.RATE_LIMIT_FAILURE
|
||||
? Type.RATE_LIMIT_FAILURE
|
||||
: result.isNetworkFailure()
|
||||
? Type.NETWORK_FAILURE
|
||||
? Type.NETWORK_FAILURE
|
||||
: result.isUnregisteredFailure()
|
||||
? Type.UNREGISTERED_FAILURE
|
||||
? Type.UNREGISTERED_FAILURE
|
||||
: result.isInvalidPreKeyFailure()
|
||||
? Type.INVALID_PRE_KEY_FAILURE
|
||||
? Type.INVALID_PRE_KEY_FAILURE
|
||||
: Type.IDENTITY_FAILURE,
|
||||
result.proofRequiredFailure() != null ? result.proofRequiredFailure().getToken() : null,
|
||||
result.proofRequiredFailure() != null ? result.proofRequiredFailure().getRetryAfterSeconds() : null);
|
||||
|
||||
@ -28,9 +28,9 @@ public record JsonSharedContact(
|
||||
: null;
|
||||
|
||||
final var address = !contact.address().isEmpty() ? contact.address()
|
||||
.stream()
|
||||
.map(JsonContactAddress::from)
|
||||
.toList() : null;
|
||||
.stream()
|
||||
.map(JsonContactAddress::from)
|
||||
.toList() : null;
|
||||
|
||||
final var organization = contact.organization().orElse(null);
|
||||
|
||||
|
||||
@ -47,9 +47,9 @@ record JsonSyncMessage(
|
||||
}
|
||||
|
||||
final var readMessages = !syncMessage.read().isEmpty() ? syncMessage.read()
|
||||
.stream()
|
||||
.map(JsonSyncReadMessage::from)
|
||||
.toList() : null;
|
||||
.stream()
|
||||
.map(JsonSyncReadMessage::from)
|
||||
.toList() : null;
|
||||
|
||||
final JsonSyncMessageType type;
|
||||
if (syncMessage.contacts().isPresent()) {
|
||||
|
||||
@ -2,11 +2,8 @@ package org.asamk.signal.json;
|
||||
|
||||
import org.asamk.signal.manager.api.CallInfo;
|
||||
import org.asamk.signal.manager.api.RecipientAddress;
|
||||
|
||||
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.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
@ -17,7 +14,12 @@ class JsonCallEventTest {
|
||||
@Test
|
||||
void fromWithNumberAndUuid() {
|
||||
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);
|
||||
|
||||
@ -34,7 +36,12 @@ class JsonCallEventTest {
|
||||
@Test
|
||||
void fromWithUuidOnly() {
|
||||
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);
|
||||
|
||||
@ -48,7 +55,12 @@ class JsonCallEventTest {
|
||||
@Test
|
||||
void fromWithNumberOnly() {
|
||||
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);
|
||||
|
||||
@ -81,7 +93,12 @@ class JsonCallEventTest {
|
||||
@Test
|
||||
void fromConnectingState() {
|
||||
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);
|
||||
|
||||
@ -97,8 +114,17 @@ class JsonCallEventTest {
|
||||
void fromWithVariousEndReasons() {
|
||||
var recipient = new RecipientAddress("uuid-1234", null, "+15551111111", null);
|
||||
|
||||
var reasons = new String[]{"local_hangup", "remote_hangup", "rejected", "remote_busy",
|
||||
"ring_timeout", "ice_failed", "tunnel_exit", "tunnel_error", "shutdown"};
|
||||
var reasons = new String[]{
|
||||
"local_hangup",
|
||||
"remote_hangup",
|
||||
"rejected",
|
||||
"remote_busy",
|
||||
"ring_timeout",
|
||||
"ice_failed",
|
||||
"tunnel_exit",
|
||||
"tunnel_error",
|
||||
"shutdown"
|
||||
};
|
||||
|
||||
for (var reason : reasons) {
|
||||
var callInfo = new CallInfo(1L, CallInfo.State.ENDED, recipient, null, null, false);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user