From 61263178c349ef417d8f5d68bc1344e624361717 Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 3 Nov 2023 16:18:20 +0100 Subject: [PATCH] Fix 500 error on API DELETE endpoints --- CHANGELOG.md | 4 ++++ lib/keila_web/api/controllers/api_campaign_controller.ex | 2 +- lib/keila_web/api/controllers/api_contact_controller.ex | 2 +- lib/keila_web/api/controllers/api_segment_controller.ex | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be4abaf8..b69023f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixed +- API DELETE endpoints for campaigns, contacts, segments now return the + correct 204 response + ## Version 0.12.8 diff --git a/lib/keila_web/api/controllers/api_campaign_controller.ex b/lib/keila_web/api/controllers/api_campaign_controller.ex index b584b848..14d9ff1f 100644 --- a/lib/keila_web/api/controllers/api_campaign_controller.ex +++ b/lib/keila_web/api/controllers/api_campaign_controller.ex @@ -104,7 +104,7 @@ defmodule KeilaWeb.ApiCampaignController do Mailings.delete_project_campaigns(project_id(conn), [id]) conn - |> put_status(204) + |> send_resp(:no_content, "") end operation(:deliver, diff --git a/lib/keila_web/api/controllers/api_contact_controller.ex b/lib/keila_web/api/controllers/api_contact_controller.ex index 8ba601aa..6e77c2a2 100644 --- a/lib/keila_web/api/controllers/api_contact_controller.ex +++ b/lib/keila_web/api/controllers/api_contact_controller.ex @@ -129,7 +129,7 @@ defmodule KeilaWeb.ApiContactController do Contacts.delete_project_contacts(project_id(conn), filter: %{"id" => id}) conn - |> put_status(204) + |> send_resp(:no_content, "") end defp project_id(conn), do: conn.assigns.current_project.id diff --git a/lib/keila_web/api/controllers/api_segment_controller.ex b/lib/keila_web/api/controllers/api_segment_controller.ex index 50bd5dea..ef2f02f6 100644 --- a/lib/keila_web/api/controllers/api_segment_controller.ex +++ b/lib/keila_web/api/controllers/api_segment_controller.ex @@ -98,7 +98,7 @@ defmodule KeilaWeb.ApiSegmentController do Contacts.delete_project_segments(project_id(conn), [id]) conn - |> put_status(204) + |> send_resp(:no_content, "") end defp project_id(conn), do: conn.assigns.current_project.id