mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 13:26:28 +03:00
api!: deprecate DC_GCL_VERIFIED_ONLY
This commit is contained in:
@@ -2132,7 +2132,10 @@ uint32_t dc_lookup_contact_id_by_addr (dc_context_t* context, const char*
|
|||||||
uint32_t dc_create_contact (dc_context_t* context, const char* name, const char* addr);
|
uint32_t dc_create_contact (dc_context_t* context, const char* name, const char* addr);
|
||||||
|
|
||||||
|
|
||||||
#define DC_GCL_VERIFIED_ONLY 0x01
|
|
||||||
|
// Deprecated 2025-05-20, setting this flag is a no-op.
|
||||||
|
#define DC_GCL_DEPRECATED_VERIFIED_ONLY 0x01
|
||||||
|
|
||||||
#define DC_GCL_ADD_SELF 0x02
|
#define DC_GCL_ADD_SELF 0x02
|
||||||
|
|
||||||
|
|
||||||
@@ -2194,8 +2197,6 @@ dc_array_t* dc_import_vcard (dc_context_t* context, const char*
|
|||||||
* @param context The context object.
|
* @param context The context object.
|
||||||
* @param flags A combination of flags:
|
* @param flags A combination of flags:
|
||||||
* - if the flag DC_GCL_ADD_SELF is set, SELF is added to the list unless filtered by other parameters
|
* - if the flag DC_GCL_ADD_SELF is set, SELF is added to the list unless filtered by other parameters
|
||||||
* - if the flag DC_GCL_VERIFIED_ONLY is set, only verified contacts are returned.
|
|
||||||
* if DC_GCL_VERIFIED_ONLY is not set, verified and unverified contacts are returned.
|
|
||||||
* @param query A string to filter the list. Typically used to implement an
|
* @param query A string to filter the list. Typically used to implement an
|
||||||
* incremental search. NULL for no filtering.
|
* incremental search. NULL for no filtering.
|
||||||
* @return An array containing all contact IDs. Must be dc_array_unref()'d
|
* @return An array containing all contact IDs. Must be dc_array_unref()'d
|
||||||
|
|||||||
@@ -1162,17 +1162,8 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
|
|||||||
let reaction = arg2;
|
let reaction = arg2;
|
||||||
send_reaction(&context, msg_id, reaction).await?;
|
send_reaction(&context, msg_id, reaction).await?;
|
||||||
}
|
}
|
||||||
"listcontacts" | "contacts" | "listverified" => {
|
"listcontacts" | "contacts" => {
|
||||||
let contacts = Contact::get_all(
|
let contacts = Contact::get_all(&context, DC_GCL_ADD_SELF, Some(arg1)).await?;
|
||||||
&context,
|
|
||||||
if arg0 == "listverified" {
|
|
||||||
DC_GCL_VERIFIED_ONLY | DC_GCL_ADD_SELF
|
|
||||||
} else {
|
|
||||||
DC_GCL_ADD_SELF
|
|
||||||
},
|
|
||||||
Some(arg1),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
log_contactlist(&context, &contacts).await?;
|
log_contactlist(&context, &contacts).await?;
|
||||||
println!("{} contacts.", contacts.len());
|
println!("{} contacts.", contacts.len());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,8 +211,8 @@ class Account:
|
|||||||
def get_contacts(
|
def get_contacts(
|
||||||
self,
|
self,
|
||||||
query: Optional[str] = None,
|
query: Optional[str] = None,
|
||||||
|
*,
|
||||||
with_self: bool = False,
|
with_self: bool = False,
|
||||||
verified_only: bool = False,
|
|
||||||
snapshot: bool = False,
|
snapshot: bool = False,
|
||||||
) -> Union[list[Contact], list[AttrDict]]:
|
) -> Union[list[Contact], list[AttrDict]]:
|
||||||
"""Get a filtered list of contacts.
|
"""Get a filtered list of contacts.
|
||||||
@@ -220,12 +220,9 @@ class Account:
|
|||||||
:param query: if a string is specified, only return contacts
|
:param query: if a string is specified, only return contacts
|
||||||
whose name or e-mail matches query.
|
whose name or e-mail matches query.
|
||||||
:param with_self: if True the self-contact is also included if it matches the query.
|
:param with_self: if True the self-contact is also included if it matches the query.
|
||||||
:param only_verified: if True only return verified contacts.
|
|
||||||
:param snapshot: If True return a list of contact snapshots instead of Contact instances.
|
:param snapshot: If True return a list of contact snapshots instead of Contact instances.
|
||||||
"""
|
"""
|
||||||
flags = 0
|
flags = 0
|
||||||
if verified_only:
|
|
||||||
flags |= ContactFlag.VERIFIED_ONLY
|
|
||||||
if with_self:
|
if with_self:
|
||||||
flags |= ContactFlag.ADD_SELF
|
flags |= ContactFlag.ADD_SELF
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ COMMAND_PREFIX = "/"
|
|||||||
class ContactFlag(IntEnum):
|
class ContactFlag(IntEnum):
|
||||||
"""Bit flags for get_contacts() method."""
|
"""Bit flags for get_contacts() method."""
|
||||||
|
|
||||||
VERIFIED_ONLY = 0x01
|
|
||||||
ADD_SELF = 0x02
|
ADD_SELF = 0x02
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -355,20 +355,16 @@ class Account:
|
|||||||
self,
|
self,
|
||||||
query: Optional[str] = None,
|
query: Optional[str] = None,
|
||||||
with_self: bool = False,
|
with_self: bool = False,
|
||||||
only_verified: bool = False,
|
|
||||||
) -> List[Contact]:
|
) -> List[Contact]:
|
||||||
"""get a (filtered) list of contacts.
|
"""get a (filtered) list of contacts.
|
||||||
|
|
||||||
:param query: if a string is specified, only return contacts
|
:param query: if a string is specified, only return contacts
|
||||||
whose name or e-mail matches query.
|
whose name or e-mail matches query.
|
||||||
:param only_verified: if true only return verified contacts.
|
|
||||||
:param with_self: if true the self-contact is also returned.
|
:param with_self: if true the self-contact is also returned.
|
||||||
:returns: list of :class:`deltachat.contact.Contact` objects.
|
:returns: list of :class:`deltachat.contact.Contact` objects.
|
||||||
"""
|
"""
|
||||||
flags = 0
|
flags = 0
|
||||||
query_c = as_dc_charpointer(query)
|
query_c = as_dc_charpointer(query)
|
||||||
if only_verified:
|
|
||||||
flags |= const.DC_GCL_VERIFIED_ONLY
|
|
||||||
if with_self:
|
if with_self:
|
||||||
flags |= const.DC_GCL_ADD_SELF
|
flags |= const.DC_GCL_ADD_SELF
|
||||||
dc_array = ffi.gc(lib.dc_get_contacts(self._dc_context, flags, query_c), lib.dc_array_unref)
|
dc_array = ffi.gc(lib.dc_get_contacts(self._dc_context, flags, query_c), lib.dc_array_unref)
|
||||||
|
|||||||
@@ -184,7 +184,6 @@ class TestOfflineContact:
|
|||||||
|
|
||||||
assert not ac1.get_contacts(query="some2")
|
assert not ac1.get_contacts(query="some2")
|
||||||
assert ac1.get_contacts(query="some1")
|
assert ac1.get_contacts(query="some1")
|
||||||
assert not ac1.get_contacts(only_verified=True)
|
|
||||||
assert len(ac1.get_contacts(with_self=True)) == 2
|
assert len(ac1.get_contacts(with_self=True)) == 2
|
||||||
|
|
||||||
assert ac1.delete_contact(contact1)
|
assert ac1.delete_contact(contact1)
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ pub const DC_GCL_NO_SPECIALS: usize = 0x02;
|
|||||||
pub const DC_GCL_ADD_ALLDONE_HINT: usize = 0x04;
|
pub const DC_GCL_ADD_ALLDONE_HINT: usize = 0x04;
|
||||||
pub const DC_GCL_FOR_FORWARDING: usize = 0x08;
|
pub const DC_GCL_FOR_FORWARDING: usize = 0x08;
|
||||||
|
|
||||||
pub const DC_GCL_VERIFIED_ONLY: u32 = 0x01;
|
|
||||||
pub const DC_GCL_ADD_SELF: u32 = 0x02;
|
pub const DC_GCL_ADD_SELF: u32 = 0x02;
|
||||||
|
|
||||||
// unchanged user avatars are resent to the recipients every some days
|
// unchanged user avatars are resent to the recipients every some days
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use crate::blob::BlobObject;
|
|||||||
use crate::chat::{ChatId, ChatIdBlocked, ProtectionStatus};
|
use crate::chat::{ChatId, ChatIdBlocked, ProtectionStatus};
|
||||||
use crate::color::str_to_color;
|
use crate::color::str_to_color;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use crate::constants::{Blocked, Chattype, DC_GCL_ADD_SELF, DC_GCL_VERIFIED_ONLY};
|
use crate::constants::{Blocked, Chattype, DC_GCL_ADD_SELF};
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::events::EventType;
|
use crate::events::EventType;
|
||||||
use crate::key::{load_self_public_key, DcKey, SignedPublicKey};
|
use crate::key::{load_self_public_key, DcKey, SignedPublicKey};
|
||||||
@@ -1041,9 +1041,8 @@ impl Contact {
|
|||||||
///
|
///
|
||||||
/// `listflags` is a combination of flags:
|
/// `listflags` is a combination of flags:
|
||||||
/// - if the flag DC_GCL_ADD_SELF is set, SELF is added to the list unless filtered by other parameters
|
/// - if the flag DC_GCL_ADD_SELF is set, SELF is added to the list unless filtered by other parameters
|
||||||
/// - if the flag DC_GCL_VERIFIED_ONLY is set, only verified contacts are returned.
|
///
|
||||||
/// if DC_GCL_VERIFIED_ONLY is not set, verified and unverified contacts are returned.
|
/// `query` is a string to filter the list.
|
||||||
/// `query` is a string to filter the list.
|
|
||||||
pub async fn get_all(
|
pub async fn get_all(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
listflags: u32,
|
listflags: u32,
|
||||||
@@ -1056,14 +1055,13 @@ impl Contact {
|
|||||||
.collect::<HashSet<_>>();
|
.collect::<HashSet<_>>();
|
||||||
let mut add_self = false;
|
let mut add_self = false;
|
||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
let flag_verified_only = (listflags & DC_GCL_VERIFIED_ONLY) != 0;
|
|
||||||
let flag_add_self = (listflags & DC_GCL_ADD_SELF) != 0;
|
let flag_add_self = (listflags & DC_GCL_ADD_SELF) != 0;
|
||||||
let minimal_origin = if context.get_config_bool(Config::Bot).await? {
|
let minimal_origin = if context.get_config_bool(Config::Bot).await? {
|
||||||
Origin::Unknown
|
Origin::Unknown
|
||||||
} else {
|
} else {
|
||||||
Origin::IncomingReplyTo
|
Origin::IncomingReplyTo
|
||||||
};
|
};
|
||||||
if flag_verified_only || query.is_some() {
|
if query.is_some() {
|
||||||
let s3str_like_cmd = format!("%{}%", query.unwrap_or(""));
|
let s3str_like_cmd = format!("%{}%", query.unwrap_or(""));
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
@@ -1074,14 +1072,12 @@ impl Contact {
|
|||||||
AND c.origin>=? \
|
AND c.origin>=? \
|
||||||
AND c.blocked=0 \
|
AND c.blocked=0 \
|
||||||
AND (iif(c.name='',c.authname,c.name) LIKE ? OR c.addr LIKE ?) \
|
AND (iif(c.name='',c.authname,c.name) LIKE ? OR c.addr LIKE ?) \
|
||||||
AND (1=? OR LENGTH(ps.verified_key_fingerprint)!=0) \
|
|
||||||
ORDER BY c.last_seen DESC, c.id DESC;",
|
ORDER BY c.last_seen DESC, c.id DESC;",
|
||||||
(
|
(
|
||||||
ContactId::LAST_SPECIAL,
|
ContactId::LAST_SPECIAL,
|
||||||
minimal_origin,
|
minimal_origin,
|
||||||
&s3str_like_cmd,
|
&s3str_like_cmd,
|
||||||
&s3str_like_cmd,
|
&s3str_like_cmd,
|
||||||
if flag_verified_only { 0i32 } else { 1i32 },
|
|
||||||
),
|
),
|
||||||
|row| {
|
|row| {
|
||||||
let id: ContactId = row.get(0)?;
|
let id: ContactId = row.get(0)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user