Quick add task from the header (owner): modal, g t shortcut, auto_handle + Daisy webhook
Some checks failed
Deploy production / deploy (push) Has been cancelled

- + button next to Dashboard (desktop and mobile sheet), lazy-loaded native <dialog>
- POST /trackers/tasks/quick inserts source 'quick-add', notes, due date, priority
- tasks.tasks.auto_handle (default false) with a Daisy badge in the tracker
- DAISY_TASK_WEBHOOK_URL/KEY/HEADER: fire-and-forget POST {task_id, title}, 3 s timeout
This commit is contained in:
2026-10-24 16:13:44 +00:00
parent 3903317a59
commit 0aa14cebf3
9 changed files with 20152 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
// "Let Daisy handle it" on quick add: tell Daisy's routine about the new task.
// Configured in /etc/personal-website/prod.env:
// DAISY_TASK_WEBHOOK_URL where to POST {task_id, title}
// DAISY_TASK_WEBHOOK_KEY secret sent with it
// DAISY_TASK_WEBHOOK_HEADER header name (default Authorization, sent as "Bearer <key>";
// any other header gets the bare key)
// Unset URL or key: nothing is sent and the task is still saved.
export type DaisyHookConfig = { url: string; headers: Record<string, string> };
export function daisyHookConfig(env: Record<string, string | undefined> = process.env) {
const url = env.DAISY_TASK_WEBHOOK_URL?.trim();
const key = env.DAISY_TASK_WEBHOOK_KEY?.trim();
if (!url || !key) return null;
const header = env.DAISY_TASK_WEBHOOK_HEADER?.trim() || 'Authorization';
const value = header.toLowerCase() === 'authorization' ? `Bearer ${key}` : key;
return { url, headers: { 'content-type': 'application/json', [header]: value } };
}
/** Fire and forget: never awaited by the request, 3 s timeout, failures only logged. */
export function notifyDaisy(
task: { id: number; title: string },
config: DaisyHookConfig | null = daisyHookConfig(),
fetcher: typeof fetch = fetch
): 'sent' | 'not-configured' {
if (!config) return 'not-configured';
fetcher(config.url, {
method: 'POST',
headers: config.headers,
body: JSON.stringify({ task_id: task.id, title: task.title }),
signal: AbortSignal.timeout(3000)
})
.then((res) => {
if (!res.ok) console.error(`[daisy-hook] task ${task.id}: HTTP ${res.status}`);
})
.catch((err) => console.error(`[daisy-hook] task ${task.id}: ${String(err)}`));
return 'sent';
}