mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
Replace some of context.sql.get_config() with context.get_config()
Pattern `context.sql.get_config(context, {foo})` is unnecessary
redundant in Rust: unlike C, Rust has associated functions (methods).
This commit is contained in:
@@ -2,6 +2,7 @@ use std::ffi::CString;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::chatlist::*;
|
||||
use crate::config::*;
|
||||
use crate::constants::*;
|
||||
use crate::contact::*;
|
||||
use crate::context::Context;
|
||||
@@ -267,7 +268,7 @@ impl Chat {
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
if let Some(from) = context.sql.get_config(context, "configured_addr") {
|
||||
if let Some(from) = context.get_config(Config::ConfiguredAddr) {
|
||||
let new_rfc724_mid = {
|
||||
let grpid = match self.typ {
|
||||
Chattype::Group | Chattype::VerifiedGroup => Some(self.grpid.as_str()),
|
||||
|
||||
@@ -362,7 +362,7 @@ fn set_self_key(
|
||||
error!(context, "File does not contain a private key.",);
|
||||
}
|
||||
|
||||
let self_addr = context.sql.get_config(context, "configured_addr");
|
||||
let self_addr = context.get_config(Config::ConfiguredAddr);
|
||||
|
||||
if self_addr.is_none() {
|
||||
error!(context, "Missing self addr");
|
||||
|
||||
@@ -87,7 +87,7 @@ impl E2eeHelper {
|
||||
EncryptPreference::NoPreference
|
||||
};
|
||||
|
||||
let addr = context.sql.get_config(context, "configured_addr");
|
||||
let addr = context.get_config(Config::ConfiguredAddr);
|
||||
|
||||
if let Some(addr) = addr {
|
||||
let pubkey_ret = load_or_generate_self_public_key(context, &addr).map_err(|err| {
|
||||
@@ -429,7 +429,7 @@ impl E2eeHelper {
|
||||
}
|
||||
}
|
||||
/* load private key for decryption */
|
||||
let self_addr = context.sql.get_config(context, "configured_addr");
|
||||
let self_addr = context.get_config(Config::ConfiguredAddr);
|
||||
if let Some(self_addr) = self_addr {
|
||||
if private_keyring.load_self_private_for_decrypting(
|
||||
context,
|
||||
|
||||
@@ -4,6 +4,7 @@ use std::ptr;
|
||||
|
||||
use crate::aheader::EncryptPreference;
|
||||
use crate::chat::{self, Chat};
|
||||
use crate::config::*;
|
||||
use crate::configure::*;
|
||||
use crate::constants::*;
|
||||
use crate::contact::*;
|
||||
@@ -82,7 +83,7 @@ pub fn dc_get_securejoin_qr(context: &Context, group_chat_id: uint32_t) -> Optio
|
||||
ensure_secret_key_exists(context).ok();
|
||||
let invitenumber = token::lookup_or_new(context, token::Namespace::InviteNumber, group_chat_id);
|
||||
let auth = token::lookup_or_new(context, token::Namespace::Auth, group_chat_id);
|
||||
let self_addr = match context.sql.get_config(context, "configured_addr") {
|
||||
let self_addr = match context.get_config(Config::ConfiguredAddr) {
|
||||
Some(addr) => addr,
|
||||
None => {
|
||||
error!(context, "Not configured, cannot generate QR code.",);
|
||||
@@ -139,7 +140,7 @@ pub fn dc_get_securejoin_qr(context: &Context, group_chat_id: uint32_t) -> Optio
|
||||
}
|
||||
|
||||
fn get_self_fingerprint(context: &Context) -> Option<String> {
|
||||
if let Some(self_addr) = context.sql.get_config(context, "configured_addr") {
|
||||
if let Some(self_addr) = context.get_config(Config::ConfiguredAddr) {
|
||||
if let Some(key) = Key::from_self_public(context, self_addr, &context.sql) {
|
||||
return Some(key.fingerprint());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user