mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-20 15:10:41 +00:00
Add federation support for attachment retrieval.
This commit is contained in:
@@ -57,6 +57,11 @@ public class IncomingMediaMessage {
|
||||
media.setContentType(Util.toIsoBytes(attachment.getContentType()));
|
||||
media.setContentLocation(Util.toIsoBytes(String.valueOf(attachment.getId())));
|
||||
media.setContentDisposition(Util.toIsoBytes(Base64.encodeBytes(encryptedKey)));
|
||||
|
||||
if (message.getRelay() != null) {
|
||||
media.setName(Util.toIsoBytes(message.getRelay()));
|
||||
}
|
||||
|
||||
media.setPendingPush(true);
|
||||
|
||||
body.addPart(media);
|
||||
|
@@ -69,8 +69,13 @@ public class PushDownloader {
|
||||
MasterCipher masterCipher = new MasterCipher(masterSecret);
|
||||
long contentLocation = Long.parseLong(Util.toIsoString(part.getContentLocation()));
|
||||
byte[] key = masterCipher.decryptBytes(Base64.decode(Util.toIsoString(part.getContentDisposition())));
|
||||
String relay = null;
|
||||
|
||||
attachmentFile = downloadAttachment(contentLocation);
|
||||
if (part.getName() != null) {
|
||||
relay = Util.toIsoString(part.getName());
|
||||
}
|
||||
|
||||
attachmentFile = downloadAttachment(relay, contentLocation);
|
||||
InputStream attachmentInput = new AttachmentCipherInputStream(attachmentFile, key);
|
||||
|
||||
database.updateDownloadedPart(messageId, partId, part, attachmentInput);
|
||||
@@ -97,9 +102,9 @@ public class PushDownloader {
|
||||
}
|
||||
}
|
||||
|
||||
private File downloadAttachment(long contentLocation) throws IOException {
|
||||
private File downloadAttachment(String relay, long contentLocation) throws IOException {
|
||||
PushServiceSocket socket = new PushServiceSocket(context, TextSecurePushCredentials.getInstance());
|
||||
return socket.retrieveAttachment(contentLocation);
|
||||
return socket.retrieveAttachment(relay, contentLocation);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user