1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 20:14:19 +00:00

Ensure empty quotes can't be added to the Diario

This commit is contained in:
Steffo 2024-08-25 12:53:33 +02:00
parent a72f0ee43d
commit fccc97bca2
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -4,10 +4,10 @@ use std::str::FromStr;
use anyhow::Context; use anyhow::Context;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use teloxide::Bot;
use teloxide::payloads::SendMessageSetters; use teloxide::payloads::SendMessageSetters;
use teloxide::prelude::Requester; use teloxide::prelude::Requester;
use teloxide::types::{Message, ParseMode, ReplyParameters}; use teloxide::types::{Message, ParseMode, ReplyParameters};
use teloxide::Bot;
use crate::interfaces::database::models::Diario; use crate::interfaces::database::models::Diario;
use crate::interfaces::database::models::RoyalnetUser; use crate::interfaces::database::models::RoyalnetUser;
@ -50,6 +50,8 @@ impl FromStr for DiarioArgs {
DiarioArgs { warning, quote, quoted, context } DiarioArgs { warning, quote, quoted, context }
} }
None => { None => {
anyhow::ensure!(!s.is_empty(), "La citazione specificata non deve essere vuota.");
let warning = None; let warning = None;
let quote = s.to_string(); let quote = s.to_string();
let quoted = None; let quoted = None;