1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-29 16:56:28 +00:00

Upgrade method

This commit is contained in:
Pierre HUBERT 2020-06-23 19:01:07 +02:00
parent 2cf2146f17
commit 04a0cd23dc
3 changed files with 6 additions and 5 deletions

View File

@ -5,6 +5,7 @@
use serde::{Serialize};
use crate::data::error::ResultBoxError;
use crate::data::user::User;
use crate::data::group_id::GroupID;
#[derive(Serialize)]
pub struct ResultFindVirtualDirectory {
@ -14,14 +15,14 @@ pub struct ResultFindVirtualDirectory {
impl ResultFindVirtualDirectory {
/// Construct a new instance
pub fn new(user: ResultBoxError<User>, group: ResultBoxError<u64>) -> ResultFindVirtualDirectory {
pub fn new(user: ResultBoxError<User>, group: ResultBoxError<GroupID>) -> ResultFindVirtualDirectory {
match (user, group) {
// User
(Ok(u), _) => ResultFindVirtualDirectory { kind: "user".to_string(), id: u.id as u64 },
// Group
(_, Ok(g)) => ResultFindVirtualDirectory { kind: "group".to_string(), id: g },
(_, Ok(g)) => ResultFindVirtualDirectory { kind: "group".to_string(), id: g.id() },
_ => unreachable!()
}

View File

@ -2,7 +2,7 @@
//!
//! @author Pierre Hubert
#[derive(Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct GroupID(u64);
impl GroupID {

View File

@ -19,11 +19,11 @@ impl GroupVisibilityLevel {
}
/// Find a group id by virtual directory
pub fn find_by_virtual_directory(dir: &str) -> ResultBoxError<u64> {
pub fn find_by_virtual_directory(dir: &str) -> ResultBoxError<GroupID> {
database::QueryInfo::new(GROUPS_LIST_TABLE)
.cond("virtual_directory", dir)
.add_field("id")
.query_row(|res| res.get_u64("id"))
.query_row(|res| res.get_group_id("id"))
}
/// Search for group