From 437650d5e2c376b7e4254265c022fff67bbafb6f Mon Sep 17 00:00:00 2001 From: SimpleTest Date: Tue, 21 Jul 2026 22:05:28 +0300 Subject: [PATCH] fix: clarify blocked request conversations --- .../live/request_live/show.ex | 25 ++++++++++++++++++- .../live/mutual_aid_live_test.exs | 25 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/lib/who_need_help_web/live/request_live/show.ex b/lib/who_need_help_web/live/request_live/show.ex index ef5667e..fbf5aae 100644 --- a/lib/who_need_help_web/live/request_live/show.ex +++ b/lib/who_need_help_web/live/request_live/show.ex @@ -294,6 +294,7 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do socket |> maybe_untrack_browser_presence() |> assign(:blocked_by_current, true) + |> assign(:interaction_blocked, true) |> assign(:messages, []) |> assign(:messages_cursor, nil) |> assign(:positions, %{}) @@ -316,9 +317,17 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do def handle_event("unblock-user", _, socket) do case Trust.unblock(socket.assigns.current_scope, socket.assigns.other_user_id) do {:ok, _result} -> + interaction_blocked = + socket.assigns.other_user_id && + Trust.blocked_between?( + socket.assigns.current_scope.user.id, + socket.assigns.other_user_id + ) + {:noreply, socket |> assign(:blocked_by_current, false) + |> assign(:interaction_blocked, interaction_blocked) |> put_flash(:info, gettext("User unblocked."))} {:error, reason} -> @@ -432,6 +441,10 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do :blocked_by_current, other_user_id && Trust.blocked_by?(current_user_id, other_user_id) ) + |> assign( + :interaction_blocked, + other_user_id && Trust.blocked_between?(current_user_id, other_user_id) + ) |> assign(:messages, messages_page.entries) |> assign(:messages_cursor, messages_page.next_cursor) |> assign(:message_window_limit, max(length(messages_page.entries), @initial_message_window)) @@ -772,7 +785,16 @@ defmodule WhoNeedHelpWeb.RequestLive.Show do > {gettext("Load earlier messages")} -

+

+ {gettext("This interaction is blocked.")} +

+

{gettext("No messages yet.")}

<.form + :if={!@interaction_blocked} id="message-form" for={@message_form} phx-submit="send-message" diff --git a/test/who_need_help_web/live/mutual_aid_live_test.exs b/test/who_need_help_web/live/mutual_aid_live_test.exs index 25b2fe3..9d7faca 100644 --- a/test/who_need_help_web/live/mutual_aid_live_test.exs +++ b/test/who_need_help_web/live/mutual_aid_live_test.exs @@ -515,6 +515,31 @@ defmodule WhoNeedHelpWeb.MutualAidLiveTest do stop_live_view(helper_view) end + test "request chat clearly disables interaction when the other participant blocks the user", %{ + conn: requester_conn, + scope: requester_scope + } do + category = Catalog.seed_defaults() + helper = user_fixture(display_name: "Blocking helper") + + {:ok, request} = Help.create_request(requester_scope, request_attrs(category)) + {:ok, assignment} = Help.accept_request(user_scope_fixture(helper), request.id) + + {:ok, _message} = + Messaging.send_message(user_scope_fixture(helper), assignment, %{ + "body" => "This message is hidden after blocking." + }) + + {:ok, _block} = Trust.block(user_scope_fixture(helper), requester_scope.user.id) + + {:ok, view, html} = live(requester_conn, ~p"/requests/#{request.id}") + + assert html =~ "This interaction is blocked." + refute html =~ "No messages yet." + refute html =~ "This message is hidden after blocking." + refute has_element?(view, "#message-form") + end + test "terminal request updates stop Android foreground tracking", _context do category = Catalog.seed_defaults() requester = user_fixture(display_name: "Tracking requester")