From bf7e19c92ede61394a8a85bef6be2199dc2baa43 Mon Sep 17 00:00:00 2001 From: fighter-wang <118291973+fighter-wang@users.noreply.github.com> Date: Tue, 3 Sep 2024 18:32:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=82=AE=E4=BB=B6=E9=80=9A=E7=9F=A5):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8E=B7=E5=8F=96=E9=82=AE=E4=BB=B6=E9=99=84?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E8=BF=87=E5=A4=A7=E6=97=B6=E7=9A=84=E6=8A=9B?= =?UTF-8?q?=E9=94=99=E5=9B=BD=E9=99=85=E5=8C=96=20(#568)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(邮件通知): 优化获取邮件附件,过大时的抛错国际化 * fix(邮件通知): 优化使用通用的国际化信息 * fix(邮件通知): 代码优化 --------- Co-authored-by: fighter-wang <11291691+fighter-wang@user.noreply.gitee.com> --- .../notify/email/embedded/DefaultEmailNotifier.java | 9 ++++++++- .../src/main/resources/i18n/messages_en.properties | 1 + .../src/main/resources/i18n/messages_zh.properties | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 jetlinks-components/notify-component/notify-email/src/main/resources/i18n/messages_en.properties create mode 100644 jetlinks-components/notify-component/notify-email/src/main/resources/i18n/messages_zh.properties diff --git a/jetlinks-components/notify-component/notify-email/src/main/java/org/jetlinks/community/notify/email/embedded/DefaultEmailNotifier.java b/jetlinks-components/notify-component/notify-email/src/main/java/org/jetlinks/community/notify/email/embedded/DefaultEmailNotifier.java index f264e642..bf256d41 100755 --- a/jetlinks-components/notify-component/notify-email/src/main/java/org/jetlinks/community/notify/email/embedded/DefaultEmailNotifier.java +++ b/jetlinks-components/notify-component/notify-email/src/main/java/org/jetlinks/community/notify/email/embedded/DefaultEmailNotifier.java @@ -154,7 +154,14 @@ public class DefaultEmailNotifier extends AbstractNotifier { return Flux .fromIterable(template.getAttachments().entrySet()) - .flatMap(entry -> Mono.zip(Mono.just(entry.getKey()), convertResource(entry.getValue()))) + .flatMap(entry -> Mono + .zip(Mono.just(entry.getKey()), convertResource(entry.getValue())) + .onErrorResume(err -> Mono + .error(() -> new BusinessException.NoStackTrace("error.load_attachment_failed", + 500, + entry.getKey(), + err.getMessage()))) + ) .flatMap(tp2 -> Mono .fromCallable(() -> { //添加附件 diff --git a/jetlinks-components/notify-component/notify-email/src/main/resources/i18n/messages_en.properties b/jetlinks-components/notify-component/notify-email/src/main/resources/i18n/messages_en.properties new file mode 100644 index 00000000..b6c29043 --- /dev/null +++ b/jetlinks-components/notify-component/notify-email/src/main/resources/i18n/messages_en.properties @@ -0,0 +1 @@ +error.load_attachment_failed=load attachment [{0}] failed:{1} \ No newline at end of file diff --git a/jetlinks-components/notify-component/notify-email/src/main/resources/i18n/messages_zh.properties b/jetlinks-components/notify-component/notify-email/src/main/resources/i18n/messages_zh.properties new file mode 100644 index 00000000..ab37a64c --- /dev/null +++ b/jetlinks-components/notify-component/notify-email/src/main/resources/i18n/messages_zh.properties @@ -0,0 +1 @@ +error.load_attachment_failed=\u52A0\u8F7D\u9644\u4EF6[{0}]\u5931\u8D25\uFF1A{1} \ No newline at end of file