remove some duplicated code

This commit is contained in:
technillogue 2021-04-25 19:43:16 -04:00
parent 87c0bfc728
commit aef4115f1f
2 changed files with 15 additions and 80 deletions

View file

@ -13,7 +13,6 @@ public class Commands {
addCommand("daemon", new DaemonCommand()); addCommand("daemon", new DaemonCommand());
addCommand("stdio", new StdioCommand()); addCommand("stdio", new StdioCommand());
addCommand("getUserStatus", new GetUserStatusCommand()); addCommand("getUserStatus", new GetUserStatusCommand());
addCommand("getUserStatus", new GetUserStatusCommand());
addCommand("link", new LinkCommand()); addCommand("link", new LinkCommand());
addCommand("listContacts", new ListContactsCommand()); addCommand("listContacts", new ListContactsCommand());
addCommand("listDevices", new ListDevicesCommand()); addCommand("listDevices", new ListDevicesCommand());

View file

@ -14,19 +14,19 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
class JsonReaction { //class JsonReaction {
String emoji; // unicode? // String emoji; // unicode?
String targetAuthor; // String targetAuthor;
long targetTimestamp; // long targetTimestamp;
boolean isRemove; // boolean isRemove;
JsonReaction (SignalServiceDataMessage.Reaction reaction) { // JsonReaction (SignalServiceDataMessage.Reaction reaction) {
this.emoji = reaction.getEmoji(); // this.emoji = reaction.getEmoji();
// comment on this line from ReceiveMessageHandler: todo resolve // // comment on this line from ReceiveMessageHandler: todo resolve
this.targetAuthor = reaction.getTargetAuthor().getLegacyIdentifier(); // this.targetAuthor = reaction.getTargetAuthor().getLegacyIdentifier();
this.targetTimestamp = reaction.getTargetSentTimestamp(); // this.targetTimestamp = reaction.getTargetSentTimestamp();
this.isRemove = reaction.isRemove(); // this.isRemove = reaction.isRemove();
} // }
} //}
class JsonDataMessage { class JsonDataMessage {
@ -52,30 +52,6 @@ class JsonDataMessage {
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
final JsonQuote quote; final JsonQuote quote;
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final List<JsonMention> mentions;
@JsonProperty
final long timestamp;
@JsonProperty
final String message;
@JsonProperty
final Integer expiresInSeconds;
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final Boolean viewOnce;
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final JsonReaction reaction;
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final JsonQuote quote;
@JsonProperty @JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
final List<JsonMention> mentions; final List<JsonMention> mentions;
@ -96,35 +72,6 @@ class JsonDataMessage {
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
final List<JsonSharedContact> contacts; final List<JsonSharedContact> contacts;
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final List<JsonAttachment> attachments;
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final JsonSticker sticker;
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final JsonRemoteDelete remoteDelete;
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final List<JsonSharedContact> contacts;
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final JsonGroupInfo groupInfo;
JsonReaction reaction;
JsonQuote quote;
List<JsonMention> mentions;
List<JsonAttachment> attachments;
JsonGroupInfo groupInfo;
JsonReaction reaction;
SignalServiceDataMessage.Quote quote;
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL)
final JsonGroupInfo groupInfo;
JsonDataMessage(SignalServiceDataMessage dataMessage, Manager m) { JsonDataMessage(SignalServiceDataMessage dataMessage, Manager m) {
this.timestamp = dataMessage.getTimestamp(); this.timestamp = dataMessage.getTimestamp();
@ -180,19 +127,8 @@ class JsonDataMessage {
this.emoji = ""; this.emoji = "";
this.targetAuthor = ""; this.targetAuthor = "";
this.targetTimestamp = 0; this.targetTimestamp = 0;
}*/ }
this.sticker = dataMessage.getSticker().isPresent() ? new JsonSticker(dataMessage.getSticker().get()) : null; if (message.getQuote().isPresent()) {
if (dataMessage.getSharedContacts().isPresent()) {
this.contacts = dataMessage.getSharedContacts()
.get()
.stream()
.map(JsonSharedContact::new)
.collect(Collectors.toList());
} else {
this.contacts = List.of();
}
/* if (message.getQuote().isPresent()) {
SignalServiceDataMessage.Quote quote = message.getQuote().get(); SignalServiceDataMessage.Quote quote = message.getQuote().get();
System.out.println("Quote: (" + quote.getId() + ")"); System.out.println("Quote: (" + quote.getId() + ")");
// there doesn't seem to be any way to find a message's id? // there doesn't seem to be any way to find a message's id?