mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 21:36:30 +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 std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use crate::chatlist::*;
|
use crate::chatlist::*;
|
||||||
|
use crate::config::*;
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::contact::*;
|
use crate::contact::*;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
@@ -267,7 +268,7 @@ impl Chat {
|
|||||||
return Ok(0);
|
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 new_rfc724_mid = {
|
||||||
let grpid = match self.typ {
|
let grpid = match self.typ {
|
||||||
Chattype::Group | Chattype::VerifiedGroup => Some(self.grpid.as_str()),
|
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.",);
|
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() {
|
if self_addr.is_none() {
|
||||||
error!(context, "Missing self addr");
|
error!(context, "Missing self addr");
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ impl E2eeHelper {
|
|||||||
EncryptPreference::NoPreference
|
EncryptPreference::NoPreference
|
||||||
};
|
};
|
||||||
|
|
||||||
let addr = context.sql.get_config(context, "configured_addr");
|
let addr = context.get_config(Config::ConfiguredAddr);
|
||||||
|
|
||||||
if let Some(addr) = addr {
|
if let Some(addr) = addr {
|
||||||
let pubkey_ret = load_or_generate_self_public_key(context, &addr).map_err(|err| {
|
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 */
|
/* 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 let Some(self_addr) = self_addr {
|
||||||
if private_keyring.load_self_private_for_decrypting(
|
if private_keyring.load_self_private_for_decrypting(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use std::ptr;
|
|||||||
|
|
||||||
use crate::aheader::EncryptPreference;
|
use crate::aheader::EncryptPreference;
|
||||||
use crate::chat::{self, Chat};
|
use crate::chat::{self, Chat};
|
||||||
|
use crate::config::*;
|
||||||
use crate::configure::*;
|
use crate::configure::*;
|
||||||
use crate::constants::*;
|
use crate::constants::*;
|
||||||
use crate::contact::*;
|
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();
|
ensure_secret_key_exists(context).ok();
|
||||||
let invitenumber = token::lookup_or_new(context, token::Namespace::InviteNumber, group_chat_id);
|
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 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,
|
Some(addr) => addr,
|
||||||
None => {
|
None => {
|
||||||
error!(context, "Not configured, cannot generate QR code.",);
|
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> {
|
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) {
|
if let Some(key) = Key::from_self_public(context, self_addr, &context.sql) {
|
||||||
return Some(key.fingerprint());
|
return Some(key.fingerprint());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user