diff --git a/src/lib/helpers/types/conversationTypes.js b/src/lib/helpers/types/conversationTypes.js index 4ec583fc..224a9bff 100644 --- a/src/lib/helpers/types/conversationTypes.js +++ b/src/lib/helpers/types/conversationTypes.js @@ -30,6 +30,7 @@ * @property {string} status - The conversation status. * @property {Object} states - The conversation states. * @property {string[]} tags - The conversation tags. + * @property {boolean?} accessible - Whether the conversation is accessible. * @property {boolean?} is_realtime_enabled - Whether the realtime feature is enabled. * @property {Date} updated_time - The conversation updated time. * @property {Date} created_time - The conversation created time. diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte index d30d913a..7664c9a1 100644 --- a/src/routes/+error.svelte +++ b/src/routes/+error.svelte @@ -1,11 +1,57 @@ -{#if $page.status === 500 } +{#if status === 500} {:else} -

{$page.status} {$page.error.message}

-

Sorry, something went wrong on our end. Please try again later.

+ + + {/if} \ No newline at end of file diff --git a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte index 4a78ec99..03742a98 100644 --- a/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte +++ b/src/routes/chat/[agentId]/[conversationId]/chat-box.svelte @@ -3,6 +3,7 @@ import { Pane, Splitpanes } from 'svelte-splitpanes'; import Viewport from 'svelte-viewport-info'; import { page } from '$app/stores'; + import { goto } from '$app/navigation'; import Swal from 'sweetalert2'; import 'overlayscrollbars/overlayscrollbars.css'; import { OverlayScrollbars } from 'overlayscrollbars'; @@ -226,9 +227,9 @@ } } - $: { - disableAction = !ADMIN_ROLES.includes(currentUser?.role || '') && currentUser?.id !== conversationUser?.id || !AgentExtensions.chatable(agent); - } + // $: { + // disableAction = !ADMIN_ROLES.includes(currentUser?.role || '') && currentUser?.id !== conversationUser?.id || !AgentExtensions.chatable(agent); + // } setContext('chat-window-context', { autoScrollToBottom: autoScrollToBottom @@ -237,6 +238,11 @@ onMount(async () => { disableSpeech = navigator.userAgent.includes('Firefox'); conversation = await getConversation(params.conversationId, true); + if (conversation == null || conversation.accessible === false) { + goto('/error', { replaceState: true }); + return; + } + dialogs = await getDialogs(params.conversationId, dialogCount); conversationUser = conversation?.user; selectedTags = conversation?.tags || []; @@ -375,7 +381,7 @@ } function initChatView() { - isFrame = window.location != window.parent.location; + isFrame = window.self != window.top; mode = $page.url.searchParams.get('mode') || ''; // initial condition isPersistLogClosed = false;