mirror of
https://github.com/haiwen/seafile.git
synced 2025-01-08 11:57:44 +08:00
add update share subdir perm api
This commit is contained in:
parent
7d7d5b01b1
commit
5a78ed80e5
@ -2564,6 +2564,73 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
seafile_update_share_subdir_perm_for_user (const char *repo_id,
|
||||
const char *path,
|
||||
const char *owner,
|
||||
const char *share_user,
|
||||
const char *permission,
|
||||
GError **error)
|
||||
{
|
||||
if (is_empty_string (repo_id) || !is_uuid_valid (repo_id)) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||
"Invalid repo_id parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (is_empty_string (path) || strcmp (path, "/") == 0) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||
"Invalid path parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (is_empty_string (owner)) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||
"Invalid owner parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (is_empty_string (share_user) ||
|
||||
strcmp (owner, share_user) == 0) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||
"Invalid share_user parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!is_permission_valid (permission)) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||
"Invalid permission parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *real_path;
|
||||
char *vrepo_id;
|
||||
int ret = 0;
|
||||
|
||||
real_path = format_dir_path (path);
|
||||
vrepo_id = seaf_repo_manager_get_virtual_repo_id (seaf->repo_mgr, repo_id,
|
||||
real_path, owner);
|
||||
if (!vrepo_id) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
||||
"Failed to get shared sub repo");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = seaf_share_manager_set_permission (seaf->share_mgr, vrepo_id,
|
||||
owner, share_user,
|
||||
permission);
|
||||
if (ret < 0) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
||||
"Failed to update share subdir permission for user");
|
||||
}
|
||||
g_free (vrepo_id);
|
||||
|
||||
out:
|
||||
g_free (real_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
GList *
|
||||
seafile_list_repo_shared_group (const char *from_user, const char *repo_id,
|
||||
GError **error)
|
||||
@ -2787,6 +2854,72 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
seafile_update_share_subdir_perm_for_group (const char *repo_id,
|
||||
const char *path,
|
||||
const char *owner,
|
||||
int share_group,
|
||||
const char *permission,
|
||||
GError **error)
|
||||
{
|
||||
if (is_empty_string (repo_id) || !is_uuid_valid (repo_id)) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||
"Invalid repo_id parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (is_empty_string (path) || strcmp (path, "/") == 0) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||
"Invalid path parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (is_empty_string (owner)) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||
"Invalid owner parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (share_group < 0) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||
"Invalid share_group parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!is_permission_valid (permission)) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||
"Invalid permission parameter");
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *real_path;
|
||||
char *vrepo_id;
|
||||
int ret = 0;
|
||||
|
||||
real_path = format_dir_path (path);
|
||||
vrepo_id = seaf_repo_manager_get_virtual_repo_id (seaf->repo_mgr, repo_id,
|
||||
real_path, owner);
|
||||
if (!vrepo_id) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
||||
"Failed to get shared sub repo");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = seaf_repo_manager_set_group_repo_perm (seaf->repo_mgr, vrepo_id,
|
||||
share_group, permission,
|
||||
error);
|
||||
if (ret < 0) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
||||
"Failed to update share subdir permission for group");
|
||||
}
|
||||
g_free (vrepo_id);
|
||||
|
||||
out:
|
||||
g_free (real_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *
|
||||
seafile_get_shared_groups_by_repo(const char *repo_id, GError **error)
|
||||
{
|
||||
|
@ -518,6 +518,14 @@ seafile_unshare_subdir_for_user (const char *repo_id,
|
||||
const char *share_user,
|
||||
GError **error);
|
||||
|
||||
int
|
||||
seafile_update_share_subdir_perm_for_user (const char *repo_id,
|
||||
const char *path,
|
||||
const char *owner,
|
||||
const char *share_user,
|
||||
const char *permission,
|
||||
GError **error);
|
||||
|
||||
int
|
||||
seafile_add_share (const char *repo_id, const char *from_email,
|
||||
const char *to_email, const char *permission,
|
||||
@ -555,6 +563,14 @@ seafile_unshare_subdir_for_group (const char *repo_id,
|
||||
int share_group,
|
||||
GError **error);
|
||||
|
||||
int
|
||||
seafile_update_share_subdir_perm_for_group (const char *repo_id,
|
||||
const char *path,
|
||||
const char *owner,
|
||||
int share_group,
|
||||
const char *permission,
|
||||
GError **error);
|
||||
|
||||
int
|
||||
seafile_group_share_repo (const char *repo_id, int group_id,
|
||||
const char *user_name, const char *permission,
|
||||
|
@ -22,6 +22,7 @@ func_table = [
|
||||
[ "int", ["string", "string", "string"] ],
|
||||
[ "int", ["string", "string", "int", "int"] ],
|
||||
[ "int", ["string", "string", "string", "int"] ],
|
||||
[ "int", ["string", "string", "string", "int", "string"] ],
|
||||
[ "int", ["string", "string", "string", "string"] ],
|
||||
[ "int", ["string", "string", "string", "string", "string"] ],
|
||||
[ "int", ["string", "string", "string", "string", "string", "string"] ],
|
||||
|
@ -557,6 +557,10 @@ class SeafServerThreadedRpcClient(ccnet.RpcClientBase):
|
||||
def unshare_subdir_for_user(repo_id, path, owner, share_user):
|
||||
pass
|
||||
|
||||
@searpc_func("int", ["string", "string", "string", "string", "string"])
|
||||
def update_share_subdir_perm_for_user(repo_id, path, owner, share_user, permission):
|
||||
pass
|
||||
|
||||
@searpc_func("objlist", ["int", "string", "string", "int", "int"])
|
||||
def seafile_list_org_share_repos(org_id, email, query_col, start, limit):
|
||||
pass
|
||||
@ -610,6 +614,10 @@ class SeafServerThreadedRpcClient(ccnet.RpcClientBase):
|
||||
def unshare_subdir_for_group(repo_id, path, owner, share_group):
|
||||
pass
|
||||
|
||||
@searpc_func("int", ["string", "string", "string", "int", "string"])
|
||||
def update_share_subdir_perm_for_group(repo_id, path, owner, share_group, permission):
|
||||
pass
|
||||
|
||||
@searpc_func("string", ["int"])
|
||||
def seafile_get_group_repoids(group_id):
|
||||
pass
|
||||
|
@ -336,6 +336,11 @@ class SeafileAPI(object):
|
||||
return seafserv_threaded_rpc.unshare_subdir_for_user(repo_id, path, owner,
|
||||
share_user)
|
||||
|
||||
def update_share_subdir_perm_for_user(self, repo_id, path, owner,
|
||||
share_user, permission):
|
||||
return seafserv_threaded_rpc.update_share_subdir_perm_for_user(repo_id, path, owner,
|
||||
share_user, permission)
|
||||
|
||||
def get_share_out_repo_list(self, username, start, limit):
|
||||
"""
|
||||
Get repo list shared by this user.
|
||||
@ -399,6 +404,11 @@ class SeafileAPI(object):
|
||||
return seafserv_threaded_rpc.unshare_subdir_for_group(repo_id, path, owner,
|
||||
share_group)
|
||||
|
||||
def update_share_subdir_perm_for_group(self, repo_id, path, owner,
|
||||
share_group, permission):
|
||||
return seafserv_threaded_rpc.update_share_subdir_perm_for_group(repo_id, path, owner,
|
||||
share_group, permission)
|
||||
|
||||
def get_group_repoids(self, group_id):
|
||||
"""
|
||||
Return the list of group repo ids
|
||||
|
@ -386,6 +386,11 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode)
|
||||
"unshare_subdir_for_user",
|
||||
searpc_signature_int__string_string_string_string());
|
||||
|
||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||
seafile_update_share_subdir_perm_for_user,
|
||||
"update_share_subdir_perm_for_user",
|
||||
searpc_signature_int__string_string_string_string_string());
|
||||
|
||||
/* share repo to group */
|
||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||
seafile_group_share_repo,
|
||||
@ -410,6 +415,11 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode)
|
||||
"unshare_subdir_for_group",
|
||||
searpc_signature_int__string_string_string_int());
|
||||
|
||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||
seafile_update_share_subdir_perm_for_group,
|
||||
"update_share_subdir_perm_for_group",
|
||||
searpc_signature_int__string_string_string_int_string());
|
||||
|
||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||
seafile_get_group_repoids,
|
||||
"seafile_get_group_repoids",
|
||||
|
Loading…
Reference in New Issue
Block a user