From 489787ceb57a39b9e804228a9d02b6fc868c0779 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 16 Apr 2021 18:36:52 +0200 Subject: [PATCH 1/3] Avoid showing suspended broken UI for suspended/deleted groups Don't return them if they're suspended Closes #655 Signed-off-by: Thomas Citharel --- lib/graphql/resolvers/group.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/graphql/resolvers/group.ex b/lib/graphql/resolvers/group.ex index fca02e768..c31892ca7 100644 --- a/lib/graphql/resolvers/group.ex +++ b/lib/graphql/resolvers/group.ex @@ -26,7 +26,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Group do } } ) do - with {:group, {:ok, %Actor{id: group_id} = group}} <- + with {:group, {:ok, %Actor{id: group_id, suspended: false} = group}} <- {:group, ActivityPub.find_or_make_group_from_nickname(name)}, {:actor, %Actor{id: actor_id} = _actor} <- {:actor, Users.get_actor_for_user(user)}, {:member, true} <- {:member, Actors.is_member?(actor_id, group_id)} do @@ -44,7 +44,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Group do end def find_group(_parent, %{preferred_username: name}, _resolution) do - with {:ok, actor} <- ActivityPub.find_or_make_group_from_nickname(name), + with {:ok, %Actor{suspended: false} = actor} <- + ActivityPub.find_or_make_group_from_nickname(name), %Actor{} = actor <- restrict_fields_for_non_member_request(actor) do {:ok, actor} else From 014c2da915653a64db40e529858279aca902ab61 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 19 Apr 2021 09:53:36 +0200 Subject: [PATCH 2/3] Improve wording when editing an user through CLI Signed-off-by: Thomas Citharel --- lib/mix/tasks/mobilizon/users/modify.ex | 6 +++++- lib/mix/tasks/mobilizon/users/show.ex | 7 +++++-- test/tasks/users_test.exs | 22 +++++++++------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/mix/tasks/mobilizon/users/modify.ex b/lib/mix/tasks/mobilizon/users/modify.ex index dd8a4181c..e210e5742 100644 --- a/lib/mix/tasks/mobilizon/users/modify.ex +++ b/lib/mix/tasks/mobilizon/users/modify.ex @@ -58,7 +58,11 @@ defmodule Mix.Tasks.Mobilizon.Users.Modify do An user has been modified with the following information: - email: #{user.email} - Role: #{user.role} - - Activated: #{if user.confirmed_at, do: user.confirmed_at, else: "False"} + - account status: #{ + if user.confirmed_at, + do: "activated on #{DateTime.to_string(user.confirmed_at)} (UTC)", + else: "disabled" + } """) else {:makes_changes, false} -> diff --git a/lib/mix/tasks/mobilizon/users/show.ex b/lib/mix/tasks/mobilizon/users/show.ex index 3c33aaf52..6651eb986 100644 --- a/lib/mix/tasks/mobilizon/users/show.ex +++ b/lib/mix/tasks/mobilizon/users/show.ex @@ -19,8 +19,11 @@ defmodule Mix.Tasks.Mobilizon.Users.Show do actors <- Users.get_actors_for_user(user) do shell_info(""" Informations for the user #{user.email}: - - Activated: #{user.confirmed_at} - - Disabled: #{user.disabled} + - account status: #{ + if user.confirmed_at, + do: "Activated on #{DateTime.to_string(user.confirmed_at)} (UTC)", + else: "disabled" + } - Role: #{user.role} #{display_actors(actors)} """) diff --git a/test/tasks/users_test.exs b/test/tasks/users_test.exs index 4c9cbc625..7cd82946b 100644 --- a/test/tasks/users_test.exs +++ b/test/tasks/users_test.exs @@ -76,16 +76,15 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do describe "show user" do test "show existing user" do - %User{confirmed_at: confirmed_at, role: role, disabled: disabled} = - user = insert(:user, email: @email) + %User{confirmed_at: confirmed_at, role: role} = user = insert(:user, email: @email) actor1 = insert(:actor, user: user) actor2 = insert(:actor, user: user) output = - "Informations for the user #{@email}:\n - Activated: #{confirmed_at}\n - Disabled: #{ - disabled - }\n - Role: #{role}\n Identities (2):\n - @#{actor1.preferred_username} / \n - @#{ + "Informations for the user #{@email}:\n - account status: Activated on #{confirmed_at} (UTC)\n - Role: #{ + role + }\n Identities (2):\n - @#{actor1.preferred_username} / \n - @#{ actor2.preferred_username } / \n\n\n" @@ -139,30 +138,27 @@ defmodule Mix.Tasks.Mobilizon.UsersTest do assert output_received == "An user has been modified with the following information:\n - email: #{ user.email - }\n - Role: #{user.role}\n - Activated: False\n" + }\n - Role: #{user.role}\n - account status: disabled\n" - assert {:ok, %User{email: email, confirmed_at: confirmed_at}} = - Users.get_user_by_email(@email) + assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email) assert is_nil(confirmed_at) Modify.run([@email, "--enable"]) assert_received {:mix_shell, :info, [output_received]} - assert {:ok, %User{email: email, confirmed_at: confirmed_at}} = - Users.get_user_by_email(@email) + assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email) assert output_received == "An user has been modified with the following information:\n - email: #{ user.email - }\n - Role: #{user.role}\n - Activated: #{confirmed_at}\n" + }\n - Role: #{user.role}\n - account status: activated on #{confirmed_at} (UTC)\n" refute is_nil(confirmed_at) Modify.run([@email, "--enable"]) - assert {:ok, %User{email: email, confirmed_at: confirmed_at}} = - Users.get_user_by_email(@email) + assert {:ok, %User{confirmed_at: confirmed_at}} = Users.get_user_by_email(@email) refute is_nil(confirmed_at) assert_received {:mix_shell, :info, [output_received]} From b2a7f134a774b05efe9f343c47eac1321d86b087 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 19 Apr 2021 10:07:29 +0200 Subject: [PATCH 3/3] Restrict browserlist Signed-off-by: Thomas Citharel --- js/.browserslistrc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/.browserslistrc b/js/.browserslistrc index 214388fe4..3c558dd26 100644 --- a/js/.browserslistrc +++ b/js/.browserslistrc @@ -1,3 +1,8 @@ -> 1% -last 2 versions -not dead +last 2 Chrome version +last 2 ChromeAndroid version +last 2 Firefox version +last 2 FirefoxAndroid version +last 2 Edge major versions +last 2 Safari major versions +last 2 iOS major versions +Firefox ESR \ No newline at end of file