From 329ce8001f4dcc2a27b9ea0c6ba50ed2d33e7e07 Mon Sep 17 00:00:00 2001 From: Sushen Oli Date: Tue, 1 Apr 2025 15:07:28 +0545 Subject: [PATCH 1/3] add error message for missing attachment description and empty message --- src/handlers/Handler.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/handlers/Handler.ts b/src/handlers/Handler.ts index 5f4c0ca..a7ea5dc 100644 --- a/src/handlers/Handler.ts +++ b/src/handlers/Handler.ts @@ -16,6 +16,7 @@ import { IReply } from '../definition/reply/IReply'; import { sendDefaultNotification, sendHelperNotification, + sendNotification, } from '../helper/notification'; import { UserPreferenceModal } from '../modal/UserPreferenceModal'; import { Language } from '../lib/Translation/translation'; @@ -174,6 +175,7 @@ export class Handler implements IHandler { const textMessage = Message.trim(); if (textMessage) { + this.app.getLogger().debug(textMessage, "testMessage") const aistorage = new AIstorage( this.persis, this.read.getPersistenceReader(), @@ -205,5 +207,19 @@ export class Handler implements IHandler { } return; } + else if(lastMessage?.attachments && !lastMessage?.attachments?.[0]?.description){ + const content = { + message: "Quick replies can't be used because the attachment has no description. The attachment must have a description to proceed." + } + await sendNotification(this.read, this.modify, this.sender, this.room, content); + return + } + else{ + const content = { + message: "Quick replies can't be used because there is no message to reply to. Please try again with a valid message." + } + await sendNotification(this.read, this.modify, this.sender, this.room, content); + return + } } } From 8c062386c046a09b27964a71e39170ccb1bf28e9 Mon Sep 17 00:00:00 2001 From: Sushen Oli Date: Tue, 1 Apr 2025 15:13:30 +0545 Subject: [PATCH 2/3] Remove logger --- src/handlers/Handler.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/handlers/Handler.ts b/src/handlers/Handler.ts index a7ea5dc..8819680 100644 --- a/src/handlers/Handler.ts +++ b/src/handlers/Handler.ts @@ -175,7 +175,6 @@ export class Handler implements IHandler { const textMessage = Message.trim(); if (textMessage) { - this.app.getLogger().debug(textMessage, "testMessage") const aistorage = new AIstorage( this.persis, this.read.getPersistenceReader(), From 91b3db12c686c189ca279b25b2d14d1d9371c125 Mon Sep 17 00:00:00 2001 From: Sushen Oli Date: Fri, 11 Apr 2025 18:05:19 +0545 Subject: [PATCH 3/3] Add multi-language error messages --- src/handlers/Handler.ts | 6 +++--- src/lib/Translation/locales/de.ts | 5 +++-- src/lib/Translation/locales/en.ts | 5 ++++- src/lib/Translation/locales/pl.ts | 5 +++-- src/lib/Translation/locales/pt.ts | 5 +++-- src/lib/Translation/locales/ru.ts | 5 +++-- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/handlers/Handler.ts b/src/handlers/Handler.ts index 8819680..1f9b85c 100644 --- a/src/handlers/Handler.ts +++ b/src/handlers/Handler.ts @@ -19,7 +19,7 @@ import { sendNotification, } from '../helper/notification'; import { UserPreferenceModal } from '../modal/UserPreferenceModal'; -import { Language } from '../lib/Translation/translation'; +import { Language, t } from '../lib/Translation/translation'; import { ReplyAIModal } from '../modal/AIreplyModal'; import { AIstorage } from '../storage/AIStorage'; import { UserPreferenceStorage } from '../storage/userPreferenceStorage'; @@ -208,14 +208,14 @@ export class Handler implements IHandler { } else if(lastMessage?.attachments && !lastMessage?.attachments?.[0]?.description){ const content = { - message: "Quick replies can't be used because the attachment has no description. The attachment must have a description to proceed." + message: t('Error_Missing_Attachment_Description', this.language) } await sendNotification(this.read, this.modify, this.sender, this.room, content); return } else{ const content = { - message: "Quick replies can't be used because there is no message to reply to. Please try again with a valid message." + message: t('Error_Missing_Message', this.language) } await sendNotification(this.read, this.modify, this.sender, this.room, content); return diff --git a/src/lib/Translation/locales/de.ts b/src/lib/Translation/locales/de.ts index 712615e..fe5c4d9 100644 --- a/src/lib/Translation/locales/de.ts +++ b/src/lib/Translation/locales/de.ts @@ -86,6 +86,7 @@ export const de = { AI_Gemini_Model_Not_Configured: "Ihr Gemini-Modell ist nicht richtig eingerichtet. Bitte überprüfen Sie Ihre Konfiguration", AI_Workspace_Model_Not_Configured: "Ihre Workspace-AI ist nicht richtig eingerichtet. Bitte kontaktieren Sie Ihren Administrator", AI_Something_Went_Wrong: "Etwas ist schiefgelaufen. Bitte versuchen Sie es später noch einmal.", - Refresh_Button_Text: "Aktualisieren" - + Refresh_Button_Text: "Aktualisieren", + Error_Missing_Attachment_Description: "Schnelle Antwort können nicht verwendet werden, da der Anhang keine Beschreibung enthält. Der Anhang muss eine Beschreibung haben, um fortzufahren.", + Error_Missing_Message: "Schnelle Antwort können nicht verwendet werden, da keine Nachricht zum Antworten vorhanden ist. Bitte versuchen Sie es mit einer gültigen Nachricht erneut." } diff --git a/src/lib/Translation/locales/en.ts b/src/lib/Translation/locales/en.ts index 5e140db..6023ece 100644 --- a/src/lib/Translation/locales/en.ts +++ b/src/lib/Translation/locales/en.ts @@ -86,4 +86,7 @@ export const en = { AI_Gemini_Model_Not_Configured: "Your Gemini Model is not set up properly. Please check your configuration", AI_Workspace_Model_Not_Configured: "Your Workspace AI is not set up properly. Please contact your administrator", AI_Something_Went_Wrong: "Something went wrong. Please try again later.", - Refresh_Button_Text: "Refresh"}; + Refresh_Button_Text: "Refresh", + Error_Missing_Attachment_Description: "Quick replies can't be used because the attachment has no description. The attachment must have a description to proceed.", + Error_Missing_Message: "Quick replies can't be used because there is no message to reply to. Please try again with a valid message." +}; diff --git a/src/lib/Translation/locales/pl.ts b/src/lib/Translation/locales/pl.ts index 3937e82..94770ce 100644 --- a/src/lib/Translation/locales/pl.ts +++ b/src/lib/Translation/locales/pl.ts @@ -86,7 +86,8 @@ export const pl = { AI_Gemini_Model_Not_Configured: "Twój model Gemini nie jest poprawnie skonfigurowany. Proszę sprawdzić swoją konfigurację", AI_Workspace_Model_Not_Configured: "Twoja AI w Workspace nie jest poprawnie skonfigurowana. Proszę skontaktować się z administratorem", AI_Something_Went_Wrong: "Coś poszło nie tak. Proszę spróbować ponownie później.", - Refresh_Button_Text: "Odśwież" - + Refresh_Button_Text: "Odśwież", + Error_Missing_Attachment_Description: "Nie można użyć szybkich odpowiedzi, ponieważ załącznik nie ma opisu. Załącznik musi zawierać opis, aby kontynuować.", + Error_Missing_Message: "Nie można użyć szybka odpowiedź, ponieważ nie ma wiadomości, na którą można odpowiedzieć. Spróbuj ponownie z prawidłową wiadomością." } diff --git a/src/lib/Translation/locales/pt.ts b/src/lib/Translation/locales/pt.ts index 146e6b7..0fc6a1c 100644 --- a/src/lib/Translation/locales/pt.ts +++ b/src/lib/Translation/locales/pt.ts @@ -86,7 +86,8 @@ export const pt = { AI_Gemini_Model_Not_Configured: "Seu Modelo Gemini não está configurado corretamente. Por favor, verifique sua configuração", AI_Workspace_Model_Not_Configured: "Sua IA do Workspace não está configurada corretamente. Por favor, entre em contato com o administrador", AI_Something_Went_Wrong: "Algo deu errado. Por favor, tente novamente mais tarde.", - Refresh_Button_Text: "Atualizar" - + Refresh_Button_Text: "Atualizar", + Error_Missing_Attachment_Description: "Resposta rápida não podem ser usadas porque o anexo não tem descrição. O anexo deve ter uma descrição para prosseguir.", + Error_Missing_Message: "Resposta rápida não podem ser usadas porque não há mensagem para responder. Por favor, tente novamente com uma mensagem válida." } diff --git a/src/lib/Translation/locales/ru.ts b/src/lib/Translation/locales/ru.ts index 09af97c..a136691 100644 --- a/src/lib/Translation/locales/ru.ts +++ b/src/lib/Translation/locales/ru.ts @@ -86,6 +86,7 @@ export const ru = { AI_Gemini_Model_Not_Configured: "Ваша модель Gemini не настроена должным образом. Пожалуйста, проверьте свою конфигурацию", AI_Workspace_Model_Not_Configured: "Ваша AI в Workspace не настроена должным образом. Пожалуйста, свяжитесь с администратором", AI_Something_Went_Wrong: "Что-то пошло не так. Пожалуйста, попробуйте позже.", - Refresh_Button_Text: "Обновить" - + Refresh_Button_Text: "Обновить", + Error_Missing_Attachment_Description: "Нельзя использовать быстрые ответы, так как вложение не содержит описания. Вложение должно иметь описание, чтобы продолжить.", + Error_Missing_Message: "Нельзя использовать быстрые ответы, так как нет сообщения, на которое можно ответить. Пожалуйста, попробуйте снова с допустимым сообщением." }