1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 00:45:18 +00:00

Get the ID of a group included in a request

This commit is contained in:
2020-06-24 13:34:09 +02:00
parent c245045d67
commit 4d844ccbad
6 changed files with 70 additions and 1 deletions

View File

@ -143,6 +143,11 @@ impl QueryInfo {
self
}
pub fn cond_group_id(mut self, key: &str, val: &GroupID) -> QueryInfo {
self.conditions.insert(key.to_string(), val.id().to_string());
self
}
pub fn cond_legacy_bool(mut self, key: &str, val: bool) -> QueryInfo {
let val = match val {
true => "1".to_string(),

View File

@ -81,6 +81,14 @@ pub fn get_list_user(user_id: UserID, only_followed: bool) -> ResultBoxError<Vec
query.exec(|row| row.get_group_id("groups_id"))
}
/// Check out whether a group exists or not
pub fn exists(group_id: &GroupID) -> ResultBoxError<bool> {
database::QueryInfo::new(GROUPS_LIST_TABLE)
.cond_group_id("id", group_id)
.exec_count()
.map(|m| m > 0)
}
/// Find a group id by virtual directory
pub fn find_by_virtual_directory(dir: &str) -> ResultBoxError<GroupID> {
database::QueryInfo::new(GROUPS_LIST_TABLE)