Skip to content

Commit

Permalink
fix search shared repo bug (#5851)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoinTyang authored Dec 21, 2023
1 parent 0bda48d commit 410440b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions seahub/ai/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,22 @@ def post(self, request):

if search_repo == 'all':
org_id = request.user.org.org_id if is_org_context(request) else None
repo_id_list = get_search_repos(request.user.username, org_id)
repos = get_search_repos(request.user.username, org_id)
is_all_repo = True
else:
repo_id_list = [search_repo]
try:
repo = seafile_api.get_repo(search_repo)
except Exception as e:
logger.error(e)
error_msg = 'Library %s not found.' % search_repo
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)

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

params = {
'query': query,
'repo_id_list': repo_id_list,
'repos': repos,
'count': count,
'is_all_repo': is_all_repo,
}
Expand Down
6 changes: 3 additions & 3 deletions seahub/ai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ def get_file_download_token(repo_id, file_id, username):


def get_search_repos(username, org_id):
repo_id_list = []
repos = []
owned_repos, shared_repos, group_repos, public_repos = get_user_repos(username, org_id=org_id)
repo_list = owned_repos + shared_repos + group_repos + public_repos

for repo in repo_list:
repo_id_list.append(repo.id)
repos.append((repo.id, repo.origin_repo_id, repo.origin_path))

return repo_id_list
return repos

0 comments on commit 410440b

Please sign in to comment.