1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 07:19:22 +00:00

Fix issue

This commit is contained in:
Pierre HUBERT 2020-06-25 08:22:26 +02:00
parent b1a15da6fa
commit aacf87cf40

View File

@ -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
pub fn get_membership(group_id: &GroupID, user_id: Option<UserID>) -> ResultBoxError<GroupMember> {
let default_membership = GroupMember {
id: 0,
user_id: 0,
group_id: group_id.clone(),
time_create: 0,
level: GroupMembershipLevel::VISITOR,
following: false,
};
if user_id == None {
return Ok(GroupMember {
id: 0,
user_id: 0,
group_id: group_id.clone(),
time_create: 0,
level: GroupMembershipLevel::VISITOR,
following: false,
});
return Ok(default_membership);
}
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_user_id("user_id", user_id)
.query_row(db_to_group_member)
.unwrap_or(default_membership))
}
/// Get the membership level of a user for a group