mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-03 12:50:37 +00:00
Add command to get an attachment
This commit is contained in:
parent
49aaff2bbe
commit
589f5378df
9 changed files with 97 additions and 0 deletions
|
@ -0,0 +1,3 @@
|
|||
package org.asamk.signal.manager;
|
||||
|
||||
public record AttachmentPointer(String id, String fileName, String contentType) {}
|
|
@ -39,6 +39,12 @@ public class AttachmentStore {
|
|||
Optional.ofNullable(pointer.getContentType()));
|
||||
}
|
||||
|
||||
public File getAttachmentFile(AttachmentPointer pointer) {
|
||||
return getAttachmentFile(SignalServiceAttachmentRemoteId.from(pointer.id()),
|
||||
Optional.ofNullable(pointer.fileName()),
|
||||
Optional.ofNullable(pointer.contentType()));
|
||||
}
|
||||
|
||||
private void storeAttachment(final File attachmentFile, final AttachmentStorer storer) throws IOException {
|
||||
createAttachmentsDir();
|
||||
try (OutputStream output = new FileOutputStream(attachmentFile)) {
|
||||
|
|
|
@ -272,6 +272,8 @@ public interface Manager extends Closeable {
|
|||
|
||||
void addClosedListener(Runnable listener);
|
||||
|
||||
File getAttachmentFile(AttachmentPointer pointer);
|
||||
|
||||
@Override
|
||||
void close() throws IOException;
|
||||
|
||||
|
|
|
@ -1147,6 +1147,10 @@ class ManagerImpl implements Manager {
|
|||
}
|
||||
}
|
||||
|
||||
public File getAttachmentFile(AttachmentPointer pointer) {
|
||||
return context.getAttachmentHelper().getAttachmentFile(pointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
Thread thread;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.asamk.signal.manager.helper;
|
||||
|
||||
import org.asamk.signal.manager.AttachmentPointer;
|
||||
import org.asamk.signal.manager.AttachmentStore;
|
||||
import org.asamk.signal.manager.SignalDependencies;
|
||||
import org.asamk.signal.manager.api.AttachmentInvalidException;
|
||||
|
@ -38,6 +39,11 @@ public class AttachmentHelper {
|
|||
return attachmentStore.getAttachmentFile(pointer);
|
||||
}
|
||||
|
||||
public File getAttachmentFile(AttachmentPointer pointer) {
|
||||
return attachmentStore.getAttachmentFile(pointer);
|
||||
}
|
||||
|
||||
|
||||
public List<SignalServiceAttachment> uploadAttachments(final List<String> attachments) throws AttachmentInvalidException, IOException {
|
||||
var attachmentStreams = AttachmentUtils.createAttachmentStreams(attachments);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue