mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 12:56:30 +03:00
Explicit API for creating chats with blocked status
This introduces the explicit ChatIdBlocked struct to more explicitly create a chat with a blocked status. It also adds a common shortcut to ChatId itself which is more natural to use in many cases.
This commit is contained in:
12
src/qr.rs
12
src/qr.rs
@@ -6,12 +6,13 @@ use percent_encoding::percent_decode_str;
|
||||
use serde::Deserialize;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::chat;
|
||||
use crate::chat::{self, ChatIdBlocked};
|
||||
use crate::config::Config;
|
||||
use crate::constants::Blocked;
|
||||
use crate::contact::{addr_normalize, may_be_valid_addr, Contact, Origin};
|
||||
use crate::context::Context;
|
||||
use crate::key::Fingerprint;
|
||||
use crate::log::LogExt;
|
||||
use crate::lot::{Lot, LotState};
|
||||
use crate::message::Message;
|
||||
use crate::peerstate::Peerstate;
|
||||
@@ -165,11 +166,12 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Lot {
|
||||
.map(|(id, _)| id)
|
||||
.unwrap_or_default();
|
||||
|
||||
let (id, _) = chat::create_or_lookup_by_contact_id(context, lot.id, Blocked::Deaddrop)
|
||||
if let Ok(chat) = ChatIdBlocked::get_for_contact(context, lot.id, Blocked::Deaddrop)
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
|
||||
chat::add_info_msg(context, id, format!("{} verified.", peerstate.addr)).await;
|
||||
.log_err(context, "Failed to create (new) chat for contact")
|
||||
{
|
||||
chat::add_info_msg(context, chat.id, format!("{} verified.", peerstate.addr)).await;
|
||||
}
|
||||
} else if let Some(addr) = addr {
|
||||
lot.state = LotState::QrFprMismatch;
|
||||
lot.id = match Contact::lookup_id_by_addr(context, &addr, Origin::Unknown).await {
|
||||
|
||||
Reference in New Issue
Block a user