mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 06:46:32 +03:00
fix: show all contacts in Contact::get_all for bots (#4811)
successor of #4810
This commit is contained in:
@@ -812,7 +812,11 @@ impl Contact {
|
|||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
let flag_verified_only = (listflags & DC_GCL_VERIFIED_ONLY) != 0;
|
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? {
|
||||||
|
Origin::Unknown
|
||||||
|
} else {
|
||||||
|
Origin::IncomingReplyTo
|
||||||
|
};
|
||||||
if flag_verified_only || query.is_some() {
|
if flag_verified_only || query.is_some() {
|
||||||
let s3str_like_cmd = format!("%{}%", query.unwrap_or(""));
|
let s3str_like_cmd = format!("%{}%", query.unwrap_or(""));
|
||||||
context
|
context
|
||||||
@@ -832,7 +836,7 @@ impl Contact {
|
|||||||
),
|
),
|
||||||
rusqlite::params_from_iter(params_iter(&self_addrs).chain(params_slice![
|
rusqlite::params_from_iter(params_iter(&self_addrs).chain(params_slice![
|
||||||
ContactId::LAST_SPECIAL,
|
ContactId::LAST_SPECIAL,
|
||||||
Origin::IncomingReplyTo,
|
minimal_origin,
|
||||||
s3str_like_cmd,
|
s3str_like_cmd,
|
||||||
s3str_like_cmd,
|
s3str_like_cmd,
|
||||||
if flag_verified_only { 0i32 } else { 1i32 }
|
if flag_verified_only { 0i32 } else { 1i32 }
|
||||||
@@ -882,10 +886,10 @@ impl Contact {
|
|||||||
ORDER BY last_seen DESC, id DESC;",
|
ORDER BY last_seen DESC, id DESC;",
|
||||||
sql::repeat_vars(self_addrs.len())
|
sql::repeat_vars(self_addrs.len())
|
||||||
),
|
),
|
||||||
rusqlite::params_from_iter(params_iter(&self_addrs).chain(params_slice![
|
rusqlite::params_from_iter(
|
||||||
ContactId::LAST_SPECIAL,
|
params_iter(&self_addrs)
|
||||||
Origin::IncomingReplyTo
|
.chain(params_slice![ContactId::LAST_SPECIAL, minimal_origin]),
|
||||||
])),
|
),
|
||||||
|row| row.get::<_, ContactId>(0),
|
|row| row.get::<_, ContactId>(0),
|
||||||
|ids| {
|
|ids| {
|
||||||
for id in ids {
|
for id in ids {
|
||||||
|
|||||||
@@ -2974,6 +2974,7 @@ async fn test_auto_accept_for_bots() -> Result<()> {
|
|||||||
let msg = t.get_last_msg().await;
|
let msg = t.get_last_msg().await;
|
||||||
let chat = chat::Chat::load_from_db(&t, msg.chat_id).await?;
|
let chat = chat::Chat::load_from_db(&t, msg.chat_id).await?;
|
||||||
assert!(!chat.is_contact_request());
|
assert!(!chat.is_contact_request());
|
||||||
|
assert!(Contact::get_all(&t, 0, None).await?.len() == 1);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user