From e24758f54b123670144df9940bb4c5f3f010f1f6 Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Mon, 16 Jun 2025 15:53:05 +0200 Subject: [PATCH] Added permission to enable/disable image capture --- backend/open_webui/config.py | 5 ++ backend/open_webui/routers/users.py | 1 + src/lib/components/admin/Users/Groups.svelte | 1 + .../admin/Users/Groups/EditGroupModal.svelte | 1 + .../admin/Users/Groups/Permissions.svelte | 9 +++ .../chat/MessageInput/InputMenu.svelte | 56 ++++++++++--------- 6 files changed, 46 insertions(+), 27 deletions(-) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 898ac1b59..0a36b6452 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -1081,6 +1081,10 @@ USER_PERMISSIONS_CHAT_SYSTEM_PROMPT = ( os.environ.get("USER_PERMISSIONS_CHAT_SYSTEM_PROMPT", "True").lower() == "true" ) +USER_PERMISSIONS_CHAT_IMAGE_CAPTURE = ( + os.environ.get("USER_PERMISSIONS_CHAT_IMAGE_CAPTURE", "True").lower() == "true" +) + USER_PERMISSIONS_CHAT_FILE_UPLOAD = ( os.environ.get("USER_PERMISSIONS_CHAT_FILE_UPLOAD", "True").lower() == "true" ) @@ -1167,6 +1171,7 @@ DEFAULT_USER_PERMISSIONS = { "chat": { "controls": USER_PERMISSIONS_CHAT_CONTROLS, "system_prompt": USER_PERMISSIONS_CHAT_SYSTEM_PROMPT, + "image_capture": USER_PERMISSIONS_CHAT_IMAGE_CAPTURE, "file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD, "delete": USER_PERMISSIONS_CHAT_DELETE, "edit": USER_PERMISSIONS_CHAT_EDIT, diff --git a/backend/open_webui/routers/users.py b/backend/open_webui/routers/users.py index 16cc2c375..38f6b95c9 100644 --- a/backend/open_webui/routers/users.py +++ b/backend/open_webui/routers/users.py @@ -134,6 +134,7 @@ class SharingPermissions(BaseModel): class ChatPermissions(BaseModel): controls: bool = True system_prompt: bool = True + image_capture: bool = True file_upload: bool = True delete: bool = True edit: bool = True diff --git a/src/lib/components/admin/Users/Groups.svelte b/src/lib/components/admin/Users/Groups.svelte index 338fbbd4c..ab03b91a5 100644 --- a/src/lib/components/admin/Users/Groups.svelte +++ b/src/lib/components/admin/Users/Groups.svelte @@ -66,6 +66,7 @@ chat: { controls: true, system_prompt: true, + image_capture: true, file_upload: true, delete: true, edit: true, diff --git a/src/lib/components/admin/Users/Groups/EditGroupModal.svelte b/src/lib/components/admin/Users/Groups/EditGroupModal.svelte index 8cc353064..7942b01ff 100644 --- a/src/lib/components/admin/Users/Groups/EditGroupModal.svelte +++ b/src/lib/components/admin/Users/Groups/EditGroupModal.svelte @@ -46,6 +46,7 @@ }, chat: { controls: true, + image_capture: true, file_upload: true, delete: true, edit: true, diff --git a/src/lib/components/admin/Users/Groups/Permissions.svelte b/src/lib/components/admin/Users/Groups/Permissions.svelte index 04e81a807..9a0fabd22 100644 --- a/src/lib/components/admin/Users/Groups/Permissions.svelte +++ b/src/lib/components/admin/Users/Groups/Permissions.svelte @@ -21,6 +21,7 @@ }, chat: { controls: true, + image_capture: true, file_upload: true, delete: true, edit: true, @@ -271,6 +272,14 @@ +
+
+ {$i18n.t('Allow Image capture')} +
+ + +
+
{$i18n.t('Allow Chat Delete')} diff --git a/src/lib/components/chat/MessageInput/InputMenu.svelte b/src/lib/components/chat/MessageInput/InputMenu.svelte index 5013f18f0..d01a9bd9f 100644 --- a/src/lib/components/chat/MessageInput/InputMenu.svelte +++ b/src/lib/components/chat/MessageInput/InputMenu.svelte @@ -173,36 +173,38 @@
{/if} - - { - if (fileUploadEnabled) { - if (!detectMobile()) { - screenCaptureHandler(); - } else { - const cameraInputElement = document.getElementById('camera-input'); + {#if $user?.role === 'admin' || $user?.permissions.chat?.image_capture} + + { + if (fileUploadEnabled) { + if (!detectMobile()) { + screenCaptureHandler(); + } else { + const cameraInputElement = document.getElementById('camera-input'); - if (cameraInputElement) { - cameraInputElement.click(); + if (cameraInputElement) { + cameraInputElement.click(); + } } } - } - }} - > - -
{$i18n.t('Capture')}
-
-
+ }} + > + +
{$i18n.t('Capture')}
+
+
+ {/if}