diff --git a/backend/open_webui/routers/channels.py b/backend/open_webui/routers/channels.py index 56af89181a..cb7c3f8a14 100644 --- a/backend/open_webui/routers/channels.py +++ b/backend/open_webui/routers/channels.py @@ -137,7 +137,7 @@ async def get_all_channels(user=Depends(get_verified_user)): ############################ -@router.get("/dm/{user_id}", response_model=Optional[ChannelModel]) +@router.get("/users/{user_id}", response_model=Optional[ChannelModel]) async def get_dm_channel_by_user_id( request: Request, user_id: str, user=Depends(get_verified_user) ): diff --git a/src/lib/apis/channels/index.ts b/src/lib/apis/channels/index.ts index 549c9004a1..0731b2ea9f 100644 --- a/src/lib/apis/channels/index.ts +++ b/src/lib/apis/channels/index.ts @@ -104,6 +104,37 @@ export const getChannelById = async (token: string = '', channel_id: string) => return res; }; +export const getDMChannelByUserId = async (token: string = '', user_id: string) => { + let error = null; + + const res = await fetch(`${WEBUI_API_BASE_URL}/channels/users/${user_id}`, { + method: 'GET', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + authorization: `Bearer ${token}` + } + }) + .then(async (res) => { + if (!res.ok) throw await res.json(); + return res.json(); + }) + .then((json) => { + return json; + }) + .catch((err) => { + error = err.detail; + console.error(err); + return null; + }); + + if (error) { + throw error; + } + + return res; +}; + export const getChannelMembersById = async ( token: string, channel_id: string, diff --git a/src/lib/components/channel/Messages/Message/ProfilePreview.svelte b/src/lib/components/channel/Messages/Message/ProfilePreview.svelte index a7daef9147..0e1d9e4076 100644 --- a/src/lib/components/channel/Messages/Message/ProfilePreview.svelte +++ b/src/lib/components/channel/Messages/Message/ProfilePreview.svelte @@ -15,7 +15,7 @@ let openPreview = false; - + + + {/if} {/if}