mirror of
https://github.com/langgenius/dify.git
synced 2026-04-24 12:55:49 +08:00
fix(trigger): enhance error handling and refactor end user creation in trigger workflows
- Improved error handling in `TriggerSubscriptionListApi` to return a 404 response for ValueErrors. - Refactored end user creation logic in `service_api/wraps.py` to use `get_or_create_end_user` for better clarity and consistency. - Introduced a new method `create_end_user_batch` for batch creation of end users, optimizing database interactions. - Updated various trigger-related services to utilize the new end user handling, ensuring proper user context during trigger dispatching.
This commit is contained in:
@ -156,7 +156,6 @@ class PluginTriggerManager(BasePluginClient):
|
||||
def dispatch_event(
|
||||
self,
|
||||
tenant_id: str,
|
||||
user_id: str,
|
||||
provider: str,
|
||||
subscription: Mapping[str, Any],
|
||||
request: Request,
|
||||
@ -173,7 +172,6 @@ class PluginTriggerManager(BasePluginClient):
|
||||
path=f"plugin/{tenant_id}/dispatch/trigger/dispatch_event",
|
||||
type_=PluginTriggerDispatchResponse,
|
||||
data={
|
||||
"user_id": user_id,
|
||||
"data": {
|
||||
"provider": provider_id.provider_name,
|
||||
"subscription": subscription,
|
||||
@ -191,6 +189,7 @@ class PluginTriggerManager(BasePluginClient):
|
||||
|
||||
for resp in response:
|
||||
return TriggerDispatchResponse(
|
||||
user_id=resp.user_id or "",
|
||||
events=resp.events,
|
||||
response=deserialize_response(binascii.unhexlify(resp.raw_http_response.encode())),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user