import org.asamk.signal.manager.api.RecipientIdentifier;
import org.asamk.signal.manager.groups.GroupId;
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
+import org.asamk.signal.output.PlainTextWriter;
import org.asamk.signal.util.DateUtils;
import org.slf4j.helpers.MessageFormatter;
@Override
public void handleMessage(MessageEnvelope envelope, Throwable exception) {
+ synchronized (writer) {
+ handleMessageInternal(envelope, exception);
+ }
+ }
+
+ private void handleMessageInternal(MessageEnvelope envelope, Throwable exception) {
var source = envelope.sourceAddress();
writer.println("Envelope from: {} (device: {})",
source.map(this::formatContact).orElse("unknown source"),
"The user’s key is untrusted, either the user has reinstalled Signal or a third party sent this message.");
final var recipientName = e.getSender().getLegacyIdentifier();
writer.println(
- "Use 'signal-cli -u {} listIdentities -n {}', verify the key and run 'signal-cli -u {} trust -v \"FINGER_PRINT\" {}' to mark it as trusted",
+ "Use 'signal-cli -a {} listIdentities -n {}', verify the key and run 'signal-cli -a {} trust -v \"FINGER_PRINT\" {}' to mark it as trusted",
m.getSelfNumber(),
recipientName,
m.getSelfNumber(),
recipientName);
writer.println(
- "If you don't care about security, use 'signal-cli -u {} trust -a {}' to trust it without verification",
+ "If you don't care about security, use 'signal-cli -a {} trust -a {}' to trust it without verification",
m.getSelfNumber(),
recipientName);
} else {
) {
writer.println("Id: {}", quote.id());
writer.println("Author: {}", formatContact(quote.author()));
- writer.println("Text: {}", quote.text());
+ if (quote.text().isPresent()) {
+ writer.println("Text: {}", quote.text().get());
+ }
if (quote.mentions() != null && quote.mentions().size() > 0) {
writer.println("Mentions:");
for (var mention : quote.mentions()) {
if (quote.attachments().size() > 0) {
writer.println("Attachments:");
for (var attachment : quote.attachments()) {
- writer.println("- Filename: {}", attachment.fileName());
- writer.indent(w -> {
- w.println("Type: {}", attachment.contentType());
- w.println("Thumbnail:");
- if (attachment.thumbnail().isPresent()) {
- printAttachment(w, attachment.thumbnail().get());
- }
- });
+ writer.println("- Attachment:");
+ printAttachment(writer.indentedWriter(), attachment);
}
}
}
+ attachment.preview().get().length
+ " bytes)" : "");
}
+ if (attachment.thumbnail().isPresent()) {
+ writer.println("Thumbnail:");
+ printAttachment(writer.indentedWriter(), attachment.thumbnail().get());
+ }
final var flags = new ArrayList<String>();
if (attachment.isVoiceNote()) {
flags.add("voice note");
if (attachment.width().isPresent() || attachment.height().isPresent()) {
writer.println("Dimensions: {}x{}", attachment.width().orElse(0), attachment.height().orElse(0));
}
- if (attachment.id().isPresent()) {
- var file = m.getAttachmentFile(attachment.id().get());
+ if (attachment.file().isPresent()) {
+ var file = attachment.file().get();
if (file.exists()) {
writer.println("Stored plaintext in: {}", file);
}