mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
2fa853dce5
Merged via squash.
Prepared head SHA: 61502846df
Co-authored-by: samzong <13782141+samzong@users.noreply.github.com>
Co-authored-by: frankekn <4488090+frankekn@users.noreply.github.com>
Reviewed-by: @frankekn
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
import { isTruthyEnvValue } from "../infra/env.js";
|
|
import { startGmailWatcher } from "./gmail-watcher.js";
|
|
|
|
export type GMailWatcherLog = {
|
|
info: (msg: string) => void;
|
|
warn: (msg: string) => void;
|
|
error: (msg: string) => void;
|
|
};
|
|
|
|
export async function startGmailWatcherWithLogs(params: {
|
|
cfg: OpenClawConfig;
|
|
log: GMailWatcherLog;
|
|
onSkipped?: () => void;
|
|
isCancelled?: () => boolean;
|
|
signal?: AbortSignal;
|
|
}) {
|
|
if (isTruthyEnvValue(process.env.OPENCLAW_SKIP_GMAIL_WATCHER)) {
|
|
params.onSkipped?.();
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const gmailResult = await startGmailWatcher(params.cfg, {
|
|
isCancelled: params.isCancelled,
|
|
signal: params.signal,
|
|
});
|
|
if (gmailResult.started) {
|
|
params.log.info("gmail watcher started");
|
|
return;
|
|
}
|
|
if (
|
|
gmailResult.reason &&
|
|
gmailResult.reason !== "hooks not enabled" &&
|
|
gmailResult.reason !== "no gmail account configured"
|
|
) {
|
|
params.log.warn(`gmail watcher not started: ${gmailResult.reason}`);
|
|
}
|
|
} catch (err) {
|
|
params.log.error(`gmail watcher failed to start: ${String(err)}`);
|
|
}
|
|
}
|