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

@ -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");
}
}