diff --git a/backend/open_webui/models/users.py b/backend/open_webui/models/users.py index 81edc2d924..05000744dd 100644 --- a/backend/open_webui/models/users.py +++ b/backend/open_webui/models/users.py @@ -220,7 +220,7 @@ class UsersTable: filter: Optional[dict] = None, skip: Optional[int] = None, limit: Optional[int] = None, - ) -> UserListResponse: + ) -> dict: with get_db() as db: query = db.query(User) diff --git a/backend/open_webui/routers/channels.py b/backend/open_webui/routers/channels.py index cf3603c6ff..0a4c7e5d84 100644 --- a/backend/open_webui/routers/channels.py +++ b/backend/open_webui/routers/channels.py @@ -200,14 +200,11 @@ async def send_notification(name, webui_url, channel, message, active_user_ids): users = get_users_with_access("read", channel.access_control) for user in users: - if user.id in active_user_ids: - continue - else: + if user.id not in active_user_ids: if user.settings: webhook_url = user.settings.ui.get("notifications", {}).get( "webhook_url", None ) - if webhook_url: await post_webhook( name, @@ -221,6 +218,8 @@ async def send_notification(name, webui_url, channel, message, active_user_ids): }, ) + return True + @router.post("/{id}/messages/post", response_model=Optional[MessageModel]) async def post_new_message( @@ -305,14 +304,16 @@ async def post_new_message( active_user_ids = get_user_ids_from_room(f"channel:{channel.id}") - background_tasks.add_task( - send_notification, - request.app.state.WEBUI_NAME, - request.app.state.config.WEBUI_URL, - channel, - message, - active_user_ids, - ) + async def background_handler(): + await send_notification( + request.app.state.WEBUI_NAME, + request.app.state.config.WEBUI_URL, + channel, + message, + active_user_ids, + ) + + background_tasks.add_task(background_handler) return MessageModel(**message.model_dump()) except Exception as e: diff --git a/backend/open_webui/utils/access_control.py b/backend/open_webui/utils/access_control.py index 1529773c44..6215a6ac22 100644 --- a/backend/open_webui/utils/access_control.py +++ b/backend/open_webui/utils/access_control.py @@ -130,9 +130,10 @@ def has_access( # Get all users with access to a resource def get_users_with_access( type: str = "write", access_control: Optional[dict] = None -) -> List[UserModel]: +) -> list[UserModel]: if access_control is None: - return Users.get_users() + result = Users.get_users() + return result.get("users", []) permission_access = access_control.get(type, {}) permitted_group_ids = permission_access.get("group_ids", []) diff --git a/src/lib/components/channel/MessageInput/MentionList.svelte b/src/lib/components/channel/MessageInput/MentionList.svelte index 307406e69a..30ba8f7513 100644 --- a/src/lib/components/channel/MessageInput/MentionList.svelte +++ b/src/lib/components/channel/MessageInput/MentionList.svelte @@ -52,12 +52,12 @@ const item = filteredItems[index]; if (!item) return; - // Add the "U:", "A:" or "C:" prefix to the id + // Add the "U:", "M:" or "C:" prefix to the id // and also append the label after a pipe | // so that the mention renderer can show the label if (item) command({ - id: `${item.type === 'user' ? 'U' : item.type === 'model' ? 'A' : 'C'}:${item.id}|${item.label}`, + id: `${item.type === 'user' ? 'U' : item.type === 'model' ? 'M' : 'C'}:${item.id}|${item.label}`, label: item.label }); }; diff --git a/src/lib/components/chat/Messages/Markdown/MarkdownInlineTokens/MentionToken.svelte b/src/lib/components/chat/Messages/Markdown/MarkdownInlineTokens/MentionToken.svelte index e536fd8cfb..b8b3874b72 100644 --- a/src/lib/components/chat/Messages/Markdown/MarkdownInlineTokens/MentionToken.svelte +++ b/src/lib/components/chat/Messages/Markdown/MarkdownInlineTokens/MentionToken.svelte @@ -53,8 +53,8 @@ } else if (triggerChar === '@') { if (idType === 'U') { // User - } else if (idType === 'A') { - // Agent/assistant/ai model + } else if (idType === 'M') { + // Model const model = $models.find((m) => m.id === id); if (model) { label = model.name; @@ -77,9 +77,8 @@ if (idType === 'U') { // Open user profile console.log('Clicked user mention', id); - } else if (idType === 'A') { - // Open agent/assistant/ai model profile - console.log('Clicked agent mention', id); + } else if (idType === 'M') { + console.log('Clicked model mention', id); await goto(`/?model=${id}`); } } else if (triggerChar === '#') { @@ -101,15 +100,15 @@ - - {#if triggerChar === '@' && idType === 'U'} + {#if triggerChar === '@' && idType === 'U'} + - {/if} - - + + + {/if}