mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-22 01:15:16 +00:00
Save new group settings in the database
This commit is contained in:
@ -671,6 +671,12 @@ impl UpdateInfo {
|
||||
self
|
||||
}
|
||||
|
||||
/// Filter with a group id
|
||||
pub fn cond_group_id(mut self, name: &str, val: &GroupID) -> UpdateInfo {
|
||||
self.cond.insert(name.to_string(), Value::UInt(val.id()));
|
||||
self
|
||||
}
|
||||
|
||||
/// Filter with an unsigned integer
|
||||
pub fn cond_u64(mut self, name: &str, val: u64) -> UpdateInfo {
|
||||
self.cond.insert(name.to_string(), Value::UInt(val));
|
||||
@ -727,6 +733,11 @@ impl UpdateInfo {
|
||||
}
|
||||
|
||||
/// Set a new unsigned number
|
||||
pub fn set_u32(mut self, name: &str, val: u32) -> UpdateInfo {
|
||||
self.set.insert(name.to_string(), Value::UInt(val as u64));
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_u64(mut self, name: &str, val: u64) -> UpdateInfo {
|
||||
self.set.insert(name.to_string(), Value::UInt(val));
|
||||
self
|
||||
|
@ -282,6 +282,24 @@ pub fn check_directory_availability(dir: &str, group_id: Option<GroupID>) -> Res
|
||||
}
|
||||
}
|
||||
|
||||
/// Set new settings to the group, except group logo
|
||||
pub fn set_settings(g: &Group) -> ResultBoxError {
|
||||
database::UpdateInfo::new(GROUPS_LIST_TABLE)
|
||||
.cond_group_id("id", &g.id)
|
||||
|
||||
// Updates
|
||||
.set_str("name", &g.name)
|
||||
.set_u64("visibility", g.visibility.to_db())
|
||||
.set_u32("registration_level", g.registration_level.to_db())
|
||||
.set_u32("posts_level", g.posts_creation_level.to_db())
|
||||
.set_opt_str("virtual_directory", g.virtual_directory.clone())
|
||||
.set_opt_str("description", g.description.clone())
|
||||
.set_opt_str("url", g.url.clone())
|
||||
|
||||
|
||||
.exec()
|
||||
}
|
||||
|
||||
/// Turn a database entry into a group struct
|
||||
fn db_to_group(row: &database::RowResult) -> ResultBoxError<Group> {
|
||||
let group_id = row.get_group_id("id")?;
|
||||
|
Reference in New Issue
Block a user