mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:41:37 +00:00
refactor(cli): share gmail webhook option parsing
This commit is contained in:
@@ -110,32 +110,54 @@ function parseGmailSetupOptions(raw: Record<string, unknown>): GmailSetupOptions
|
|||||||
if (!account) {
|
if (!account) {
|
||||||
throw new Error("--account is required");
|
throw new Error("--account is required");
|
||||||
}
|
}
|
||||||
|
const common = parseGmailCommonOptions(raw);
|
||||||
return {
|
return {
|
||||||
account,
|
account,
|
||||||
project: stringOption(raw.project),
|
project: stringOption(raw.project),
|
||||||
topic: stringOption(raw.topic),
|
topic: common.topic,
|
||||||
subscription: stringOption(raw.subscription),
|
subscription: common.subscription,
|
||||||
label: stringOption(raw.label),
|
label: common.label,
|
||||||
hookUrl: stringOption(raw.hookUrl),
|
hookUrl: common.hookUrl,
|
||||||
hookToken: stringOption(raw.hookToken),
|
hookToken: common.hookToken,
|
||||||
pushToken: stringOption(raw.pushToken),
|
pushToken: common.pushToken,
|
||||||
bind: stringOption(raw.bind),
|
bind: common.bind,
|
||||||
port: numberOption(raw.port),
|
port: common.port,
|
||||||
path: stringOption(raw.path),
|
path: common.path,
|
||||||
includeBody: booleanOption(raw.includeBody),
|
includeBody: common.includeBody,
|
||||||
maxBytes: numberOption(raw.maxBytes),
|
maxBytes: common.maxBytes,
|
||||||
renewEveryMinutes: numberOption(raw.renewMinutes),
|
renewEveryMinutes: common.renewEveryMinutes,
|
||||||
tailscale: stringOption(raw.tailscale) as GmailSetupOptions["tailscale"],
|
tailscale: common.tailscaleRaw as GmailSetupOptions["tailscale"],
|
||||||
tailscalePath: stringOption(raw.tailscalePath),
|
tailscalePath: common.tailscalePath,
|
||||||
tailscaleTarget: stringOption(raw.tailscaleTarget),
|
tailscaleTarget: common.tailscaleTarget,
|
||||||
pushEndpoint: stringOption(raw.pushEndpoint),
|
pushEndpoint: stringOption(raw.pushEndpoint),
|
||||||
json: Boolean(raw.json),
|
json: Boolean(raw.json),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseGmailRunOptions(raw: Record<string, unknown>): GmailRunOptions {
|
function parseGmailRunOptions(raw: Record<string, unknown>): GmailRunOptions {
|
||||||
|
const common = parseGmailCommonOptions(raw);
|
||||||
return {
|
return {
|
||||||
account: stringOption(raw.account),
|
account: stringOption(raw.account),
|
||||||
|
topic: common.topic,
|
||||||
|
subscription: common.subscription,
|
||||||
|
label: common.label,
|
||||||
|
hookUrl: common.hookUrl,
|
||||||
|
hookToken: common.hookToken,
|
||||||
|
pushToken: common.pushToken,
|
||||||
|
bind: common.bind,
|
||||||
|
port: common.port,
|
||||||
|
path: common.path,
|
||||||
|
includeBody: common.includeBody,
|
||||||
|
maxBytes: common.maxBytes,
|
||||||
|
renewEveryMinutes: common.renewEveryMinutes,
|
||||||
|
tailscale: common.tailscaleRaw as GmailRunOptions["tailscale"],
|
||||||
|
tailscalePath: common.tailscalePath,
|
||||||
|
tailscaleTarget: common.tailscaleTarget,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseGmailCommonOptions(raw: Record<string, unknown>) {
|
||||||
|
return {
|
||||||
topic: stringOption(raw.topic),
|
topic: stringOption(raw.topic),
|
||||||
subscription: stringOption(raw.subscription),
|
subscription: stringOption(raw.subscription),
|
||||||
label: stringOption(raw.label),
|
label: stringOption(raw.label),
|
||||||
@@ -148,7 +170,7 @@ function parseGmailRunOptions(raw: Record<string, unknown>): GmailRunOptions {
|
|||||||
includeBody: booleanOption(raw.includeBody),
|
includeBody: booleanOption(raw.includeBody),
|
||||||
maxBytes: numberOption(raw.maxBytes),
|
maxBytes: numberOption(raw.maxBytes),
|
||||||
renewEveryMinutes: numberOption(raw.renewMinutes),
|
renewEveryMinutes: numberOption(raw.renewMinutes),
|
||||||
tailscale: stringOption(raw.tailscale) as GmailRunOptions["tailscale"],
|
tailscaleRaw: stringOption(raw.tailscale),
|
||||||
tailscalePath: stringOption(raw.tailscalePath),
|
tailscalePath: stringOption(raw.tailscalePath),
|
||||||
tailscaleTarget: stringOption(raw.tailscaleTarget),
|
tailscaleTarget: stringOption(raw.tailscaleTarget),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user