mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
add public share toggle endpoint
This commit is contained in:
parent
88a9e623ba
commit
90cf6d4b1b
1 changed files with 29 additions and 0 deletions
|
|
@ -45,11 +45,14 @@ from app.schemas.new_chat import (
|
||||||
NewChatThreadUpdate,
|
NewChatThreadUpdate,
|
||||||
NewChatThreadVisibilityUpdate,
|
NewChatThreadVisibilityUpdate,
|
||||||
NewChatThreadWithMessages,
|
NewChatThreadWithMessages,
|
||||||
|
PublicShareToggleRequest,
|
||||||
|
PublicShareToggleResponse,
|
||||||
RegenerateRequest,
|
RegenerateRequest,
|
||||||
ThreadHistoryLoadResponse,
|
ThreadHistoryLoadResponse,
|
||||||
ThreadListItem,
|
ThreadListItem,
|
||||||
ThreadListResponse,
|
ThreadListResponse,
|
||||||
)
|
)
|
||||||
|
from app.services.public_chat_service import toggle_public_share
|
||||||
from app.tasks.chat.stream_new_chat import stream_new_chat
|
from app.tasks.chat.stream_new_chat import stream_new_chat
|
||||||
from app.users import current_active_user
|
from app.users import current_active_user
|
||||||
from app.utils.rbac import check_permission
|
from app.utils.rbac import check_permission
|
||||||
|
|
@ -729,6 +732,32 @@ async def update_thread_visibility(
|
||||||
) from None
|
) from None
|
||||||
|
|
||||||
|
|
||||||
|
@router.patch(
|
||||||
|
"/threads/{thread_id}/public-share", response_model=PublicShareToggleResponse
|
||||||
|
)
|
||||||
|
async def update_thread_public_share(
|
||||||
|
thread_id: int,
|
||||||
|
request: Request,
|
||||||
|
toggle_request: PublicShareToggleRequest,
|
||||||
|
session: AsyncSession = Depends(get_async_session),
|
||||||
|
user: User = Depends(current_active_user),
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Enable or disable public sharing for a thread.
|
||||||
|
|
||||||
|
Only the creator of the thread can manage public sharing.
|
||||||
|
When enabled, returns a public URL that anyone can use to view the chat.
|
||||||
|
"""
|
||||||
|
base_url = str(request.base_url).rstrip("/")
|
||||||
|
return await toggle_public_share(
|
||||||
|
session=session,
|
||||||
|
thread_id=thread_id,
|
||||||
|
enabled=toggle_request.enabled,
|
||||||
|
user=user,
|
||||||
|
base_url=base_url,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Message Endpoints
|
# Message Endpoints
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue