This commit is contained in:
@@ -30,6 +30,7 @@ import org.springframework.mail.javamail.MimeMessageHelper;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -80,9 +81,9 @@ public class SendEmailV2Service {
|
|||||||
notificationService.sendMessage(Topic.LOG, LogNotification.info(successMessage));
|
notificationService.sendMessage(Topic.LOG, LogNotification.info(successMessage));
|
||||||
log.info(successMessage);
|
log.info(successMessage);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String errorMessage = "An error occurred while sending the book: " + bookTitle + " to " + recipientEmail + ". Error: " + e.getMessage();
|
String userMessage = "Failed to send book: " + bookTitle + " to " + recipientEmail + ". " + extractUserFriendlyMessage(e);
|
||||||
notificationService.sendMessage(Topic.LOG, LogNotification.error(errorMessage));
|
notificationService.sendMessage(Topic.LOG, LogNotification.error(userMessage));
|
||||||
log.error(errorMessage, e);
|
log.error("Email send failed for book '{}' to {}: {}", bookTitle, recipientEmail, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -202,6 +203,20 @@ public class SendEmailV2Service {
|
|||||||
.orElseThrow(ApiError.DEFAULT_EMAIL_PROVIDER_NOT_FOUND::createException);
|
.orElseThrow(ApiError.DEFAULT_EMAIL_PROVIDER_NOT_FOUND::createException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String extractUserFriendlyMessage(Exception e) {
|
||||||
|
Throwable cause = e;
|
||||||
|
while (cause != null) {
|
||||||
|
if (cause instanceof IOException) {
|
||||||
|
return "The email provider rejected or dropped the connection during transfer. This often happens when the attachment exceeds the provider's size limit.";
|
||||||
|
}
|
||||||
|
cause = cause.getCause();
|
||||||
|
}
|
||||||
|
if (e instanceof MessagingException) {
|
||||||
|
return "The email could not be sent due to a mail server error. Please verify your email provider settings.";
|
||||||
|
}
|
||||||
|
return "An unexpected error occurred: " + e.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
private enum ConnectionType {
|
private enum ConnectionType {
|
||||||
SSL,
|
SSL,
|
||||||
STARTTLS,
|
STARTTLS,
|
||||||
|
|||||||
+34
-17
@@ -415,23 +415,40 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
label: this.t.translate('book.card.menu.quickSend'),
|
label: this.t.translate('book.card.menu.quickSend'),
|
||||||
icon: 'pi pi-envelope',
|
icon: 'pi pi-envelope',
|
||||||
command: () => {
|
command: () => {
|
||||||
this.emailService.emailBookQuick(this.book.id).subscribe({
|
const doSend = () => {
|
||||||
next: () => {
|
this.emailService.emailBookQuick(this.book.id).subscribe({
|
||||||
this.messageService.add({
|
next: () => {
|
||||||
severity: 'info',
|
this.messageService.add({
|
||||||
summary: this.t.translate('common.success'),
|
severity: 'info',
|
||||||
detail: this.t.translate('book.card.toast.quickSendSuccessDetail'),
|
summary: this.t.translate('common.success'),
|
||||||
});
|
detail: this.t.translate('book.card.toast.quickSendSuccessDetail'),
|
||||||
},
|
});
|
||||||
error: (err) => {
|
},
|
||||||
const errorMessage = err?.error?.message || this.t.translate('book.card.toast.quickSendErrorDetail');
|
error: (err) => {
|
||||||
this.messageService.add({
|
const errorMessage = err?.error?.message || this.t.translate('book.card.toast.quickSendErrorDetail');
|
||||||
severity: 'error',
|
this.messageService.add({
|
||||||
summary: this.t.translate('common.error'),
|
severity: 'error',
|
||||||
detail: errorMessage,
|
summary: this.t.translate('common.error'),
|
||||||
});
|
detail: errorMessage,
|
||||||
},
|
});
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.book.primaryFile?.fileSizeKb && this.book.primaryFile.fileSizeKb > 25 * 1024) {
|
||||||
|
this.confirmationService.confirm({
|
||||||
|
message: this.t.translate('book.card.confirm.largeFileMessage'),
|
||||||
|
header: this.t.translate('book.card.confirm.largeFileHeader'),
|
||||||
|
icon: 'pi pi-exclamation-triangle',
|
||||||
|
acceptLabel: this.t.translate('book.card.confirm.sendAnyway'),
|
||||||
|
rejectLabel: this.t.translate('common.cancel'),
|
||||||
|
acceptButtonProps: { severity: 'warn' },
|
||||||
|
rejectButtonProps: { severity: 'secondary' },
|
||||||
|
accept: doSend,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
doSend();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+31
-14
@@ -268,7 +268,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
|
|||||||
{
|
{
|
||||||
label: this.t.translate('metadata.viewer.menuQuickSend'),
|
label: this.t.translate('metadata.viewer.menuQuickSend'),
|
||||||
icon: 'pi pi-bolt',
|
icon: 'pi pi-bolt',
|
||||||
command: () => this.quickSend(book.id)
|
command: () => this.quickSend(book)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: this.t.translate('metadata.viewer.menuCustomSend'),
|
label: this.t.translate('metadata.viewer.menuCustomSend'),
|
||||||
@@ -646,19 +646,36 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
|
|||||||
}, 15000);
|
}, 15000);
|
||||||
}
|
}
|
||||||
|
|
||||||
quickSend(bookId: number) {
|
quickSend(book: Book) {
|
||||||
this.emailService.emailBookQuick(bookId).subscribe({
|
const doSend = () => {
|
||||||
next: () => this.messageService.add({
|
this.emailService.emailBookQuick(book.id).subscribe({
|
||||||
severity: 'info',
|
next: () => this.messageService.add({
|
||||||
summary: this.t.translate('metadata.viewer.toast.quickSendSuccessSummary'),
|
severity: 'info',
|
||||||
detail: this.t.translate('metadata.viewer.toast.quickSendSuccessDetail'),
|
summary: this.t.translate('metadata.viewer.toast.quickSendSuccessSummary'),
|
||||||
}),
|
detail: this.t.translate('metadata.viewer.toast.quickSendSuccessDetail'),
|
||||||
error: (err) => this.messageService.add({
|
}),
|
||||||
severity: 'error',
|
error: (err) => this.messageService.add({
|
||||||
summary: this.t.translate('metadata.viewer.toast.quickSendErrorSummary'),
|
severity: 'error',
|
||||||
detail: err?.error?.message || this.t.translate('metadata.viewer.toast.quickSendErrorDetail'),
|
summary: this.t.translate('metadata.viewer.toast.quickSendErrorSummary'),
|
||||||
})
|
detail: err?.error?.message || this.t.translate('metadata.viewer.toast.quickSendErrorDetail'),
|
||||||
});
|
})
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (book.primaryFile?.fileSizeKb && book.primaryFile.fileSizeKb > 25 * 1024) {
|
||||||
|
this.confirmationService.confirm({
|
||||||
|
message: this.t.translate('metadata.viewer.confirm.largeFileMessage'),
|
||||||
|
header: this.t.translate('metadata.viewer.confirm.largeFileHeader'),
|
||||||
|
icon: 'pi pi-exclamation-triangle',
|
||||||
|
acceptLabel: this.t.translate('metadata.viewer.confirm.sendAnyway'),
|
||||||
|
rejectLabel: this.t.translate('common.cancel'),
|
||||||
|
acceptButtonProps: { severity: 'warn' },
|
||||||
|
rejectButtonProps: { severity: 'secondary' },
|
||||||
|
accept: doSend,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
doSend();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assignShelf(bookId: number) {
|
assignShelf(bookId: number) {
|
||||||
|
|||||||
@@ -101,7 +101,10 @@
|
|||||||
"deleteBookMessage": "Are you sure you want to delete \"{{ title }}\"?\n\nThis will permanently remove the book file from your filesystem.\n\nThis action cannot be undone.",
|
"deleteBookMessage": "Are you sure you want to delete \"{{ title }}\"?\n\nThis will permanently remove the book file from your filesystem.\n\nThis action cannot be undone.",
|
||||||
"deleteBookHeader": "Confirm Deletion",
|
"deleteBookHeader": "Confirm Deletion",
|
||||||
"deleteFileMessage": "Are you sure you want to delete the additional file \"{{ fileName }}\"?",
|
"deleteFileMessage": "Are you sure you want to delete the additional file \"{{ fileName }}\"?",
|
||||||
"deleteFileHeader": "Confirm File Deletion"
|
"deleteFileHeader": "Confirm File Deletion",
|
||||||
|
"largeFileMessage": "This file exceeds 25MB. Some email providers may reject large attachments.\n\nDo you want to send it anyway?",
|
||||||
|
"largeFileHeader": "Large File Warning",
|
||||||
|
"sendAnyway": "Send Anyway"
|
||||||
},
|
},
|
||||||
"toast": {
|
"toast": {
|
||||||
"quickSendSuccessDetail": "The book sending has been scheduled.",
|
"quickSendSuccessDetail": "The book sending has been scheduled.",
|
||||||
|
|||||||
@@ -383,7 +383,10 @@
|
|||||||
"detachFileBtn": "Detach",
|
"detachFileBtn": "Detach",
|
||||||
"deleteBookMessage": "Are you sure you want to delete \"{{ title }}\"?\n\nThis will permanently remove the book record from your library.\n\nThis action cannot be undone.",
|
"deleteBookMessage": "Are you sure you want to delete \"{{ title }}\"?\n\nThis will permanently remove the book record from your library.\n\nThis action cannot be undone.",
|
||||||
"deleteBookAllFilesMessage": "Are you sure you want to delete \"{{ title }}\"?\n\nThis will permanently remove the book record AND all associated files from your filesystem.\n\nThis action cannot be undone.",
|
"deleteBookAllFilesMessage": "Are you sure you want to delete \"{{ title }}\"?\n\nThis will permanently remove the book record AND all associated files from your filesystem.\n\nThis action cannot be undone.",
|
||||||
"deleteEverythingBtn": "Delete Everything"
|
"deleteEverythingBtn": "Delete Everything",
|
||||||
|
"largeFileMessage": "This file exceeds 25MB. Some email providers may reject large attachments.\n\nDo you want to send it anyway?",
|
||||||
|
"largeFileHeader": "Large File Warning",
|
||||||
|
"sendAnyway": "Send Anyway"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sidecar": {
|
"sidecar": {
|
||||||
|
|||||||
@@ -101,7 +101,10 @@
|
|||||||
"deleteBookMessage": "¿Estás seguro de que deseas eliminar \"{{ title }}\"?\n\nEsto eliminará permanentemente el archivo del libro de tu sistema de archivos.\n\nEsta acción no se puede deshacer.",
|
"deleteBookMessage": "¿Estás seguro de que deseas eliminar \"{{ title }}\"?\n\nEsto eliminará permanentemente el archivo del libro de tu sistema de archivos.\n\nEsta acción no se puede deshacer.",
|
||||||
"deleteBookHeader": "Confirmar eliminación",
|
"deleteBookHeader": "Confirmar eliminación",
|
||||||
"deleteFileMessage": "¿Estás seguro de que deseas eliminar el archivo adicional \"{{ fileName }}\"?",
|
"deleteFileMessage": "¿Estás seguro de que deseas eliminar el archivo adicional \"{{ fileName }}\"?",
|
||||||
"deleteFileHeader": "Confirmar eliminación de archivo"
|
"deleteFileHeader": "Confirmar eliminación de archivo",
|
||||||
|
"largeFileMessage": "Este archivo supera los 25 MB. Algunos proveedores de correo pueden rechazar archivos adjuntos grandes.\n\n¿Deseas enviarlo de todos modos?",
|
||||||
|
"largeFileHeader": "Advertencia de archivo grande",
|
||||||
|
"sendAnyway": "Enviar de todos modos"
|
||||||
},
|
},
|
||||||
"toast": {
|
"toast": {
|
||||||
"quickSendSuccessDetail": "El envío del libro ha sido programado.",
|
"quickSendSuccessDetail": "El envío del libro ha sido programado.",
|
||||||
|
|||||||
@@ -383,7 +383,10 @@
|
|||||||
"detachFileBtn": "Separar",
|
"detachFileBtn": "Separar",
|
||||||
"deleteBookMessage": "¿Estás seguro de que deseas eliminar \"{{ title }}\"?\n\nEsto eliminará permanentemente el registro del libro de tu biblioteca.\n\nEsta acción no se puede deshacer.",
|
"deleteBookMessage": "¿Estás seguro de que deseas eliminar \"{{ title }}\"?\n\nEsto eliminará permanentemente el registro del libro de tu biblioteca.\n\nEsta acción no se puede deshacer.",
|
||||||
"deleteBookAllFilesMessage": "¿Estás seguro de que deseas eliminar \"{{ title }}\"?\n\nEsto eliminará permanentemente el registro del libro Y todos los archivos asociados de tu sistema de archivos.\n\nEsta acción no se puede deshacer.",
|
"deleteBookAllFilesMessage": "¿Estás seguro de que deseas eliminar \"{{ title }}\"?\n\nEsto eliminará permanentemente el registro del libro Y todos los archivos asociados de tu sistema de archivos.\n\nEsta acción no se puede deshacer.",
|
||||||
"deleteEverythingBtn": "Eliminar todo"
|
"deleteEverythingBtn": "Eliminar todo",
|
||||||
|
"largeFileMessage": "Este archivo supera los 25 MB. Algunos proveedores de correo pueden rechazar archivos adjuntos grandes.\n\n¿Deseas enviarlo de todos modos?",
|
||||||
|
"largeFileHeader": "Advertencia de archivo grande",
|
||||||
|
"sendAnyway": "Enviar de todos modos"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sidecar": {
|
"sidecar": {
|
||||||
|
|||||||
Reference in New Issue
Block a user