Add JSON-RPC API can_send()

This commit is contained in:
link2xt
2023-04-14 20:10:18 +00:00
parent b369a30544
commit 28a13e98a6
4 changed files with 16 additions and 1 deletions

View File

@@ -1701,6 +1701,15 @@ impl CommandApi {
Ok(msg_id)
}
/// Checks if messages can be sent to a given chat.
async fn can_send(&self, account_id: u32, chat_id: u32) -> Result<bool> {
let ctx = self.get_context(account_id).await?;
let chat_id = ChatId::new(chat_id);
let chat = Chat::load_from_db(&ctx, chat_id).await?;
let can_send = chat.can_send(&ctx).await?;
Ok(can_send)
}
// ---------------------------------------------
// functions for the composer
// the composer is the message input field