mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 04:46:29 +03:00
add a function to delete records from the chats_contacts table
This commit is contained in:
committed by
holger krekel
parent
d9dda44409
commit
fa3d98a492
27
src/chat.rs
27
src/chat.rs
@@ -1750,8 +1750,6 @@ pub fn create_group_chat(
|
|||||||
Ok(chat_id)
|
Ok(chat_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* you MUST NOT modify this or the following strings */
|
|
||||||
// Context functions to work with chats
|
|
||||||
pub fn add_to_chat_contacts_table(context: &Context, chat_id: ChatId, contact_id: u32) -> bool {
|
pub fn add_to_chat_contacts_table(context: &Context, chat_id: ChatId, contact_id: u32) -> bool {
|
||||||
// add a contact to a chat; the function does not check the type or if any of the record exist or are already
|
// add a contact to a chat; the function does not check the type or if any of the record exist or are already
|
||||||
// added to the chat!
|
// added to the chat!
|
||||||
@@ -1764,6 +1762,22 @@ pub fn add_to_chat_contacts_table(context: &Context, chat_id: ChatId, contact_id
|
|||||||
.is_ok()
|
.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove_from_chat_contacts_table(
|
||||||
|
context: &Context,
|
||||||
|
chat_id: ChatId,
|
||||||
|
contact_id: u32,
|
||||||
|
) -> bool {
|
||||||
|
// remove a contact from the chats_contact table unconditionally
|
||||||
|
// the function does not check the type or if the record exist
|
||||||
|
sql::execute(
|
||||||
|
context,
|
||||||
|
&context.sql,
|
||||||
|
"DELETE FROM chats_contacts WHERE chat_id=? AND contact_id=?",
|
||||||
|
params![chat_id, contact_id as i32],
|
||||||
|
)
|
||||||
|
.is_ok()
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds a contact to the chat.
|
/// Adds a contact to the chat.
|
||||||
pub fn add_contact_to_chat(context: &Context, chat_id: ChatId, contact_id: u32) -> bool {
|
pub fn add_contact_to_chat(context: &Context, chat_id: ChatId, contact_id: u32) -> bool {
|
||||||
match add_contact_to_chat_ex(context, chat_id, contact_id, false) {
|
match add_contact_to_chat_ex(context, chat_id, contact_id, false) {
|
||||||
@@ -2075,14 +2089,7 @@ pub fn remove_contact_from_chat(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if sql::execute(
|
if remove_from_chat_contacts_table(context, chat_id, contact_id) {
|
||||||
context,
|
|
||||||
&context.sql,
|
|
||||||
"DELETE FROM chats_contacts WHERE chat_id=? AND contact_id=?;",
|
|
||||||
params![chat_id, contact_id as i32],
|
|
||||||
)
|
|
||||||
.is_ok()
|
|
||||||
{
|
|
||||||
context.call_cb(Event::ChatModified(chat_id));
|
context.call_cb(Event::ChatModified(chat_id));
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user