mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
refactor: check if the contact is blocked with a dedicated SQL query
Avoid loading unnecessary fields from the database.
This commit is contained in:
@@ -407,7 +407,13 @@ impl Contact {
|
|||||||
|
|
||||||
/// Check if a contact is blocked.
|
/// Check if a contact is blocked.
|
||||||
pub async fn is_blocked_load(context: &Context, id: ContactId) -> Result<bool> {
|
pub async fn is_blocked_load(context: &Context, id: ContactId) -> Result<bool> {
|
||||||
let blocked = Self::load_from_db(context, id).await?.blocked;
|
let blocked = context
|
||||||
|
.sql
|
||||||
|
.query_row("SELECT blocked FROM contacts WHERE id=?", (id,), |row| {
|
||||||
|
let blocked: bool = row.get(0)?;
|
||||||
|
Ok(blocked)
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
Ok(blocked)
|
Ok(blocked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user