From 59226d36a5bd7a3c2fdaaa31cb9217d06ba12d7e Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Wed, 16 Oct 2024 15:25:49 +0800 Subject: [PATCH] feat: add incoming information into sessions --- internal/core/plugin_daemon/basic.go | 14 +++----------- internal/core/plugin_daemon/generic.go | 4 ---- internal/core/session_manager/session.go | 10 +++++++--- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/internal/core/plugin_daemon/basic.go b/internal/core/plugin_daemon/basic.go index bef69c8..8afcc5d 100644 --- a/internal/core/plugin_daemon/basic.go +++ b/internal/core/plugin_daemon/basic.go @@ -6,18 +6,10 @@ func getBasicPluginAccessMap( user_id string, access_type access_types.PluginAccessType, action access_types.PluginAccessAction, - conversation_id *string, - message_id *string, - app_id *string, - endpoint_id *string, ) map[string]any { return map[string]any{ - "user_id": user_id, - "type": access_type, - "action": action, - "conversation_id": conversation_id, - "message_id": message_id, - "app_id": app_id, - "endpoint_id": endpoint_id, + "user_id": user_id, + "type": access_type, + "action": action, } } diff --git a/internal/core/plugin_daemon/generic.go b/internal/core/plugin_daemon/generic.go index 9fea5da..43dea62 100644 --- a/internal/core/plugin_daemon/generic.go +++ b/internal/core/plugin_daemon/generic.go @@ -106,10 +106,6 @@ func getInvokePluginMap( session.UserID, session.InvokeFrom, session.Action, - session.ConversationID, - session.MessageID, - session.AppID, - session.EndpointID, ) for k, v := range parser.StructToMap(request) { req[k] = v diff --git a/internal/core/session_manager/session.go b/internal/core/session_manager/session.go index 531d5da..8e453c1 100644 --- a/internal/core/session_manager/session.go +++ b/internal/core/session_manager/session.go @@ -163,9 +163,13 @@ const ( func (s *Session) Message(event PLUGIN_IN_STREAM_EVENT, data any) []byte { return parser.MarshalJsonBytes(map[string]any{ - "session_id": s.ID, - "event": event, - "data": data, + "session_id": s.ID, + "conversation_id": s.ConversationID, + "message_id": s.MessageID, + "app_id": s.AppID, + "endpoint_id": s.EndpointID, + "event": event, + "data": data, }) }