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)
| 1958 | // outbound. The returned user_id is guaranteed to own the message's |
| 1959 | // agent (via the agent_identities.user_id join). |
| 1960 | func (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. |
no test coverage detected