@@ -780,10 +780,9 @@ func (h *SessionHandler) PatchConfigs(c *gin.Context) {
780780}
781781
782782type SessionSearchReq struct {
783- Query string `form:"query" json:"query" binding:"required" example:"find conversations about authentication"`
784- UserID string `form:"user_id" json:"user_id" binding:"required" example:"123e4567-e89b-12d3-a456-426614174000"`
785- ProjectID string `form:"project_id" json:"project_id" binding:"required" example:"123e4567-e89b-12d3-a456-426614174001"`
786- Limit int `form:"limit,default=10" json:"limit" binding:"omitempty,min=1,max=100" example:"10"`
783+ Query string `form:"query" json:"query" binding:"required" example:"find conversations about authentication"`
784+ User string `form:"user" json:"user" binding:"required" example:"alice@acontext.io"`
785+ Limit int `form:"limit,default=10" json:"limit" binding:"omitempty,min=1,max=100" example:"10"`
787786}
788787
789788// SessionSearch godoc
@@ -794,8 +793,7 @@ type SessionSearchReq struct {
794793// @Accept json
795794// @Produce json
796795// @Param query query string true "Search query text"
797- // @Param user_id query string true "User ID"
798- // @Param project_id query string true "Project ID"
796+ // @Param user query string true "user identifier" example(alice@acontext.io)
799797// @Param limit query integer false "Maximum number of results (1-100, default 10)"
800798// @Security BearerAuth
801799// @Success 200 {object} serializer.Response{data=httpclient.SessionSearchResponse}
@@ -807,12 +805,24 @@ func (h *SessionHandler) SessionSearch(c *gin.Context) {
807805 return
808806 }
809807
808+ project , ok := c .MustGet ("project" ).(* model.Project )
809+ if ! ok {
810+ c .JSON (http .StatusBadRequest , serializer .ParamErr ("" , errors .New ("project not found" )))
811+ return
812+ }
813+
814+ user , err := h .userSvc .GetByIdentifier (c .Request .Context (), project .ID , req .User )
815+ if err != nil {
816+ c .JSON (http .StatusNotFound , serializer .Err (http .StatusNotFound , "user not found in this project" , err ))
817+ return
818+ }
819+
810820 limit := req .Limit
811821 if limit == 0 {
812822 limit = 10
813823 }
814824
815- result , err := h .coreClient .SessionSearch (c .Request .Context (), req . UserID , req . ProjectID , req .Query , limit )
825+ result , err := h .coreClient .SessionSearch (c .Request .Context (), user . ID . String (), project . ID . String () , req .Query , limit )
816826 if err != nil {
817827 c .JSON (http .StatusInternalServerError , serializer .Err (http .StatusInternalServerError , "failed to search sessions" , err ))
818828 return
0 commit comments