mirror of
https://github.com/aljazceru/signal-cli.git
synced 2025-12-23 09:04:26 +01:00
Output json when receiving messages from dbus and --json parameter is given
Fixes #138
This commit is contained in:
31
src/main/java/org/asamk/signal/json/JsonAttachment.java
Normal file
31
src/main/java/org/asamk/signal/json/JsonAttachment.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package org.asamk.signal.json;
|
||||
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer;
|
||||
|
||||
class JsonAttachment {
|
||||
|
||||
String contentType;
|
||||
String filename;
|
||||
String id;
|
||||
int size;
|
||||
|
||||
JsonAttachment(SignalServiceAttachment attachment) {
|
||||
this.contentType = attachment.getContentType();
|
||||
|
||||
final SignalServiceAttachmentPointer pointer = attachment.asPointer();
|
||||
if (attachment.isPointer()) {
|
||||
this.id = String.valueOf(pointer.getId());
|
||||
if (pointer.getFileName().isPresent()) {
|
||||
this.filename = pointer.getFileName().get();
|
||||
}
|
||||
if (pointer.getSize().isPresent()) {
|
||||
this.size = pointer.getSize().get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JsonAttachment(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user