Removed 2nd JsonAttachments contructor and cleaned up some comments

This commit is contained in:
david-harley 2020-12-22 15:23:44 +10:30
parent 1de0bbd4f7
commit 5767853ef0
4 changed files with 15 additions and 22 deletions

View file

@ -25,20 +25,6 @@ class JsonAttachment {
}
}
// Used for the quoted attachments
JsonAttachment(SignalServiceAttachment attachment, String filename) {
this.contentType = attachment.getContentType();
final SignalServiceAttachmentPointer pointer = attachment.asPointer();
if (attachment.isPointer()) {
this.id = String.valueOf(pointer.getRemoteId());
this.filename = filename;
if (pointer.getSize().isPresent()) {
this.size = pointer.getSize().get();
}
}
}
JsonAttachment(String filename) {
this.filename = filename;
}

View file

@ -73,7 +73,7 @@ class JsonDataMessage {
timestamp = messageReceived.getTimestamp();
message = messageReceived.getMessage();
groupInfo = new JsonGroupInfo(messageReceived.getGroupId());
reaction = null; // TEMP until I understand how to do this
reaction = null; // TODO Replace these 3 with the proper commands
quote = null;
mentions = null;
attachments = messageReceived.getAttachments().stream().map(JsonAttachment::new).collect(Collectors.toList());
@ -83,7 +83,7 @@ class JsonDataMessage {
timestamp = messageReceived.getTimestamp();
message = messageReceived.getMessage();
groupInfo = new JsonGroupInfo(messageReceived.getGroupId());
reaction = null; // TEMP until I understand how to do this
reaction = null; // TODO Replace these 3 with the proper commands
quote = null;
mentions = null;
attachments = messageReceived.getAttachments().stream().map(JsonAttachment::new).collect(Collectors.toList());

View file

@ -5,7 +5,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
public class JsonMention {
UUID uuid; // If possible, it would be nice to resolve this into their phone-number/name. Same for plain-text output
UUID uuid;
int start;
int length;

View file

@ -1,5 +1,6 @@
package org.asamk.signal.json;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
import java.util.ArrayList;
@ -19,12 +20,18 @@ public class JsonQuote {
if (quote.getAttachments().size() > 0) {
this.attachments = new ArrayList<>(quote.getAttachments().size());
SignalServiceAttachmentPointer attachmentPointer;
for (SignalServiceDataMessage.Quote.QuotedAttachment quotedAttachment : quote.getAttachments()) {
// We use this constructor to override the filename since the one in the thumbnail is lost
this.attachments.add(new JsonAttachment(
quotedAttachment.getThumbnail(),
quotedAttachment.getFileName()
));
JsonAttachment recentAttachment = new JsonAttachment(quotedAttachment.getThumbnail());
// Its possible the name might be missing, if it is then we'll use the other one
attachmentPointer = quotedAttachment.getThumbnail().asPointer();
if (!attachmentPointer.getFileName().isPresent()) {
recentAttachment.filename = quotedAttachment.getFileName();
}
this.attachments.add(recentAttachment);
}
} else {
this.attachments = new ArrayList<>();