feat(hooks): allow gmail tailscale target URLs
This commit is contained in:
@@ -60,6 +60,7 @@ export type GmailSetupOptions = {
|
||||
renewEveryMinutes?: number;
|
||||
tailscale?: "off" | "serve" | "funnel";
|
||||
tailscalePath?: string;
|
||||
tailscaleTarget?: string;
|
||||
pushEndpoint?: string;
|
||||
json?: boolean;
|
||||
};
|
||||
@@ -80,6 +81,7 @@ export type GmailRunOptions = {
|
||||
renewEveryMinutes?: number;
|
||||
tailscale?: "off" | "serve" | "funnel";
|
||||
tailscalePath?: string;
|
||||
tailscaleTarget?: string;
|
||||
};
|
||||
|
||||
const DEFAULT_GMAIL_TOPIC_IAM_MEMBER =
|
||||
@@ -134,11 +136,18 @@ export async function runGmailSetup(opts: GmailSetupOptions) {
|
||||
const serveBind = opts.bind ?? DEFAULT_GMAIL_SERVE_BIND;
|
||||
const servePort = opts.port ?? DEFAULT_GMAIL_SERVE_PORT;
|
||||
const configuredServePath = opts.path ?? baseConfig.hooks?.gmail?.serve?.path;
|
||||
const configuredTailscaleTarget =
|
||||
opts.tailscaleTarget ?? baseConfig.hooks?.gmail?.tailscale?.target;
|
||||
const normalizedServePath =
|
||||
typeof configuredServePath === "string" &&
|
||||
configuredServePath.trim().length > 0
|
||||
? normalizeServePath(configuredServePath)
|
||||
: DEFAULT_GMAIL_SERVE_PATH;
|
||||
const normalizedTailscaleTarget =
|
||||
typeof configuredTailscaleTarget === "string" &&
|
||||
configuredTailscaleTarget.trim().length > 0
|
||||
? configuredTailscaleTarget.trim()
|
||||
: undefined;
|
||||
|
||||
const includeBody = opts.includeBody ?? true;
|
||||
const maxBytes = opts.maxBytes ?? DEFAULT_GMAIL_MAX_BYTES;
|
||||
@@ -149,7 +158,9 @@ export async function runGmailSetup(opts: GmailSetupOptions) {
|
||||
// Tailscale strips the path before proxying; keep a public path while gog
|
||||
// listens on "/" whenever Tailscale is enabled.
|
||||
const servePath = normalizeServePath(
|
||||
tailscaleMode !== "off" ? "/" : normalizedServePath,
|
||||
tailscaleMode !== "off" && !normalizedTailscaleTarget
|
||||
? "/"
|
||||
: normalizedServePath,
|
||||
);
|
||||
const tailscalePath = normalizeServePath(
|
||||
opts.tailscalePath ??
|
||||
@@ -189,6 +200,7 @@ export async function runGmailSetup(opts: GmailSetupOptions) {
|
||||
mode: tailscaleMode,
|
||||
path: tailscalePath,
|
||||
port: servePort,
|
||||
target: normalizedTailscaleTarget,
|
||||
token: pushToken,
|
||||
});
|
||||
|
||||
@@ -236,6 +248,7 @@ export async function runGmailSetup(opts: GmailSetupOptions) {
|
||||
...baseConfig.hooks?.gmail?.tailscale,
|
||||
mode: tailscaleMode,
|
||||
path: tailscalePath,
|
||||
target: normalizedTailscaleTarget,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -299,6 +312,7 @@ export async function runGmailService(opts: GmailRunOptions) {
|
||||
renewEveryMinutes: opts.renewEveryMinutes,
|
||||
tailscaleMode: opts.tailscale,
|
||||
tailscalePath: opts.tailscalePath,
|
||||
tailscaleTarget: opts.tailscaleTarget,
|
||||
};
|
||||
|
||||
const resolved = resolveGmailHookRuntimeConfig(config, overrides);
|
||||
@@ -314,6 +328,7 @@ export async function runGmailService(opts: GmailRunOptions) {
|
||||
mode: runtimeConfig.tailscale.mode,
|
||||
path: runtimeConfig.tailscale.path,
|
||||
port: runtimeConfig.serve.port,
|
||||
target: runtimeConfig.tailscale.target,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user