Remove dead code and fix inspection issues

This commit is contained in:
AsamK 2021-12-05 10:25:46 +01:00
parent 6ffeb7c431
commit e83f43065e
13 changed files with 10 additions and 82 deletions

View file

@ -131,7 +131,7 @@ public class DbusManagerImpl implements Manager {
emptyIfNull(about),
emptyIfNull(aboutEmoji),
avatar == null ? "" : avatar.map(File::getPath).orElse(""),
avatar != null && !avatar.isPresent());
avatar != null && avatar.isEmpty());
}
@Override
@ -786,9 +786,8 @@ public class DbusManagerImpl implements Manager {
private void notifyMessageHandlers(final MessageEnvelope envelope) {
synchronized (messageHandlers) {
Stream.concat(messageHandlers.stream(), weakHandlers.stream()).forEach(h -> {
h.handleMessage(envelope, null);
});
Stream.concat(messageHandlers.stream(), weakHandlers.stream())
.forEach(h -> h.handleMessage(envelope, null));
}
}

View file

@ -18,12 +18,10 @@ import java.util.stream.Collectors;
public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler {
private final Manager m;
private final DBusConnection conn;
private final String objectPath;
public DbusReceiveMessageHandler(Manager m, DBusConnection conn, final String objectPath) {
this.m = m;
public DbusReceiveMessageHandler(DBusConnection conn, final String objectPath) {
this.conn = conn;
this.objectPath = objectPath;
}
@ -127,7 +125,7 @@ public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler
var attachments = message.attachments()
.stream()
.filter(a -> a.id().isPresent())
.map(a -> getAttachmentMap(m, a))
.map(this::getAttachmentMap)
.collect(Collectors.toList());
extras.put("attachments", new Variant<>(attachments, "aa{sv}"));
}
@ -180,7 +178,7 @@ public class DbusReceiveMessageHandler implements Manager.ReceiveMessageHandler
}
private Map<String, Variant<?>> getAttachmentMap(
final Manager m, final MessageEnvelope.Data.Attachment a
final MessageEnvelope.Data.Attachment a
) {
final var map = new HashMap<String, Variant<?>>();
if (a.id().isPresent()) {

View file

@ -111,7 +111,7 @@ public class DbusSignalImpl implements Signal {
@Override
public void subscribeReceive() {
if (dbusMessageHandler == null) {
dbusMessageHandler = new DbusReceiveMessageHandler(m, connection, objectPath);
dbusMessageHandler = new DbusReceiveMessageHandler(connection, objectPath);
m.addReceiveHandler(dbusMessageHandler);
}
subscriberCount++;

View file

@ -10,8 +10,4 @@ record JsonAttachment(String contentType, String filename, String id, Long size)
final var size = attachment.size().orElse(null);
return new JsonAttachment(attachment.contentType(), filename, id, size);
}
static JsonAttachment from(String filename) {
return new JsonAttachment(filename, null, null, null);
}
}

View file

@ -2,7 +2,6 @@ package org.asamk.signal.json;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.asamk.Signal;
import org.asamk.signal.manager.api.MessageEnvelope;
import java.util.List;
@ -65,38 +64,4 @@ record JsonDataMessage(
contacts,
groupInfo);
}
static JsonDataMessage from(Signal.MessageReceived messageReceived) {
return new JsonDataMessage(messageReceived.getTimestamp(),
messageReceived.getMessage(),
// TODO Replace these with the proper commands
null,
null,
null,
null,
null,
null,
messageReceived.getAttachments().stream().map(JsonAttachment::from).collect(Collectors.toList()),
null,
null,
null,
messageReceived.getGroupId().length > 0 ? JsonGroupInfo.from(messageReceived.getGroupId()) : null);
}
static JsonDataMessage from(Signal.SyncMessageReceived messageReceived) {
return new JsonDataMessage(messageReceived.getTimestamp(),
messageReceived.getMessage(),
// TODO Replace these with the proper commands
null,
null,
null,
null,
null,
null,
messageReceived.getAttachments().stream().map(JsonAttachment::from).collect(Collectors.toList()),
null,
null,
null,
messageReceived.getGroupId().length > 0 ? JsonGroupInfo.from(messageReceived.getGroupId()) : null);
}
}

View file

@ -2,16 +2,10 @@ package org.asamk.signal.json;
import org.asamk.signal.manager.api.MessageEnvelope;
import java.util.Base64;
record JsonGroupInfo(String groupId, String type) {
static JsonGroupInfo from(MessageEnvelope.Data.GroupContext groupContext) {
return new JsonGroupInfo(groupContext.groupId().toBase64(),
groupContext.isGroupUpdate() ? "UPDATE" : "DELIVER");
}
static JsonGroupInfo from(byte[] groupId) {
return new JsonGroupInfo(Base64.getEncoder().encodeToString(groupId), "DELIVER");
}
}

View file

@ -5,8 +5,6 @@ import org.asamk.signal.commands.exceptions.IOErrorException;
import org.asamk.signal.manager.api.ProofRequiredException;
import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.api.SendMessageResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
@ -16,8 +14,6 @@ import java.util.stream.Collectors;
public class ErrorUtils {
private final static Logger logger = LoggerFactory.getLogger(ErrorUtils.class);
private ErrorUtils() {
}