Skip to content

Commit

Permalink
semantic search return content (#5897)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoinTyang authored Jan 15, 2024
1 parent 75a26dd commit 71ee501
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/src/components/search/ai-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ export default class AISearch extends Component {
items[i]['repo_id'] = data[i].repo_id;
items[i]['repo_name'] = data[i].repo_name;
items[i]['is_dir'] = data[i].is_dir;
items[i]['content'] = data[i].content;
items[i]['link_content'] = decodeURI(data[i].fullpath).substring(1);
}
return items;
Expand Down
11 changes: 11 additions & 0 deletions seahub/ai/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
get_file_download_token, get_search_repos, RELATED_REPOS_PREFIX, RELATED_REPOS_CACHE_TIMEOUT, SEARCH_REPOS_LIMIT, \
format_repos
from seahub.utils import is_org_context, normalize_cache_key
from seahub.views import check_folder_permission

from seaserv import seafile_api

Expand Down Expand Up @@ -104,6 +105,11 @@ def post(self, request):
error_msg = 'Library %s not found.' % search_repo
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

# permission check
if not check_folder_permission(request, search_repo, '/'):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

repos = [(repo.id, repo.origin_repo_id, repo.origin_path, repo.name)]
is_all_repo = False

Expand Down Expand Up @@ -175,6 +181,11 @@ def post(self, request):
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

# permission check
if not check_folder_permission(request, repo_id, '/'):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

repo = (repo.id, repo.origin_repo_id, repo.origin_path, repo.name)

params = {
Expand Down

0 comments on commit 71ee501

Please sign in to comment.