mirror of
https://github.com/open-webui/open-webui
synced 2024-11-06 00:32:05 +00:00
fix: share chat issue
This commit is contained in:
parent
1e6ddb2fb3
commit
8dac4e91a5
@ -11,6 +11,7 @@ import logging
|
||||
|
||||
from apps.web.models.users import UserModel, UserUpdateForm, UserRoleUpdateForm, Users
|
||||
from apps.web.models.auths import Auths
|
||||
from apps.web.models.chats import Chats
|
||||
|
||||
from utils.utils import get_verified_user, get_password_hash, get_admin_user
|
||||
from constants import ERROR_MESSAGES
|
||||
@ -80,6 +81,17 @@ class UserResponse(BaseModel):
|
||||
@router.get("/{user_id}", response_model=UserResponse)
|
||||
async def get_user_by_id(user_id: str, user=Depends(get_verified_user)):
|
||||
|
||||
if user_id.startswith("shared-"):
|
||||
chat_id = user_id.replace("shared-", "")
|
||||
chat = Chats.get_chat_by_id(chat_id)
|
||||
if chat:
|
||||
user_id = chat.user_id
|
||||
else:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=ERROR_MESSAGES.USER_NOT_FOUND,
|
||||
)
|
||||
|
||||
user = Users.get_user_by_id(user_id)
|
||||
|
||||
if user:
|
||||
|
@ -13,6 +13,7 @@
|
||||
import Messages from '$lib/components/chat/Messages.svelte';
|
||||
import Navbar from '$lib/components/layout/Navbar.svelte';
|
||||
import { getUserById } from '$lib/apis/users';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
@ -90,7 +91,10 @@
|
||||
});
|
||||
|
||||
if (chat) {
|
||||
user = await getUserById(localStorage.token, chat.user_id);
|
||||
user = await getUserById(localStorage.token, chat.user_id).catch((error) => {
|
||||
console.error(error);
|
||||
return null;
|
||||
});
|
||||
|
||||
const chatContent = chat.chat;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user