mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-05 13:40:38 +00:00
Fixed issues and added mentions in quotes
This commit is contained in:
parent
7eb0487719
commit
ee2848db23
7 changed files with 68 additions and 34 deletions
|
@ -42,12 +42,12 @@ class JsonDataMessage {
|
|||
this.reaction = new JsonReaction(dataMessage.getReaction().get(), m);
|
||||
}
|
||||
if (dataMessage.getQuote().isPresent()) {
|
||||
this.quote = new JsonQuote(dataMessage.getQuote().get());
|
||||
this.quote = new JsonQuote(dataMessage.getQuote().get(), m);
|
||||
}
|
||||
if (dataMessage.getMentions().isPresent()) {
|
||||
this.mentions = new ArrayList<>(dataMessage.getMentions().get().size());
|
||||
for (SignalServiceDataMessage.Mention mention : dataMessage.getMentions().get()) {
|
||||
this.mentions.add(new JsonMention(mention));
|
||||
this.mentions.add(new JsonMention(mention, m));
|
||||
}
|
||||
} else {
|
||||
this.mentions = new ArrayList<>();
|
||||
|
|
|
@ -32,7 +32,6 @@ class JsonGroupInfo {
|
|||
|
||||
JsonGroupInfo(SignalServiceGroupV2 groupInfo) {
|
||||
this.groupId = Base64.encodeBytes(GroupUtils.getGroupId(groupInfo.getMasterKey()));
|
||||
// TODO populate members and name fields
|
||||
this.type = groupInfo.hasSignedGroupChange() ? "UPDATE" : "DELIVER";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
package org.asamk.signal.json;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
public class JsonMention {
|
||||
|
||||
UUID uuid;
|
||||
String name;
|
||||
int start;
|
||||
int length;
|
||||
|
||||
JsonMention(SignalServiceDataMessage.Mention mention) {
|
||||
this.uuid = mention.getUuid();
|
||||
JsonMention(SignalServiceDataMessage.Mention mention, Manager m) {
|
||||
this.name = m.resolveSignalServiceAddress(
|
||||
new SignalServiceAddress(mention.getUuid(), null)
|
||||
).getLegacyIdentifier();
|
||||
this.start = mention.getStart();
|
||||
this.length = mention.getLength();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,9 +19,7 @@ public class JsonMessageEnvelope {
|
|||
JsonCallMessage callMessage;
|
||||
JsonReceiptMessage receiptMessage;
|
||||
|
||||
public JsonMessageEnvelope(
|
||||
SignalServiceEnvelope envelope, SignalServiceContent content, Manager m
|
||||
) {
|
||||
public JsonMessageEnvelope(SignalServiceEnvelope envelope, SignalServiceContent content, Manager m) {
|
||||
if (!envelope.isUnidentifiedSender() && envelope.hasSource()) {
|
||||
SignalServiceAddress source = envelope.getSourceAddress();
|
||||
this.source = source.getLegacyIdentifier();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.asamk.signal.json;
|
||||
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -11,27 +11,28 @@ public class JsonQuote {
|
|||
long id;
|
||||
String author;
|
||||
String text;
|
||||
List<JsonAttachment> attachments;
|
||||
|
||||
JsonQuote(SignalServiceDataMessage.Quote quote) {
|
||||
List<JsonMention> mentions;
|
||||
List<JsonQuotedAttachment> attachments;
|
||||
|
||||
JsonQuote(SignalServiceDataMessage.Quote quote, Manager m) {
|
||||
this.id = quote.getId();
|
||||
this.author = quote.getAuthor().getLegacyIdentifier();
|
||||
this.author = m.resolveSignalServiceAddress(quote.getAuthor()).getLegacyIdentifier();
|
||||
this.text = quote.getText();
|
||||
|
||||
if (quote.getMentions().size() > 0) {
|
||||
this.mentions = new ArrayList<>(quote.getMentions().size());
|
||||
|
||||
for (SignalServiceDataMessage.Mention quotedMention: quote.getMentions()){
|
||||
this.mentions.add(new JsonMention(quotedMention, m));
|
||||
}
|
||||
}
|
||||
|
||||
if (quote.getAttachments().size() > 0) {
|
||||
this.attachments = new ArrayList<>(quote.getAttachments().size());
|
||||
|
||||
SignalServiceAttachmentPointer attachmentPointer;
|
||||
for (SignalServiceDataMessage.Quote.QuotedAttachment quotedAttachment : quote.getAttachments()) {
|
||||
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);
|
||||
this.attachments.add(new JsonQuotedAttachment(quotedAttachment));
|
||||
}
|
||||
} else {
|
||||
this.attachments = new ArrayList<>();
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package org.asamk.signal.json;
|
||||
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
|
||||
public class JsonQuotedAttachment {
|
||||
|
||||
String contextType;
|
||||
String filename;
|
||||
JsonAttachment thumbnail;
|
||||
|
||||
JsonQuotedAttachment(SignalServiceDataMessage.Quote.QuotedAttachment quotedAttachment) {
|
||||
contextType = quotedAttachment.getContentType();
|
||||
filename = quotedAttachment.getFileName();
|
||||
if (quotedAttachment.getThumbnail() != null) {
|
||||
thumbnail = new JsonAttachment(quotedAttachment.getThumbnail());
|
||||
}
|
||||
else {
|
||||
thumbnail = null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue