From fccc97bca28743ab80aecd23e4fca992fb20b6d4 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 25 Aug 2024 12:53:33 +0200 Subject: [PATCH] Ensure empty quotes can't be added to the Diario --- src/services/telegram/commands/diario.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/telegram/commands/diario.rs b/src/services/telegram/commands/diario.rs index f7a34e44..e0228599 100644 --- a/src/services/telegram/commands/diario.rs +++ b/src/services/telegram/commands/diario.rs @@ -4,10 +4,10 @@ use std::str::FromStr; use anyhow::Context; use once_cell::sync::Lazy; use regex::Regex; -use teloxide::Bot; use teloxide::payloads::SendMessageSetters; use teloxide::prelude::Requester; use teloxide::types::{Message, ParseMode, ReplyParameters}; +use teloxide::Bot; use crate::interfaces::database::models::Diario; use crate::interfaces::database::models::RoyalnetUser; @@ -50,6 +50,8 @@ impl FromStr for DiarioArgs { DiarioArgs { warning, quote, quoted, context } } None => { + anyhow::ensure!(!s.is_empty(), "La citazione specificata non deve essere vuota."); + let warning = None; let quote = s.to_string(); let quoted = None;