should have allowed saving of encrypted attachments, will add more complexity for images in next update.

This commit is contained in:
crowetic 2024-12-19 21:59:28 -08:00
parent 759f000a00
commit 57219987f3
4 changed files with 30 additions and 12 deletions

Binary file not shown.

Binary file not shown.

View File

@ -887,6 +887,6 @@ function startPollingForNewMessages() {
if (activeRoom) {
await loadMessagesFromQDN(activeRoom, currentPage, true);
}
}, 20000);
}, 40000);
}

View File

@ -797,17 +797,35 @@ async function loadImageHtml(service, name, identifier, filename, mimeType) {
const fetchAndSaveAttachment = async (service, name, identifier, filename, mimeType) => {
const url = `${baseUrl}/arbitrary/${service}/${name}/${identifier}`;
try {
const response = await fetch(url);
const blob = await response.blob();
await qortalRequest({
action: "SAVE_FILE",
blob,
filename: filename,
mimeType
});
} catch (error) {
console.error("Error fetching or saving the attachment:", error);
if ((service === "FILE_PRIVATE") || (service === "MAIL_PRIVATE")) {
service = "FILE_PRIVATE" || service
try{
const encryptedBase64Data = await fetchFileBase64(service, name, identifier)
const decryptedBase64 = await decryptObject(encryptedBase64Data)
const fileBlob = new Blob([decryptedBase64], { type: mimeType });
await qortalRequest({
action: "SAVE_FILE",
blob: fileBlob,
filename,
mimeType
});
}catch (error) {
console.error("Error fetching ro saving encrypted attachment",error)
}
}else{
try {
const response = await fetch(url);
const blob = await response.blob();
await qortalRequest({
action: "SAVE_FILE",
blob,
filename: filename,
mimeType
});
} catch (error) {
console.error("Error fetching or saving the attachment:", error);
}
}
}