refac: skip background work for accounts that were deactivated meanwhile (#33801)

Follow-up generation after a response and replies to channel mentions are now skipped when the account that triggered them has been deactivated in the meantime.
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-06 07:53:32 +09:00
1 parent 88cf7f209c
commit dd42f4e913
2 files changed
+9 -2

No files matched your search

+5 -2
View File
@@ -59,7 +59,7 @@ from open_webui.utils.apps import (
has_app_access,
send_app_mention,
)
from open_webui.utils.auth import get_admin_user, get_verified_user
from open_webui.utils.auth import get_admin_user, get_verified_user, get_verified_user_by_id
from open_webui.utils.channels import extract_mentions, replace_mentions
from open_webui.utils.files import get_image_base64_from_file_id
from open_webui.utils.models import (
@@ -1152,7 +1152,7 @@ async def send_notification(request, channel, message, active_user_ids, db=None)
async def app_channel_reply_handler(channel_id, message_id, user_id):
"""Committed human messages only; errors never cause the human POST to retry."""
if not await Config.get('apps.enable'):
if not await Config.get('apps.enable') or not await get_verified_user_by_id(user_id):
return
async with get_async_db() as db:
message = await db.get(Message, message_id)
@@ -1228,6 +1228,9 @@ async def app_channel_reply_handler(channel_id, message_id, user_id):
async def model_response_handler(request, channel, message, user, db=None):
if not await get_verified_user_by_id(user.id):
return
MODELS = {model['id']: model for model in await get_filtered_models(await get_all_models(request, user=user), user)}
mentions = extract_mentions(message.content)
+4
View File
@@ -86,6 +86,7 @@ from open_webui.utils.access_control.files import get_owner_accessible_folder_fi
from open_webui.utils.access_control.folders import has_folder_access
from open_webui.utils.ask_user import stage_ask_user_tool_calls
from open_webui.utils.audit import log_model_usage
from open_webui.utils.auth import get_verified_user_by_id
from open_webui.utils.chat import generate_chat_completion
from open_webui.utils.chat_id import is_saved_chat_id, is_temporary_chat_id
from open_webui.utils.code_interpreter import execute_code_jupyter
@@ -3549,6 +3550,9 @@ async def background_tasks_handler(ctx):
tasks = ctx['tasks']
event_emitter = ctx['event_emitter']
if not await get_verified_user_by_id(user.id):
return
message = None
messages = []