mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
Remove get_origin_by_id
This commit is contained in:
@@ -63,7 +63,7 @@ pub struct Contact {
|
|||||||
addr: String,
|
addr: String,
|
||||||
|
|
||||||
/// Blocked state. Use dc_contact_is_blocked to access this field.
|
/// Blocked state. Use dc_contact_is_blocked to access this field.
|
||||||
blocked: bool,
|
pub blocked: bool,
|
||||||
|
|
||||||
/// The origin/source of the contact.
|
/// The origin/source of the contact.
|
||||||
pub origin: Origin,
|
pub origin: Origin,
|
||||||
@@ -892,22 +892,6 @@ impl Contact {
|
|||||||
.unwrap_or_default() as usize
|
.unwrap_or_default() as usize
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_origin_by_id(context: &Context, contact_id: u32, ret_blocked: &mut bool) -> Origin {
|
|
||||||
let mut ret = Origin::Unknown;
|
|
||||||
*ret_blocked = false;
|
|
||||||
|
|
||||||
if let Ok(contact) = Contact::load_from_db(context, contact_id) {
|
|
||||||
/* we could optimize this by loading only the needed fields */
|
|
||||||
if contact.blocked {
|
|
||||||
*ret_blocked = true;
|
|
||||||
} else {
|
|
||||||
ret = contact.origin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn real_exists_by_id(context: &Context, contact_id: u32) -> bool {
|
pub fn real_exists_by_id(context: &Context, contact_id: u32) -> bool {
|
||||||
if !context.sql.is_open() || contact_id <= DC_CONTACT_ID_LAST_SPECIAL {
|
if !context.sql.is_open() || contact_id <= DC_CONTACT_ID_LAST_SPECIAL {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -124,7 +124,10 @@ pub fn dc_receive_imf(
|
|||||||
incoming_origin = Origin::OutgoingBcc;
|
incoming_origin = Origin::OutgoingBcc;
|
||||||
} else if !from_ids.is_empty() {
|
} else if !from_ids.is_empty() {
|
||||||
from_id = from_ids.get_index(0).cloned().unwrap_or_default();
|
from_id = from_ids.get_index(0).cloned().unwrap_or_default();
|
||||||
incoming_origin = Contact::get_origin_by_id(context, from_id, &mut from_id_blocked)
|
if let Ok(contact) = Contact::load_from_db(context, from_id) {
|
||||||
|
incoming_origin = contact.origin;
|
||||||
|
from_id_blocked = contact.blocked;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
warn!(context, "mail has an empty From header: {:?}", field_from);
|
warn!(context, "mail has an empty From header: {:?}", field_from);
|
||||||
// if there is no from given, from_id stays 0 which is just fine. These messages
|
// if there is no from given, from_id stays 0 which is just fine. These messages
|
||||||
|
|||||||
Reference in New Issue
Block a user