Fix sending mail in guest mode

This commit is contained in:
Booteille 2024-12-07 15:09:32 +01:00
parent 3640e22239
commit cc3cc0681a
No known key found for this signature in database
GPG Key ID: 0FE17AFD5A1F837F
2 changed files with 36 additions and 43 deletions

View File

@ -100,15 +100,14 @@ document.addEventListener("DOMContentLoaded", () => {
/** /**
* [Invitation feature] Send URLs of files to server * [Invitation feature] Send URLs of files to server
*/ */
const sendFilesURLs = () => { const sendGuestFiles = (fileURL) => {
if (filesURLs.length > 0) { fetch(sendGuestFileURL, {
fetch(sendFilesURLsURL, {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
body: JSON.stringify({ body: JSON.stringify({
urls: filesURLs, urls: [fileURL],
}), }),
}) })
.then((response) => response.json()) .then((response) => response.json())
@ -122,7 +121,6 @@ document.addEventListener("DOMContentLoaded", () => {
.catch((error) => { .catch((error) => {
console.error("Error:", error); console.error("Error:", error);
}); });
}
}; };
/** /**
@ -224,8 +222,7 @@ document.addEventListener("DOMContentLoaded", () => {
job.lufiFile.downloadUrl(); job.lufiFile.downloadUrl();
uploadedFileCard.querySelector(".action-delete").href = uploadedFileCard.querySelector(".action-delete").href =
job.lufiFile.removeUrl(); job.lufiFile.removeUrl();
uploadedFileCard.querySelector(".action-share").href = `${ uploadedFileCard.querySelector(".action-share").href = `${job.lufiFile.serverUrl
job.lufiFile.serverUrl
}m?links=${encodeURIComponent( }m?links=${encodeURIComponent(
'["' + job.lufiFile.keys.server + '"]' '["' + job.lufiFile.keys.server + '"]'
)}`; )}`;
@ -266,8 +263,7 @@ document.addEventListener("DOMContentLoaded", () => {
} }
if (isGuest && job.lufiFile.keys.server !== null) { if (isGuest && job.lufiFile.keys.server !== null) {
filesURLs.push( sendGuestFiles(JSON.stringify({
JSON.stringify({
name: job.lufiFile.name, name: job.lufiFile.name,
short: job.lufiFile.keys.server, short: job.lufiFile.keys.server,
url: job.lufiFile.downloadUrl(), url: job.lufiFile.downloadUrl(),
@ -275,10 +271,7 @@ document.addEventListener("DOMContentLoaded", () => {
created_at: job.lufiFile.createdAt, created_at: job.lufiFile.createdAt,
delay, delay,
token: job.lufiFile.actionToken, token: job.lufiFile.actionToken,
}) }));
);
sendFilesURLs();
} }
return okAsync(job); return okAsync(job);

View File

@ -342,7 +342,7 @@ const maxSize = <%= config('max_file_size') || 0 %>;
% if (defined stash('invitation')) { % if (defined stash('invitation')) {
const isGuest = true; const isGuest = true;
const sendFilesURLsURL = '<%= url_for('guest_send_mail', token => stash('invitation')->token)->to_abs() %>'; const sendGuestFileURL = '<%= url_for('guest_send_mail', token => stash('invitation')->token)->to_abs() %>';
% } else { % } else {
const isGuest = false; const isGuest = false;
% } % }