aboutsummaryrefslogtreecommitdiff
path: root/src/types
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-12-15 20:17:22 -0800
committerElizabeth Hunt <me@liz.coffee>2025-12-15 20:19:43 -0800
commit2814d5520623efe5f48c26f639d3ed6cc5f0d8d2 (patch)
tree3fc1af65dac5ed55aceaab7574b22fea32cad86a /src/types
parent2e41f030f02a336c2e9866d3d56b0494da5a622e (diff)
downloadposthook-2814d5520623efe5f48c26f639d3ed6cc5f0d8d2.tar.gz
posthook-2814d5520623efe5f48c26f639d3ed6cc5f0d8d2.zip
Add email integration
Diffstat (limited to 'src/types')
-rw-r--r--src/types/index.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/types/index.ts b/src/types/index.ts
index 5e0b2d4..89a2a6c 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -12,12 +12,27 @@ export interface NtfyConfig {
topic?: string;
}
+export interface EmailConfig {
+ enabled: boolean;
+ to?: string;
+ from?: string;
+ host?: string;
+ port?: number;
+ secure?: boolean;
+ username?: string;
+ password?: string;
+ subject?: string;
+ includeBody?: boolean;
+ includeHeaders?: boolean;
+}
+
export interface RouteConfig {
name: string;
contentType: ContentType;
hcaptchaProtected: boolean;
hcaptchaSecret?: string;
ntfy?: NtfyConfig;
+ email?: EmailConfig;
requireToken?: boolean;
}
@@ -71,6 +86,24 @@ export function isRouteConfig(obj: unknown): obj is RouteConfig {
}
}
+ // Validate email config if present
+ if (r.email !== undefined) {
+ if (typeof r.email !== 'object' || r.email === null) return false;
+ const email = r.email as Record<string, unknown>;
+ if (typeof email.enabled !== 'boolean') return false;
+ if (email.enabled && (typeof email.to !== 'string' || typeof email.from !== 'string')) {
+ return false;
+ }
+ if (email.host !== undefined && typeof email.host !== 'string') return false;
+ if (email.port !== undefined && typeof email.port !== 'number') return false;
+ if (email.secure !== undefined && typeof email.secure !== 'boolean') return false;
+ if (email.username !== undefined && typeof email.username !== 'string') return false;
+ if (email.password !== undefined && typeof email.password !== 'string') return false;
+ if (email.subject !== undefined && typeof email.subject !== 'string') return false;
+ if (email.includeBody !== undefined && typeof email.includeBody !== 'boolean') return false;
+ if (email.includeHeaders !== undefined && typeof email.includeHeaders !== 'boolean') return false;
+ }
+
// Validate requireToken if present
if (r.requireToken !== undefined && typeof r.requireToken !== 'boolean') {
return false;