Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
865c2683
Commit
865c2683
authored
Apr 02, 2024
by
Timothy J. Baek
Browse files
feat: delete shared chat link
parent
dcac8a77
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
50 deletions
+77
-50
backend/apps/web/routers/chats.py
backend/apps/web/routers/chats.py
+7
-6
src/lib/components/chat/ShareChatModal.svelte
src/lib/components/chat/ShareChatModal.svelte
+70
-44
No files found.
backend/apps/web/routers/chats.py
View file @
865c2683
...
@@ -226,16 +226,17 @@ async def share_chat_by_id(id: str, user=Depends(get_current_user)):
...
@@ -226,16 +226,17 @@ async def share_chat_by_id(id: str, user=Depends(get_current_user)):
############################
############################
@
router
.
delete
(
"/{
share_
id}/share"
,
response_model
=
Optional
[
bool
])
@
router
.
delete
(
"/{id}/share"
,
response_model
=
Optional
[
bool
])
async
def
delete_shared_chat_by_id
(
share_
id
:
str
,
user
=
Depends
(
get_current_user
)):
async
def
delete_shared_chat_by_id
(
id
:
str
,
user
=
Depends
(
get_current_user
)):
chat
=
Chats
.
get_chat_by_id_and_user_id
(
share_
id
,
user
.
id
)
chat
=
Chats
.
get_chat_by_id_and_user_id
(
id
,
user
.
id
)
if
chat
:
if
chat
:
if
not
chat
.
share_id
:
if
not
chat
.
share_id
:
return
False
return
False
result
=
Chats
.
delete_shared_chat_by_chat_id
(
chat
.
id
)
update_result
=
Chats
.
update_chat_share_id_by_id
(
chat
.
id
,
None
)
return
result
and
update_result
result
=
Chats
.
delete_shared_chat_by_chat_id
(
id
)
update_result
=
Chats
.
update_chat_share_id_by_id
(
id
,
None
)
return
result
and
update_result
!=
None
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
...
...
src/lib/components/chat/ShareChatModal.svelte
View file @
865c2683
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
const { saveAs } = fileSaver;
const { saveAs } = fileSaver;
import { toast } from 'svelte-sonner';
import { toast } from 'svelte-sonner';
import { getChatById, shareChatById } from '$lib/apis/chats';
import {
deleteSharedChatById,
getChatById, shareChatById } from '$lib/apis/chats';
import { chatId, modelfiles } from '$lib/stores';
import { chatId, modelfiles } from '$lib/stores';
import { copyToClipboard } from '$lib/utils';
import { copyToClipboard } from '$lib/utils';
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
toast.success($i18n.t('Copied shared conversation URL to clipboard!'));
toast.success($i18n.t('Copied shared conversation URL to clipboard!'));
copyToClipboard(chatShareUrl);
copyToClipboard(chatShareUrl);
chat = await getChatById(localStorage.token, $chatId);
};
};
const shareChat = async () => {
const shareChat = async () => {
...
@@ -78,6 +79,7 @@
...
@@ -78,6 +79,7 @@
onMount(async () => {
onMount(async () => {
chat = await getChatById(localStorage.token, $chatId);
chat = await getChatById(localStorage.token, $chatId);
console.log(chat);
});
});
</script>
</script>
...
@@ -105,10 +107,28 @@
...
@@ -105,10 +107,28 @@
</div>
</div>
<hr class=" dark:border-gray-800" />
<hr class=" dark:border-gray-800" />
{#if chat}
<div class="px-4 pt-4 pb-5 w-full flex flex-col justify-center">
<div class="px-4 pt-4 pb-5 w-full flex flex-col justify-center">
<div class=" text-sm dark:text-gray-300 mb-1">
<div class=" text-sm dark:text-gray-300 mb-1">
Messages you send after creating your link won't be shared. Anyone with the URL will be able
{#if chat.share_id}
to view the shared chat.
<a href="/s/{chat.share_id}" target="_blank"
>You have shared this chat <span class=" underline">before</span>.</a
>
Click here to
<button
class="underline"
on:click={async () => {
const res = await deleteSharedChatById(localStorage.token, $chatId);
if (res) {
chat = await getChatById(localStorage.token, $chatId);
}
}}>delete this link</button
> and create a new shared link.
{:else}
Messages you send after creating your link won't be shared. Anyone with the URL will be
able to view the shared chat.
{/if}
</div>
</div>
<div class="flex justify-end">
<div class="flex justify-end">
...
@@ -134,7 +154,12 @@
...
@@ -134,7 +154,12 @@
}}
}}
>
>
<Link />
<Link />
{#if chat.share_id}
{$i18n.t('Update and Copy Link')}
{:else}
{$i18n.t('Copy Link')}
{$i18n.t('Copy Link')}
{/if}
</button>
</button>
</div>
</div>
<div class="flex gap-1 mt-1.5">
<div class="flex gap-1 mt-1.5">
...
@@ -153,5 +178,6 @@
...
@@ -153,5 +178,6 @@
</div>
</div>
</div>
</div>
</div>
</div>
{/if}
</div>
</div>
</Modal>
</Modal>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment