From e5516adf4892823147ed9a74fad66a8bbd1b16b7 Mon Sep 17 00:00:00 2001 From: freamon Date: Wed, 22 Jan 2025 01:22:06 +0000 Subject: [PATCH] API: allow search to bring in remote communities --- app/api/alpha/utils/community.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/api/alpha/utils/community.py b/app/api/alpha/utils/community.py index d7ad1638..1a410446 100644 --- a/app/api/alpha/utils/community.py +++ b/app/api/alpha/utils/community.py @@ -1,6 +1,7 @@ from app import cache from app.api.alpha.views import community_view from app.api.alpha.utils.validators import required, integer_expected, boolean_expected +from app.community.util import search_for_community from app.utils import authorise_api_user from app.models import Community, CommunityMember from app.shared.community import join_community, leave_community, block_community, unblock_community @@ -44,7 +45,12 @@ def get_community_list(auth, data): page = int(data['page']) if data and 'page' in data else 1 limit = int(data['limit']) if data and 'limit' in data else 10 + user_id = authorise_api_user(auth) if auth else None + query = data['q'] if data and 'q' in data else '' + if user_id and '@' in query and '.' in query and query.startswith('!'): + search_for_community(query) + query = query[1:] user_id = authorise_api_user(auth) if auth else None