attachReferencesChain rebuilds the References chain on a HITL-approved SendRequest by looking up the parent inbound's raw message via email_message_id. Required because the pending-outbound row only persists the parent's Message-ID, not its raw message — without re-deriving here, HITL-protected repl
(ctx context.Context, store hitlInboundLookup, agentID string, req *outbound.SendRequest)
| 154 | // than refusing the send. Callers must keep ReplyToMessageID populated |
| 155 | // regardless; only References is filled in here. |
| 156 | func attachReferencesChain(ctx context.Context, store hitlInboundLookup, agentID string, req *outbound.SendRequest) { |
| 157 | if req.ReplyToMessageID == "" { |
| 158 | return |
| 159 | } |
| 160 | inbound, err := store.GetInboundByEmailMessageID(ctx, agentID, req.ReplyToMessageID) |
| 161 | if err != nil || inbound == nil { |
| 162 | return |
| 163 | } |
| 164 | req.References = outbound.BuildReferencesChain(inbound.RawMessage, req.ReplyToMessageID) |
| 165 | } |
| 166 | |
| 167 | // hitlInboundLookup is the narrow store contract attachReferencesChain |
| 168 | // needs. Defined as an interface so tests can stub it without spinning |