mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Use var instead of explicit types
This commit is contained in:
parent
03c30519b1
commit
de273586b4
77 changed files with 850 additions and 1017 deletions
|
@ -3,8 +3,6 @@ package org.asamk.signal.json;
|
|||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream;
|
||||
|
||||
class JsonAttachment {
|
||||
|
||||
|
@ -24,12 +22,12 @@ class JsonAttachment {
|
|||
this.contentType = attachment.getContentType();
|
||||
|
||||
if (attachment.isPointer()) {
|
||||
final SignalServiceAttachmentPointer pointer = attachment.asPointer();
|
||||
final var pointer = attachment.asPointer();
|
||||
this.id = pointer.getRemoteId().toString();
|
||||
this.filename = pointer.getFileName().orNull();
|
||||
this.size = pointer.getSize().transform(Integer::longValue).orNull();
|
||||
} else {
|
||||
final SignalServiceAttachmentStream stream = attachment.asStream();
|
||||
final var stream = attachment.asStream();
|
||||
this.id = null;
|
||||
this.filename = stream.getFileName().orNull();
|
||||
this.size = stream.getLength();
|
||||
|
|
|
@ -6,9 +6,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
import org.asamk.Signal;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroupContext;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -63,12 +60,12 @@ class JsonDataMessage {
|
|||
JsonDataMessage(SignalServiceDataMessage dataMessage, Manager m) {
|
||||
this.timestamp = dataMessage.getTimestamp();
|
||||
if (dataMessage.getGroupContext().isPresent()) {
|
||||
final SignalServiceGroupContext groupContext = dataMessage.getGroupContext().get();
|
||||
final var groupContext = dataMessage.getGroupContext().get();
|
||||
if (groupContext.getGroupV1().isPresent()) {
|
||||
SignalServiceGroup groupInfo = groupContext.getGroupV1().get();
|
||||
var groupInfo = groupContext.getGroupV1().get();
|
||||
this.groupInfo = new JsonGroupInfo(groupInfo);
|
||||
} else if (groupContext.getGroupV2().isPresent()) {
|
||||
SignalServiceGroupV2 groupInfo = groupContext.getGroupV2().get();
|
||||
var groupInfo = groupContext.getGroupV2().get();
|
||||
this.groupInfo = new JsonGroupInfo(groupInfo);
|
||||
} else {
|
||||
this.groupInfo = null;
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.asamk.Signal;
|
|||
import org.asamk.signal.manager.Manager;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceContent;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -48,7 +47,7 @@ public class JsonMessageEnvelope {
|
|||
|
||||
public JsonMessageEnvelope(SignalServiceEnvelope envelope, SignalServiceContent content, Manager m) {
|
||||
if (!envelope.isUnidentifiedSender() && envelope.hasSource()) {
|
||||
SignalServiceAddress source = envelope.getSourceAddress();
|
||||
var source = envelope.getSourceAddress();
|
||||
this.source = source.getLegacyIdentifier();
|
||||
this.sourceDevice = envelope.getSourceDevice();
|
||||
this.relay = source.getRelay().orNull();
|
||||
|
|
|
@ -45,7 +45,7 @@ class JsonSyncMessage {
|
|||
? new JsonSyncDataMessage(syncMessage.getSent().get(), m)
|
||||
: null;
|
||||
if (syncMessage.getBlockedList().isPresent()) {
|
||||
final Base64.Encoder base64 = Base64.getEncoder();
|
||||
final var base64 = Base64.getEncoder();
|
||||
this.blockedNumbers = syncMessage.getBlockedList()
|
||||
.get()
|
||||
.getAddresses()
|
||||
|
|
|
@ -22,7 +22,7 @@ class JsonTypingMessage {
|
|||
JsonTypingMessage(SignalServiceTypingMessage typingMessage) {
|
||||
this.action = typingMessage.getAction().name();
|
||||
this.timestamp = typingMessage.getTimestamp();
|
||||
final Base64.Encoder encoder = Base64.getEncoder();
|
||||
final var encoder = Base64.getEncoder();
|
||||
this.groupId = typingMessage.getGroupId().transform(encoder::encodeToString).orNull();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue