Allow drafts without text if there is a quote

This commit is contained in:
Hocuri
2020-10-09 19:58:56 +02:00
committed by link2xt
parent 990ab739cc
commit cf5342c367
2 changed files with 20 additions and 8 deletions

View File

@@ -315,14 +315,11 @@ impl ChatId {
async fn do_set_draft(self, context: &Context, msg: &mut Message) -> Result<(), Error> {
match msg.viewtype {
Viewtype::Unknown => bail!("Can not set draft of unknown type."),
Viewtype::Text => match msg.text.as_ref() {
Some(text) => {
if text.is_empty() {
bail!("No text in draft");
}
Viewtype::Text => {
if msg.text.is_none_or_empty() && msg.in_reply_to.is_none_or_empty() {
bail!("No text and no quote in draft");
}
None => bail!("No text in draft"),
},
}
_ => {
let blob = msg
.param
@@ -346,7 +343,7 @@ impl ChatId {
msg.text.as_deref().unwrap_or(""),
msg.param.to_string(),
1,
msg.in_reply_to,
msg.in_reply_to.as_deref().unwrap_or_default(),
],
)
.await?;