feat: wire external rules pipeline into ingress and dispatch
- Add DispatchContext field to Task model for rule metadata storage - Add BlocklistEmails config (BLOCKLIST_EMAILS env var) - Wire rules.Pipeline into IMAPWatcher, replacing inline whitelist check - Pass rule metadata through DispatchContext to OpenClaw dispatch - Remove isWhitelisted method (now handled by WhitelistRule) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -73,7 +73,7 @@ func (d *Dispatcher) Dispatch(task *database.Task) {
|
||||
SessionID: task.ThreadID,
|
||||
History: history,
|
||||
CallbackURL: callbackURL,
|
||||
Metadata: map[string]string{"task_uuid": task.TaskUUID},
|
||||
Metadata: buildDispatchMetadata(task),
|
||||
}
|
||||
|
||||
// Update status to AI_PROCESSING before first attempt.
|
||||
@@ -195,3 +195,18 @@ func (d *Dispatcher) buildHistory(threadID string) ([]historyEntry, error) {
|
||||
|
||||
return history, nil
|
||||
}
|
||||
|
||||
// buildDispatchMetadata constructs the metadata map for OpenClaw dispatch,
|
||||
// merging the task UUID with any DispatchContext from the rules pipeline.
|
||||
func buildDispatchMetadata(task *database.Task) map[string]string {
|
||||
metadata := map[string]string{"task_uuid": task.TaskUUID}
|
||||
if task.DispatchContext != "" {
|
||||
var ctx map[string]string
|
||||
if err := json.Unmarshal([]byte(task.DispatchContext), &ctx); err == nil {
|
||||
for k, v := range ctx {
|
||||
metadata[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
return metadata
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user