fix: endpoint using default user
This commit is contained in:
parent
ece82b87bf
commit
50a5cfe56a
@ -1,6 +1,7 @@
|
|||||||
from collections.abc import Generator, Mapping
|
from collections.abc import Generator, Mapping
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
|
from controllers.service_api.wraps import create_or_update_end_user_for_user_id
|
||||||
from core.app.apps.advanced_chat.app_generator import AdvancedChatAppGenerator
|
from core.app.apps.advanced_chat.app_generator import AdvancedChatAppGenerator
|
||||||
from core.app.apps.agent_chat.app_generator import AgentChatAppGenerator
|
from core.app.apps.agent_chat.app_generator import AgentChatAppGenerator
|
||||||
from core.app.apps.chat.app_generator import ChatAppGenerator
|
from core.app.apps.chat.app_generator import ChatAppGenerator
|
||||||
@ -29,6 +30,9 @@ class PluginAppBackwardsInvocation(BaseBackwardsInvocation):
|
|||||||
invoke app
|
invoke app
|
||||||
"""
|
"""
|
||||||
app = cls._get_app(app_id, tenant_id)
|
app = cls._get_app(app_id, tenant_id)
|
||||||
|
if not user_id:
|
||||||
|
user = create_or_update_end_user_for_user_id(app)
|
||||||
|
else:
|
||||||
user = cls._get_user(user_id)
|
user = cls._get_user(user_id)
|
||||||
|
|
||||||
conversation_id = conversation_id or ""
|
conversation_id = conversation_id or ""
|
||||||
@ -178,10 +182,13 @@ class PluginAppBackwardsInvocation(BaseBackwardsInvocation):
|
|||||||
"""
|
"""
|
||||||
get app
|
get app
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
app = db.session.query(App). \
|
app = db.session.query(App). \
|
||||||
filter(App.id == app_id). \
|
filter(App.id == app_id). \
|
||||||
filter(App.tenant_id == tenant_id). \
|
filter(App.tenant_id == tenant_id). \
|
||||||
first()
|
first()
|
||||||
|
except Exception:
|
||||||
|
raise ValueError("app not found")
|
||||||
|
|
||||||
if not app:
|
if not app:
|
||||||
raise ValueError("app not found")
|
raise ValueError("app not found")
|
||||||
|
Loading…
Reference in New Issue
Block a user