mirror of
https://github.com/chatmail/core.git
synced 2026-05-17 05:46:30 +03:00
drafts are added to chatlist only on explicit request
This commit is contained in:
@@ -861,6 +861,7 @@ void dc_maybe_network (dc_context_t* context);
|
|||||||
#define DC_GCL_ARCHIVED_ONLY 0x01
|
#define DC_GCL_ARCHIVED_ONLY 0x01
|
||||||
#define DC_GCL_NO_SPECIALS 0x02
|
#define DC_GCL_NO_SPECIALS 0x02
|
||||||
#define DC_GCL_ADD_ALLDONE_HINT 0x04
|
#define DC_GCL_ADD_ALLDONE_HINT 0x04
|
||||||
|
#define DC_GCL_ADD_DRAFTS 0x08
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -904,6 +905,12 @@ void dc_maybe_network (dc_context_t* context);
|
|||||||
* not needed when DC_GCL_ARCHIVED_ONLY is already set)
|
* not needed when DC_GCL_ARCHIVED_ONLY is already set)
|
||||||
* - if the flag DC_GCL_ADD_ALLDONE_HINT is set, DC_CHAT_ID_ALLDONE_HINT
|
* - if the flag DC_GCL_ADD_ALLDONE_HINT is set, DC_CHAT_ID_ALLDONE_HINT
|
||||||
* is added as needed.
|
* is added as needed.
|
||||||
|
* - if the flag DC_GCL_ADD_DRAFTS is set
|
||||||
|
* and a chat has a recent draft,
|
||||||
|
* the draft is returned by dc_chatlist_get_msg_id().
|
||||||
|
* if the chatlist is shown permanently eg. on desktop,
|
||||||
|
* you may not want to add this flags
|
||||||
|
* as the resorting on dc_set_draft() is easily confusing.
|
||||||
* @param query_str An optional query for filtering the list. Only chats matching this query
|
* @param query_str An optional query for filtering the list. Only chats matching this query
|
||||||
* are returned. Give NULL for no filtering.
|
* are returned. Give NULL for no filtering.
|
||||||
* @param query_id An optional contact ID for filtering the list. Only chats including this contact ID
|
* @param query_id An optional contact ID for filtering the list. Only chats including this contact ID
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from os.path import join as joinpath
|
|||||||
DC_GCL_ARCHIVED_ONLY = 0x01
|
DC_GCL_ARCHIVED_ONLY = 0x01
|
||||||
DC_GCL_NO_SPECIALS = 0x02
|
DC_GCL_NO_SPECIALS = 0x02
|
||||||
DC_GCL_ADD_ALLDONE_HINT = 0x04
|
DC_GCL_ADD_ALLDONE_HINT = 0x04
|
||||||
|
DC_GCL_ADD_DRAFTS = 0x08
|
||||||
DC_GCL_VERIFIED_ONLY = 0x01
|
DC_GCL_VERIFIED_ONLY = 0x01
|
||||||
DC_GCL_ADD_SELF = 0x02
|
DC_GCL_ADD_SELF = 0x02
|
||||||
DC_QR_ASK_VERIFYCONTACT = 200
|
DC_QR_ASK_VERIFYCONTACT = 200
|
||||||
|
|||||||
@@ -88,6 +88,16 @@ impl Chatlist {
|
|||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let mut add_archived_link_item = false;
|
let mut add_archived_link_item = false;
|
||||||
|
|
||||||
|
// drafts are hidden in the database.
|
||||||
|
// if add_drafts is set, this will be expanded to `hidden=1 AND state=DC_STATE_OUT_DRAFT`.
|
||||||
|
// otherwise, this results in `hidden=0 AND state=DC_STATE_OUT_DRAFT` in the sql statement
|
||||||
|
// and no additional messages will be regarded
|
||||||
|
let add_drafts = if 0 != listflags & DC_GCL_ADD_DRAFTS {
|
||||||
|
1
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
// select with left join and minimum:
|
// select with left join and minimum:
|
||||||
// - the inner select must use `hidden` and _not_ `m.hidden`
|
// - the inner select must use `hidden` and _not_ `m.hidden`
|
||||||
// which would refer the outer select and take a lot of time
|
// which would refer the outer select and take a lot of time
|
||||||
@@ -125,10 +135,10 @@ impl Chatlist {
|
|||||||
ON c.id=m.chat_id \
|
ON c.id=m.chat_id \
|
||||||
AND m.timestamp=( SELECT MAX(timestamp) \
|
AND m.timestamp=( SELECT MAX(timestamp) \
|
||||||
FROM msgs WHERE chat_id=c.id \
|
FROM msgs WHERE chat_id=c.id \
|
||||||
AND (hidden=0 OR (hidden=1 AND state=19))) WHERE c.id>9 \
|
AND (hidden=0 OR (hidden=? AND state=19))) WHERE c.id>9 \
|
||||||
AND c.blocked=0 AND c.id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=?) \
|
AND c.blocked=0 AND c.id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=?) \
|
||||||
GROUP BY c.id ORDER BY IFNULL(m.timestamp,0) DESC, m.id DESC;",
|
GROUP BY c.id ORDER BY IFNULL(m.timestamp,0) DESC, m.id DESC;",
|
||||||
params![query_contact_id as i32],
|
params![add_drafts, query_contact_id as i32],
|
||||||
process_row,
|
process_row,
|
||||||
process_rows,
|
process_rows,
|
||||||
)?
|
)?
|
||||||
@@ -139,10 +149,10 @@ impl Chatlist {
|
|||||||
ON c.id=m.chat_id \
|
ON c.id=m.chat_id \
|
||||||
AND m.timestamp=( SELECT MAX(timestamp) \
|
AND m.timestamp=( SELECT MAX(timestamp) \
|
||||||
FROM msgs WHERE chat_id=c.id \
|
FROM msgs WHERE chat_id=c.id \
|
||||||
AND (hidden=0 OR (hidden=1 AND state=19))) WHERE c.id>9 \
|
AND (hidden=0 OR (hidden=? AND state=19))) WHERE c.id>9 \
|
||||||
AND c.blocked=0 AND c.archived=1 GROUP BY c.id \
|
AND c.blocked=0 AND c.archived=1 GROUP BY c.id \
|
||||||
ORDER BY IFNULL(m.timestamp,0) DESC, m.id DESC;",
|
ORDER BY IFNULL(m.timestamp,0) DESC, m.id DESC;",
|
||||||
params![],
|
params![add_drafts],
|
||||||
process_row,
|
process_row,
|
||||||
process_rows,
|
process_rows,
|
||||||
)?
|
)?
|
||||||
@@ -156,10 +166,10 @@ impl Chatlist {
|
|||||||
ON c.id=m.chat_id \
|
ON c.id=m.chat_id \
|
||||||
AND m.timestamp=( SELECT MAX(timestamp) \
|
AND m.timestamp=( SELECT MAX(timestamp) \
|
||||||
FROM msgs WHERE chat_id=c.id \
|
FROM msgs WHERE chat_id=c.id \
|
||||||
AND (hidden=0 OR (hidden=1 AND state=19))) WHERE c.id>9 \
|
AND (hidden=0 OR (hidden=? AND state=19))) WHERE c.id>9 \
|
||||||
AND c.blocked=0 AND c.name LIKE ? \
|
AND c.blocked=0 AND c.name LIKE ? \
|
||||||
GROUP BY c.id ORDER BY IFNULL(m.timestamp,0) DESC, m.id DESC;",
|
GROUP BY c.id ORDER BY IFNULL(m.timestamp,0) DESC, m.id DESC;",
|
||||||
params![str_like_cmd],
|
params![add_drafts, str_like_cmd],
|
||||||
process_row,
|
process_row,
|
||||||
process_rows,
|
process_rows,
|
||||||
)?
|
)?
|
||||||
@@ -171,11 +181,11 @@ impl Chatlist {
|
|||||||
ON c.id=m.chat_id \
|
ON c.id=m.chat_id \
|
||||||
AND m.timestamp=( SELECT MAX(timestamp) \
|
AND m.timestamp=( SELECT MAX(timestamp) \
|
||||||
FROM msgs WHERE chat_id=c.id \
|
FROM msgs WHERE chat_id=c.id \
|
||||||
AND (hidden=0 OR (hidden=1 AND state=19))) WHERE c.id>9 \
|
AND (hidden=0 OR (hidden=? AND state=19))) WHERE c.id>9 \
|
||||||
AND c.blocked=0 AND c.archived=0 \
|
AND c.blocked=0 AND c.archived=0 \
|
||||||
GROUP BY c.id \
|
GROUP BY c.id \
|
||||||
ORDER BY IFNULL(m.timestamp,0) DESC, m.id DESC;",
|
ORDER BY IFNULL(m.timestamp,0) DESC, m.id DESC;",
|
||||||
params![],
|
params![add_drafts],
|
||||||
process_row,
|
process_row,
|
||||||
process_rows,
|
process_rows,
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ pub const DC_HANDSHAKE_ADD_DELETE_JOB: i32 = 0x04;
|
|||||||
pub const DC_GCL_ARCHIVED_ONLY: usize = 0x01;
|
pub const DC_GCL_ARCHIVED_ONLY: usize = 0x01;
|
||||||
pub const DC_GCL_NO_SPECIALS: usize = 0x02;
|
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_ADD_DRAFTS: usize = 0x08;
|
||||||
|
|
||||||
const DC_GCM_ADDDAYMARKER: usize = 0x01;
|
const DC_GCM_ADDDAYMARKER: usize = 0x01;
|
||||||
|
|
||||||
|
|||||||
@@ -1378,5 +1378,9 @@ mod tests {
|
|||||||
assert!(listflags_has(listflags, DC_GCL_ADD_SELF) == true);
|
assert!(listflags_has(listflags, DC_GCL_ADD_SELF) == true);
|
||||||
let listflags: u32 = DC_GCL_VERIFIED_ONLY.try_into().unwrap();
|
let listflags: u32 = DC_GCL_VERIFIED_ONLY.try_into().unwrap();
|
||||||
assert!(listflags_has(listflags, DC_GCL_ADD_SELF) == false);
|
assert!(listflags_has(listflags, DC_GCL_ADD_SELF) == false);
|
||||||
|
|
||||||
|
let listflags: u32 = DC_GCL_ADD_DRAFTS.try_into().unwrap();
|
||||||
|
assert!(listflags_has(listflags, DC_GCL_ADD_ALLDONE_HINT) == false);
|
||||||
|
assert!(listflags_has(listflags, 0x8) == true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user