fix(hooks): exclude outbound Gmail labels (#56720)

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
Lidang Jiang
2026-07-29 17:16:31 +08:00
committed by GitHub
parent e8524a5839
commit 8acadc6990
2 changed files with 10 additions and 0 deletions
+7
View File
@@ -3,6 +3,7 @@ import { describe, expect, it } from "vitest";
import { type OpenClawConfig, DEFAULT_GATEWAY_PORT } from "../config/config.js";
import {
buildDefaultHookUrl,
buildGogWatchServeArgs,
buildGogWatchServeLogArgs,
buildTopicPath,
parseTopicPath,
@@ -88,6 +89,10 @@ describe("gmail hook config", () => {
return;
}
const serveArgs = buildGogWatchServeArgs(result.value);
expect(serveArgs).toContain("--exclude-labels");
expect(serveArgs[serveArgs.indexOf("--exclude-labels") + 1]).toBe("SPAM,TRASH,DRAFT,SENT");
const args = buildGogWatchServeLogArgs(result.value);
expect(args).not.toContain("push-token");
expect(args).not.toContain("hook-token");
@@ -107,6 +112,8 @@ describe("gmail hook config", () => {
"--path",
"/gmail-pubsub",
"--include-body",
"--exclude-labels",
"SPAM,TRASH,DRAFT,SENT",
"--max-bytes",
"20000",
]);
+3
View File
@@ -23,6 +23,8 @@ export const DEFAULT_GMAIL_SERVE_PATH = "/gmail-pubsub";
export const DEFAULT_GMAIL_MAX_BYTES = 20_000;
export const DEFAULT_GMAIL_RENEW_MINUTES = 12 * 60;
const DEFAULT_HOOKS_PATH = "/hooks";
// OpenClaw handles inbound mail; override gog's narrower SPAM,TRASH default.
const GMAIL_WATCH_EXCLUDED_LABELS = "SPAM,TRASH,DRAFT,SENT";
const GMAIL_WATCH_SENSITIVE_FLAGS = new Set(["--token", "--hook-url", "--hook-token"]);
let gogBin: string | undefined;
@@ -254,6 +256,7 @@ export function buildGogWatchServeArgs(cfg: GmailHookRuntimeConfig): string[] {
if (cfg.includeBody) {
args.push("--include-body");
}
args.push("--exclude-labels", GMAIL_WATCH_EXCLUDED_LABELS);
if (cfg.maxBytes > 0) {
args.push("--max-bytes", String(cfg.maxBytes));
}