Implemented new Backend in E-Mail Sending

Implemented Blob Return Method for File Download
This commit is contained in:
2025-09-12 17:42:24 +02:00
parent 9a210bceb9
commit 30da08689d
2 changed files with 33 additions and 15 deletions

View File

@@ -31,7 +31,7 @@ const setupPage = async () => {
} else {
emailData.value.account = emailAccounts.value[0].id
preloadedContent.value = `<p></p><p></p><p></p>${profileStore.activeProfile.emailSignature || ""}`
preloadedContent.value = `<p></p><p></p><p></p>${auth.profile.email_signature || ""}`
//Check Query
if(route.query.to) emailData.value.to = route.query.to
@@ -133,25 +133,35 @@ const sendEmail = async () => {
for await (const doc of loadedDocuments.value) {
const {data,error} = await supabase.storage.from("filesdev").download(doc.path)
//const {data,error} = await supabase.storage.from("filesdev").download(doc.path)
const res = await useFiles().downloadFile(doc.id, null, true)
body.attachments.push({
filename: doc.path.split("/")[doc.path.split("/").length -1],
content: await blobToBase64(data),
contentType: data.type,
content: await blobToBase64(res),
contentType: res.type,
encoding: "base64",
contentDisposition: "attachment"
})
}
const { data, error } = await supabase.functions.invoke('send_email', {
body
const res = await useNuxtApp().$api("/api/emailasuser/send",{
method: "POST",
body: body,
})
if(error) {
console.log(res)
/*const { data, error } = await supabase.functions.invoke('send_email', {
body
})*/
if(!res.success) {
toast.add({title: "Fehler beim Absenden der E-Mail", color: "rose"})
} else if(data) {
router.push("/")
} else {
//router.push("/")
toast.add({title: "E-Mail zum Senden eingereiht"})
}