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

Method ResolveOutboundOwner

internal/identity/store.go:1960–1972  ·  view source on GitHub ↗

ResolveOutboundOwner looks up the user_id and agent_id for an outbound message without requiring the caller to know the user_id up-front. It exists for token-authenticated paths (magic-link approve/reject) where the HMAC token itself is the authorization and the handler just needs enough context to

(ctx context.Context, messageID string)

Source from the content-addressed store, hash-verified

1958// outbound. The returned user_id is guaranteed to own the message's
1959// agent (via the agent_identities.user_id join).
1960func (s *Store) ResolveOutboundOwner(ctx context.Context, messageID string) (userID, agentID string, err error) {
1961 err = s.pool.QueryRow(ctx,
1962 `SELECT a.user_id, m.agent_id
1963 FROM messages m
1964 JOIN agent_identities a ON a.id = m.agent_id
1965 WHERE m.id = $1 AND m.direction = 'outbound'`,
1966 messageID,
1967 ).Scan(&userID, &agentID)
1968 if err != nil {
1969 return "", "", ErrMessageNotFound
1970 }
1971 return userID, agentID, nil
1972}
1973
1974// ExpirationCandidate is the minimal row the expiration worker needs to
1975// decide how to finalize an expired pending message.

Callers 3

renderConfirmPageMethod · 0.80

Implementers 1

Storeinternal/identity/store.go

Calls 2

ScanMethod · 0.80
QueryRowMethod · 0.80

Tested by

no test coverage detected