1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-07-17 12:48:04 +00:00

Can change conversation name

This commit is contained in:
2020-06-15 14:30:01 +02:00
parent 0f856e93cb
commit 8a2b618648
3 changed files with 37 additions and 0 deletions

@ -167,6 +167,14 @@ pub fn set_members(conv_id: u64, new_list: &Vec<UserID>, can_delete: bool) -> Re
Ok(())
}
/// Set a new name to the conversation
pub fn set_name(conv_id: u64, name: Option<String>) -> ResultBoxError<()> {
database::UpdateInfo::new(CONV_LIST_TABLE)
.cond_u64("id", conv_id)
.set_opt_str("name", name)
.exec()
}
/// Turn a database entry into a ConversationInfo object
fn db_to_conversation_info(row: &database::RowResult) -> ResultBoxError<Conversation> {
let conv_id = row.get_u64("id")?;

@ -574,6 +574,15 @@ impl UpdateInfo {
self
}
/// Set an new optional string
///
/// None => Empty string
/// Some => The string
pub fn set_opt_str(mut self, name: &str, val: Option<String>) -> UpdateInfo {
self.set.insert(name.to_string(), Value::from(val.unwrap_or(String::new())));
self
}
/// Set a new legacy boolean
pub fn set_legacy_bool(mut self, name: &str, val: bool) -> UpdateInfo {
let num = match val {