MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / HandleAgentActivity

Method HandleAgentActivity

internal/auth/auth.go:707–746  ·  view source on GitHub ↗

HandleAgentActivity returns recent message activity for an agent owned by the authenticated user.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

705
706// HandleAgentActivity returns recent message activity for an agent owned by the authenticated user.
707func (ua *UserAuth) HandleAgentActivity(w http.ResponseWriter, r *http.Request) {
708 user := ua.AuthenticateRequest(r)
709 if user == nil {
710 http.Error(w, "not authenticated", http.StatusUnauthorized)
711 return
712 }
713
714 // Extract agent email from URL path: /api/dashboard/agents/{email}/activity
715 path := strings.TrimPrefix(r.URL.Path, "/api/dashboard/agents/")
716 email, _ := url.PathUnescape(strings.TrimSuffix(path, "/activity"))
717 email = identity.NormalizeEmail(email)
718 if email == "" {
719 http.Error(w, "agent email required", http.StatusBadRequest)
720 return
721 }
722
723 agent, err := ua.store.GetAgentByEmail(r.Context(), email)
724 if err != nil {
725 http.Error(w, "agent not found", http.StatusNotFound)
726 return
727 }
728
729 if agent.UserID != user.ID {
730 http.Error(w, "agent not found", http.StatusNotFound)
731 return
732 }
733
734 activity, err := ua.store.ListActivityByAgent(r.Context(), agent.ID, 50)
735 if err != nil {
736 http.Error(w, "failed to list activity", http.StatusInternalServerError)
737 return
738 }
739
740 if activity == nil {
741 activity = []identity.Message{}
742 }
743
744 w.Header().Set("Content-Type", "application/json")
745 writeJSON(w, activity)
746}
747
748// HandleCreateAPIKey creates a new API key for the authenticated user.
749func (ua *UserAuth) HandleCreateAPIKey(w http.ResponseWriter, r *http.Request) {

Calls 6

AuthenticateRequestMethod · 0.95
NormalizeEmailFunction · 0.92
ListActivityByAgentMethod · 0.80
writeJSONFunction · 0.70
GetAgentByEmailMethod · 0.65
ErrorMethod · 0.45