mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-21 00:45:18 +00:00
Get the list of groups of a user
This commit is contained in:
@ -8,6 +8,7 @@ use crate::data::group::GroupVisibilityLevel;
|
||||
use crate::data::group_id::GroupID;
|
||||
use crate::data::group_member::{GroupMember, GroupMembershipLevel};
|
||||
use crate::data::new_group::NewGroup;
|
||||
use crate::data::user::UserID;
|
||||
use crate::helpers::database;
|
||||
use crate::utils::date_utils::time;
|
||||
|
||||
@ -67,6 +68,19 @@ pub fn insert_member(m: &GroupMember) -> ResultBoxError<()> {
|
||||
.insert_drop_result()
|
||||
}
|
||||
|
||||
/// Get the list of groups of a user
|
||||
pub fn get_list_user(user_id: UserID, only_followed: bool) -> ResultBoxError<Vec<GroupID>> {
|
||||
let mut query = database::QueryInfo::new(GROUPS_MEMBERS_TABLE)
|
||||
.add_field("groups_id")
|
||||
.cond_user_id("user_id", user_id);
|
||||
|
||||
if only_followed {
|
||||
query = query.cond_legacy_bool("following", true);
|
||||
}
|
||||
|
||||
query.exec(|row| row.get_group_id("groups_id"))
|
||||
}
|
||||
|
||||
/// Find a group id by virtual directory
|
||||
pub fn find_by_virtual_directory(dir: &str) -> ResultBoxError<GroupID> {
|
||||
database::QueryInfo::new(GROUPS_LIST_TABLE)
|
||||
|
Reference in New Issue
Block a user