mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
refactor(portal): remove soft delete elements from portal code (#10607)
Why: * In previous commits, the portal code had been updated to use hard deletion rather than soft deletion of data. The fields used in the soft deletion were still kept in the DB and the code to allow for zero downtime rollout and an easy rollback if necessary. To continue with that work the portal code has now been updated to remove any reference to the soft deleted fields (e.g. deleted_at, persistent_id, etc...). While the code has been updated the actual data in the DB will need to remain for now, to once again allow for a zero downtime rollout. Once this commit has been deployed to production another PR can follow to remove the columns from the necessary tables in the DB. Related: #8187
This commit is contained in:
@@ -65,7 +65,7 @@ defmodule API.ActorGroupMembershipController do
|
||||
) do
|
||||
subject = conn.assigns.subject
|
||||
preload = [:memberships]
|
||||
filter = [deleted?: false, editable?: true]
|
||||
filter = [editable?: true]
|
||||
|
||||
with {:ok, group} <-
|
||||
Actors.fetch_group_by_id(actor_group_id, subject, preload: preload, filter: filter),
|
||||
@@ -105,7 +105,7 @@ defmodule API.ActorGroupMembershipController do
|
||||
remove = Map.get(params, "remove", [])
|
||||
subject = conn.assigns.subject
|
||||
preload = [:memberships]
|
||||
filter = [deleted?: false, editable?: true]
|
||||
filter = [editable?: true]
|
||||
|
||||
with {:ok, group} <-
|
||||
Actors.fetch_group_by_id(actor_group_id, subject, preload: preload, filter: filter),
|
||||
|
||||
@@ -43,7 +43,7 @@ defmodule API.PolicyController do
|
||||
|
||||
# Show a specific Policy
|
||||
def show(conn, %{"id" => id}) do
|
||||
with {:ok, policy} <- Policies.fetch_policy_by_id_or_persistent_id(id, conn.assigns.subject) do
|
||||
with {:ok, policy} <- Policies.fetch_policy_by_id(id, conn.assigns.subject) do
|
||||
render(conn, :show, policy: policy)
|
||||
end
|
||||
end
|
||||
@@ -91,7 +91,7 @@ defmodule API.PolicyController do
|
||||
def update(conn, %{"id" => id, "policy" => params}) do
|
||||
subject = conn.assigns.subject
|
||||
|
||||
with {:ok, policy} <- Policies.fetch_policy_by_id_or_persistent_id(id, subject) do
|
||||
with {:ok, policy} <- Policies.fetch_policy_by_id(id, subject) do
|
||||
case Policies.update_policy(policy, params, subject) do
|
||||
{:ok, policy} ->
|
||||
render(conn, :show, policy: policy)
|
||||
@@ -124,7 +124,7 @@ defmodule API.PolicyController do
|
||||
def delete(conn, %{"id" => id}) do
|
||||
subject = conn.assigns.subject
|
||||
|
||||
with {:ok, policy} <- Policies.fetch_policy_by_id_or_persistent_id(id, subject),
|
||||
with {:ok, policy} <- Policies.fetch_policy_by_id(id, subject),
|
||||
{:ok, policy} <- Policies.delete_policy(policy, subject) do
|
||||
render(conn, :show, policy: policy)
|
||||
end
|
||||
|
||||
@@ -43,7 +43,7 @@ defmodule API.ResourceController do
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
||||
with {:ok, resource} <-
|
||||
Resources.fetch_resource_by_id_or_persistent_id(id, conn.assigns.subject) do
|
||||
Resources.fetch_resource_by_id(id, conn.assigns.subject) do
|
||||
render(conn, :show, resource: resource)
|
||||
end
|
||||
end
|
||||
@@ -92,7 +92,7 @@ defmodule API.ResourceController do
|
||||
subject = conn.assigns.subject
|
||||
attrs = set_param_defaults(params)
|
||||
|
||||
with {:ok, resource} <- Resources.fetch_active_resource_by_id_or_persistent_id(id, subject) do
|
||||
with {:ok, resource} <- Resources.fetch_resource_by_id(id, subject) do
|
||||
case Resources.update_resource(resource, attrs, subject) do
|
||||
{:ok, updated_resource} ->
|
||||
render(conn, :show, resource: updated_resource)
|
||||
@@ -124,7 +124,7 @@ defmodule API.ResourceController do
|
||||
def delete(conn, %{"id" => id}) do
|
||||
subject = conn.assigns.subject
|
||||
|
||||
with {:ok, resource} <- Resources.fetch_resource_by_id_or_persistent_id(id, subject),
|
||||
with {:ok, resource} <- Resources.fetch_resource_by_id(id, subject),
|
||||
{:ok, resource} <- Resources.delete_resource(resource, subject) do
|
||||
render(conn, :show, resource: resource)
|
||||
end
|
||||
|
||||
@@ -102,8 +102,9 @@ defmodule API.Gateway.ChannelTest do
|
||||
capture_log(fn ->
|
||||
send(socket.channel_pid, %Changes.Change{lsn: 50})
|
||||
|
||||
# Wait for the channel to process and emit the log
|
||||
Process.sleep(1)
|
||||
# Force the channel to process the message before continuing
|
||||
# :sys.get_state/1 is synchronous and will wait for all pending messages to be handled
|
||||
:sys.get_state(socket.channel_pid)
|
||||
end)
|
||||
|
||||
assert message =~ "[warning] Out of order or duplicate change received; ignoring"
|
||||
|
||||
@@ -60,7 +60,8 @@ defmodule API.Relay.ChannelTest do
|
||||
describe "handle_in/3 for unknown messages" do
|
||||
test "it doesn't crash", %{socket: socket} do
|
||||
ref = push(socket, "unknown_message", %{})
|
||||
assert_reply ref, :error, %{reason: :unknown_message}
|
||||
|
||||
assert_reply ref, :error, %{reason: :unknown_message}, 1000
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user