mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-04 21:32:39 +02:00
BE-1: Allow multiple connectors of same type per search space (remove duplicate checks, update docstrings)
This commit is contained in:
parent
9f75a3f0b3
commit
21d45b8b21
1 changed files with 3 additions and 17 deletions
|
|
@ -7,7 +7,7 @@ PUT /search-source-connectors/{connector_id} - Update a specific connector
|
||||||
DELETE /search-source-connectors/{connector_id} - Delete a specific connector
|
DELETE /search-source-connectors/{connector_id} - Delete a specific connector
|
||||||
POST /search-source-connectors/{connector_id}/index - Index content from a connector to a search space
|
POST /search-source-connectors/{connector_id}/index - Index content from a connector to a search space
|
||||||
|
|
||||||
Note: Each search space can have only one connector of each type per user (based on search_space_id, user_id, and connector_type).
|
Note: Each search space can have multiple connectors of the same type per user (uniqueness is no longer enforced, you may connect several accounts of the same type).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
@ -111,7 +111,7 @@ async def create_search_source_connector(
|
||||||
Create a new search source connector.
|
Create a new search source connector.
|
||||||
Requires CONNECTORS_CREATE permission.
|
Requires CONNECTORS_CREATE permission.
|
||||||
|
|
||||||
Each search space can have only one connector of each type (based on search_space_id and connector_type).
|
Each search space can have multiple connectors of the same type (e.g., multiple Gmail, Slack, etc. accounts).
|
||||||
The config must contain the appropriate keys for the connector type.
|
The config must contain the appropriate keys for the connector type.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
|
@ -124,20 +124,6 @@ async def create_search_source_connector(
|
||||||
"You don't have permission to create connectors in this search space",
|
"You don't have permission to create connectors in this search space",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if a connector with the same type already exists for this search space
|
|
||||||
result = await session.execute(
|
|
||||||
select(SearchSourceConnector).filter(
|
|
||||||
SearchSourceConnector.search_space_id == search_space_id,
|
|
||||||
SearchSourceConnector.connector_type == connector.connector_type,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
existing_connector = result.scalars().first()
|
|
||||||
if existing_connector:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=409,
|
|
||||||
detail=f"A connector with type {connector.connector_type} already exists in this search space.",
|
|
||||||
)
|
|
||||||
|
|
||||||
# Prepare connector data
|
# Prepare connector data
|
||||||
connector_data = connector.model_dump()
|
connector_data = connector.model_dump()
|
||||||
|
|
||||||
|
|
@ -183,7 +169,7 @@ async def create_search_source_connector(
|
||||||
await session.rollback()
|
await session.rollback()
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=409,
|
status_code=409,
|
||||||
detail=f"Integrity error: A connector with this type already exists in this search space. {e!s}",
|
detail=f"Integrity error: {e!s}",
|
||||||
) from e
|
) from e
|
||||||
except HTTPException:
|
except HTTPException:
|
||||||
await session.rollback()
|
await session.rollback()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue