Skip to content

Commit 62b208e

Browse files
author
Jicheng Lu
committed
add converation access
1 parent 918773b commit 62b208e

3 files changed

Lines changed: 60 additions & 7 deletions

File tree

src/lib/helpers/types/conversationTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
* @property {string} status - The conversation status.
3131
* @property {Object} states - The conversation states.
3232
* @property {string[]} tags - The conversation tags.
33+
* @property {boolean?} accessible - Whether the conversation is accessible.
3334
* @property {boolean?} is_realtime_enabled - Whether the realtime feature is enabled.
3435
* @property {Date} updated_time - The conversation updated time.
3536
* @property {Date} created_time - The conversation created time.

src/routes/+error.svelte

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,57 @@
11
<script>
22
import { page } from '$app/stores';
3-
import Error500 from '$lib/common/errors/error-500.svelte'
3+
import { Col, Container, Row } from '@sveltestrap/sveltestrap';
4+
import Link from 'svelte-link';
5+
import Error500 from '$lib/common/errors/error-500.svelte';
6+
import HeadTitle from '$lib/common/shared/HeadTitle.svelte';
7+
8+
$: status = $page.status;
9+
$: message = $page.error?.message || 'An error occurred';
10+
11+
$: icon = status === 404 ? 'bx-search-alt' : 'bx-error-circle';
12+
$: title = status === 404 ? 'Page Not Found' : message;
413
</script>
514

6-
{#if $page.status === 500 }
15+
{#if status === 500}
716
<Error500 />
817
{:else}
9-
<h1>{$page.status} {$page.error.message}</h1>
10-
<p>Sorry, something went wrong on our end. Please try again later.</p>
18+
<HeadTitle title="{status} Error" />
19+
20+
<div class="account-pages my-5 pt-5">
21+
<Container>
22+
<Row>
23+
<Col lg="12">
24+
<div class="text-center mb-5">
25+
<h1 class="display-2 fw-medium">
26+
{String(status).charAt(0)}
27+
<i class="bx {icon} bx-tada text-primary display-3" />
28+
{String(status).slice(1)}
29+
</h1>
30+
<h4 class="text-uppercase">{title}</h4>
31+
<p class="text-muted mt-3">
32+
{#if status === 404}
33+
The page you're looking for doesn't exist or has been moved.
34+
{:else}
35+
Sorry, something went wrong. Please try again later.
36+
{/if}
37+
</p>
38+
{#if status !== 404}
39+
<div class="mt-5 text-center">
40+
<Link class="btn btn-primary" href="page/dashboard">
41+
Back to Dashboard
42+
</Link>
43+
</div>
44+
{/if}
45+
</div>
46+
</Col>
47+
</Row>
48+
<Row class="justify-content-center">
49+
<Col md="8" xl="6">
50+
<div>
51+
<img src="/images/error-img.png" alt="" class="img-fluid" />
52+
</div>
53+
</Col>
54+
</Row>
55+
</Container>
56+
</div>
1157
{/if}

src/routes/chat/[agentId]/[conversationId]/chat-box.svelte

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Pane, Splitpanes } from 'svelte-splitpanes';
44
import Viewport from 'svelte-viewport-info';
55
import { page } from '$app/stores';
6+
import { goto } from '$app/navigation';
67
import Swal from 'sweetalert2';
78
import 'overlayscrollbars/overlayscrollbars.css';
89
import { OverlayScrollbars } from 'overlayscrollbars';
@@ -226,9 +227,9 @@
226227
}
227228
}
228229
229-
$: {
230-
disableAction = !ADMIN_ROLES.includes(currentUser?.role || '') && currentUser?.id !== conversationUser?.id || !AgentExtensions.chatable(agent);
231-
}
230+
// $: {
231+
// disableAction = !ADMIN_ROLES.includes(currentUser?.role || '') && currentUser?.id !== conversationUser?.id || !AgentExtensions.chatable(agent);
232+
// }
232233
233234
setContext('chat-window-context', {
234235
autoScrollToBottom: autoScrollToBottom
@@ -237,6 +238,11 @@
237238
onMount(async () => {
238239
disableSpeech = navigator.userAgent.includes('Firefox');
239240
conversation = await getConversation(params.conversationId, true);
241+
if (conversation == null || conversation.accessible === false) {
242+
goto('/error', { replaceState: true });
243+
return;
244+
}
245+
240246
dialogs = await getDialogs(params.conversationId, dialogCount);
241247
conversationUser = conversation?.user;
242248
selectedTags = conversation?.tags || [];

0 commit comments

Comments
 (0)