mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 07:19:22 +00:00
Fix issue
This commit is contained in:
parent
b1a15da6fa
commit
aacf87cf40
@ -174,23 +174,26 @@ pub fn search_group(query: &str, limit: u64) -> ResultBoxError<Vec<GroupID>> {
|
|||||||
|
|
||||||
/// Get information about the membership of a user over a group
|
/// Get information about the membership of a user over a group
|
||||||
pub fn get_membership(group_id: &GroupID, user_id: Option<UserID>) -> ResultBoxError<GroupMember> {
|
pub fn get_membership(group_id: &GroupID, user_id: Option<UserID>) -> ResultBoxError<GroupMember> {
|
||||||
if user_id == None {
|
let default_membership = GroupMember {
|
||||||
return Ok(GroupMember {
|
|
||||||
id: 0,
|
id: 0,
|
||||||
user_id: 0,
|
user_id: 0,
|
||||||
group_id: group_id.clone(),
|
group_id: group_id.clone(),
|
||||||
time_create: 0,
|
time_create: 0,
|
||||||
level: GroupMembershipLevel::VISITOR,
|
level: GroupMembershipLevel::VISITOR,
|
||||||
following: false,
|
following: false,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if user_id == None {
|
||||||
|
return Ok(default_membership);
|
||||||
}
|
}
|
||||||
|
|
||||||
let user_id = user_id.unwrap();
|
let user_id = user_id.unwrap();
|
||||||
|
|
||||||
database::QueryInfo::new(GROUPS_MEMBERS_TABLE)
|
Ok(database::QueryInfo::new(GROUPS_MEMBERS_TABLE)
|
||||||
.cond_group_id("groups_id", group_id)
|
.cond_group_id("groups_id", group_id)
|
||||||
.cond_user_id("user_id", user_id)
|
.cond_user_id("user_id", user_id)
|
||||||
.query_row(db_to_group_member)
|
.query_row(db_to_group_member)
|
||||||
|
.unwrap_or(default_membership))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the membership level of a user for a group
|
/// Get the membership level of a user for a group
|
||||||
|
Loading…
Reference in New Issue
Block a user