From 9450dd34db7a0e360e665e9aee3b4e2ef04f6331 Mon Sep 17 00:00:00 2001 From: louispaulb Date: Fri, 22 May 2026 09:33:44 -0400 Subject: [PATCH] feat(campaigns): delete campaign from the list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DELETE /campaigns/:id removes the JSON from /opt/targo-hub/data/campaigns/. The Giftbit shortlinks already issued for that campaign live on Giftbit's side and are unaffected — this is purely about clearing internal tracking records (typically test runs cluttering the list). Refuses (409) while the send worker is active for that id so we never yank the file out from under saveCampaign(). Defensive id regex (in campaignPath) blocks path-traversal attempts before unlink runs. UI: red trash icon on each row, disabled while status=sending. Confirmation dialog spells out what survives the deletion (Giftbit links) vs what's lost (tracking, opens/clicks, CSV report) so the operator isn't surprised. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 --- apps/ops/src/api/campaigns.js | 8 +++++ .../campaigns/pages/CampaignsListPage.vue | 36 +++++++++++++++++-- services/targo-hub/lib/campaigns.js | 24 +++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/apps/ops/src/api/campaigns.js b/apps/ops/src/api/campaigns.js index d4ae901..b7c2d08 100644 --- a/apps/ops/src/api/campaigns.js +++ b/apps/ops/src/api/campaigns.js @@ -69,6 +69,14 @@ export function sendCampaign (id) { }) } +// Permanent deletion — removes the JSON on the hub. Used for clearing +// test campaigns from the list. Giftbit shortlinks are unaffected. +export function deleteCampaign (id) { + return hubFetch(`/campaigns/${encodeURIComponent(id)}`, { + method: 'DELETE', + }) +} + // Build the URL the browser hits to download the per-recipient CSV report // (giftbit shortlink ↔ email ↔ name ↔ status). The hub serves it with the // proper Content-Disposition so an click triggers a save. diff --git a/apps/ops/src/modules/campaigns/pages/CampaignsListPage.vue b/apps/ops/src/modules/campaigns/pages/CampaignsListPage.vue index bee226a..2d0f5b1 100644 --- a/apps/ops/src/modules/campaigns/pages/CampaignsListPage.vue +++ b/apps/ops/src/modules/campaigns/pages/CampaignsListPage.vue @@ -49,7 +49,14 @@ @@ -58,8 +65,10 @@