feat(flight-finder): implement milestone M2 - report workflow and delivery gates
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { isPlausibleEmail } from "./input-validation.js";
|
||||
|
||||
type DeliveryPlanInput = {
|
||||
recipientEmail?: string | null;
|
||||
subject: string;
|
||||
body: string;
|
||||
attachmentPath: string;
|
||||
};
|
||||
|
||||
export type DeliveryPlan = {
|
||||
ready: boolean;
|
||||
needsRecipientEmail: boolean;
|
||||
command: string | null;
|
||||
sender: "luke@fiorinis.com";
|
||||
recipientEmail: string | null;
|
||||
};
|
||||
|
||||
function shellQuote(value: string): string {
|
||||
return `'${value.replace(/'/g, `'\"'\"'`)}'`;
|
||||
}
|
||||
|
||||
export function buildLukeDeliveryPlan(input: DeliveryPlanInput): DeliveryPlan {
|
||||
const recipientEmail = input.recipientEmail?.trim() || null;
|
||||
if (!recipientEmail || !isPlausibleEmail(recipientEmail)) {
|
||||
return {
|
||||
ready: false,
|
||||
needsRecipientEmail: true,
|
||||
command: null,
|
||||
sender: "luke@fiorinis.com",
|
||||
recipientEmail
|
||||
};
|
||||
}
|
||||
|
||||
const validRecipientEmail: string = recipientEmail;
|
||||
const command = [
|
||||
"zsh ~/.openclaw/workspace/bin/gog-luke gmail send",
|
||||
`--to ${shellQuote(validRecipientEmail)}`,
|
||||
`--subject ${shellQuote(input.subject)}`,
|
||||
`--body ${shellQuote(input.body)}`,
|
||||
`--attach ${shellQuote(input.attachmentPath)}`
|
||||
].join(" ");
|
||||
|
||||
return {
|
||||
ready: true,
|
||||
needsRecipientEmail: false,
|
||||
command,
|
||||
sender: "luke@fiorinis.com",
|
||||
recipientEmail: validRecipientEmail
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user