From 8bacdc36806efd01a7897359ff0fd2c8e24730d2 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 13 Oct 2020 09:45:08 -0500 Subject: [PATCH 01/18] Change user.discoverable field to user.is_discoverable --- lib/pleroma/user.ex | 8 ++++---- lib/pleroma/user/search.ex | 2 +- lib/pleroma/web/activity_pub/activity_pub.ex | 4 ++-- lib/pleroma/web/activity_pub/views/user_view.ex | 2 +- lib/pleroma/web/admin_api/views/account_view.ex | 2 +- .../web/api_spec/operations/account_operation.ex | 4 ++-- .../web/api_spec/operations/chat_operation.ex | 2 +- lib/pleroma/web/api_spec/schemas/account.ex | 4 ++-- lib/pleroma/web/api_spec/schemas/chat.ex | 2 +- lib/pleroma/web/api_spec/schemas/status.ex | 2 +- .../controllers/account_controller.ex | 2 +- .../web/mastodon_api/views/account_view.ex | 2 +- lib/pleroma/web/metadata/restrict_indexing.ex | 2 +- ...013144052_refactor_discoverable_user_field.exs | 15 +++++++++++++++ test/support/factory.ex | 2 +- test/user_search_test.exs | 2 +- test/user_test.exs | 4 ++-- test/web/admin_api/search_test.exs | 2 +- .../update_credentials_test.exs | 8 ++++---- .../controllers/account_controller_test.exs | 2 +- test/web/mastodon_api/views/account_view_test.exs | 4 ++-- test/web/metadata/metadata_test.exs | 8 ++++---- test/web/metadata/restrict_indexing_test.exs | 4 ++-- 23 files changed, 52 insertions(+), 37 deletions(-) create mode 100644 priv/repo/migrations/20201013144052_refactor_discoverable_user_field.exs diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 09ea80793..c4640f928 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -136,7 +136,7 @@ defmodule Pleroma.User do field(:pleroma_settings_store, :map, default: %{}) field(:fields, {:array, :map}, default: []) field(:raw_fields, {:array, :map}, default: []) - field(:discoverable, :boolean, default: false) + field(:is_discoverable, :boolean, default: false) field(:invisible, :boolean, default: false) field(:allow_following_move, :boolean, default: true) field(:skip_thread_containment, :boolean, default: false) @@ -448,7 +448,7 @@ def remote_user_changeset(struct \\ %User{local: false}, params) do :follower_count, :fields, :following_count, - :discoverable, + :is_discoverable, :invisible, :actor_type, :also_known_as, @@ -495,7 +495,7 @@ def update_changeset(struct, params \\ %{}) do :fields, :raw_fields, :pleroma_settings_store, - :discoverable, + :is_discoverable, :actor_type, :also_known_as, :accepts_chat_messages @@ -1618,7 +1618,7 @@ def purge_user_changeset(user) do pleroma_settings_store: %{}, fields: [], raw_fields: [], - discoverable: false, + is_discoverable: false, also_known_as: [] }) end diff --git a/lib/pleroma/user/search.ex b/lib/pleroma/user/search.ex index 35a828008..2dab67211 100644 --- a/lib/pleroma/user/search.ex +++ b/lib/pleroma/user/search.ex @@ -164,7 +164,7 @@ defp filter_invisible_users(query) do end defp filter_discoverable_users(query) do - from(q in query, where: q.discoverable == true) + from(q in query, where: q.is_discoverable == true) end defp filter_internal_users(query) do diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index eb44cffec..236fefbb6 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1232,7 +1232,7 @@ defp object_to_user_data(data) do capabilities = data["capabilities"] || %{} accepts_chat_messages = capabilities["acceptsChatMessages"] data = Transmogrifier.maybe_fix_user_object(data) - discoverable = data["discoverable"] || false + is_discoverable = data["is_discoverable"] || false invisible = data["invisible"] || false actor_type = data["type"] || "Person" @@ -1258,7 +1258,7 @@ defp object_to_user_data(data) do fields: fields, emoji: emojis, locked: locked, - discoverable: discoverable, + is_discoverable: is_discoverable, invisible: invisible, avatar: avatar, name: data["name"], diff --git a/lib/pleroma/web/activity_pub/views/user_view.ex b/lib/pleroma/web/activity_pub/views/user_view.ex index 3a4564912..81cd7e81d 100644 --- a/lib/pleroma/web/activity_pub/views/user_view.ex +++ b/lib/pleroma/web/activity_pub/views/user_view.ex @@ -110,7 +110,7 @@ def render("user.json", %{user: user}) do "endpoints" => endpoints, "attachment" => fields, "tag" => emoji_tags, - "discoverable" => user.discoverable, + "is_discoverable" => user.is_discoverable, "capabilities" => capabilities } |> Map.merge(maybe_make_image(&User.avatar_url/2, "icon", user)) diff --git a/lib/pleroma/web/admin_api/views/account_view.ex b/lib/pleroma/web/admin_api/views/account_view.ex index 9c477feab..5f3a78a0f 100644 --- a/lib/pleroma/web/admin_api/views/account_view.ex +++ b/lib/pleroma/web/admin_api/views/account_view.ex @@ -52,7 +52,7 @@ def render("credentials.json", %{user: user, for: for_user}) do :skip_thread_containment, :pleroma_settings_store, :raw_fields, - :discoverable, + :is_discoverable, :actor_type ]) |> Map.merge(%{ diff --git a/lib/pleroma/web/api_spec/operations/account_operation.ex b/lib/pleroma/web/api_spec/operations/account_operation.ex index d90ddb787..1696b19a5 100644 --- a/lib/pleroma/web/api_spec/operations/account_operation.ex +++ b/lib/pleroma/web/api_spec/operations/account_operation.ex @@ -606,7 +606,7 @@ defp update_credentials_request do description: "Sets the background image of the user.", format: :binary }, - discoverable: %Schema{ + is_discoverable: %Schema{ allOf: [BooleanLike], nullable: true, description: @@ -630,7 +630,7 @@ defp update_credentials_request do pleroma_settings_store: %{"pleroma-fe" => %{"key" => "val"}}, skip_thread_containment: false, allow_following_move: false, - discoverable: false, + is_discoverable: false, actor_type: "Person" } } diff --git a/lib/pleroma/web/api_spec/operations/chat_operation.ex b/lib/pleroma/web/api_spec/operations/chat_operation.ex index 0dcfdb354..18693a5d7 100644 --- a/lib/pleroma/web/api_spec/operations/chat_operation.ex +++ b/lib/pleroma/web/api_spec/operations/chat_operation.ex @@ -253,7 +253,7 @@ def chats_response do "sensitive" => false, "note" => "lain", "pleroma" => %{ - "discoverable" => false, + "is_discoverable" => false, "actor_type" => "Person" }, "fields" => [] diff --git a/lib/pleroma/web/api_spec/schemas/account.ex b/lib/pleroma/web/api_spec/schemas/account.ex index ca79f0747..459e7dba6 100644 --- a/lib/pleroma/web/api_spec/schemas/account.ex +++ b/lib/pleroma/web/api_spec/schemas/account.ex @@ -124,7 +124,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do type: :object, properties: %{ actor_type: ActorType, - discoverable: %Schema{ + is_discoverable: %Schema{ type: :boolean, description: "whether the user allows discovery of the account in search results and other services." @@ -205,7 +205,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do "note" => "foobar", "pleroma" => %{ "actor_type" => "Person", - "discoverable" => false, + "is_discoverable" => false, "no_rich_text" => false, "show_role" => true }, diff --git a/lib/pleroma/web/api_spec/schemas/chat.ex b/lib/pleroma/web/api_spec/schemas/chat.ex index b4986b734..da245d0de 100644 --- a/lib/pleroma/web/api_spec/schemas/chat.ex +++ b/lib/pleroma/web/api_spec/schemas/chat.ex @@ -44,7 +44,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Chat do "sensitive" => false, "note" => "lain", "pleroma" => %{ - "discoverable" => false, + "is_discoverable" => false, "actor_type" => "Person" }, "fields" => [] diff --git a/lib/pleroma/web/api_spec/schemas/status.ex b/lib/pleroma/web/api_spec/schemas/status.ex index 947e42890..52b870d63 100644 --- a/lib/pleroma/web/api_spec/schemas/status.ex +++ b/lib/pleroma/web/api_spec/schemas/status.ex @@ -284,7 +284,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do "source" => %{ "fields" => [], "note" => "Tester Number 6", - "pleroma" => %{"actor_type" => "Person", "discoverable" => false}, + "pleroma" => %{"actor_type" => "Person", "is_discoverable" => false}, "sensitive" => false }, "statuses_count" => 1, diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex index 95d8452df..e06ff9307 100644 --- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex @@ -186,7 +186,7 @@ def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _p :show_role, :skip_thread_containment, :allow_following_move, - :discoverable, + :is_discoverable, :accepts_chat_messages ] |> Enum.reduce(%{}, fn key, acc -> diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 121ba1693..0636d9cc1 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -261,7 +261,7 @@ defp do_render("show.json", %{user: user} = opts) do sensitive: false, fields: user.raw_fields, pleroma: %{ - discoverable: user.discoverable, + is_discoverable: user.is_discoverable, actor_type: user.actor_type } }, diff --git a/lib/pleroma/web/metadata/restrict_indexing.ex b/lib/pleroma/web/metadata/restrict_indexing.ex index a1dcb6e15..900c2434d 100644 --- a/lib/pleroma/web/metadata/restrict_indexing.ex +++ b/lib/pleroma/web/metadata/restrict_indexing.ex @@ -10,7 +10,7 @@ defmodule Pleroma.Web.Metadata.Providers.RestrictIndexing do """ @impl true - def build_tags(%{user: %{local: true, discoverable: true}}), do: [] + def build_tags(%{user: %{local: true, is_discoverable: true}}), do: [] def build_tags(_) do [ diff --git a/priv/repo/migrations/20201013144052_refactor_discoverable_user_field.exs b/priv/repo/migrations/20201013144052_refactor_discoverable_user_field.exs new file mode 100644 index 000000000..3fdc190cc --- /dev/null +++ b/priv/repo/migrations/20201013144052_refactor_discoverable_user_field.exs @@ -0,0 +1,15 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Repo.Migrations.RefactorDiscoverableUserField do + use Ecto.Migration + + def up do + execute("ALTER TABLE users RENAME COLUMN discoverable TO is_discoverable;") + end + + def down do + execute("ALTER TABLE users RENAME COLUMN is_discoverable TO discoverable;") + end +end diff --git a/test/support/factory.ex b/test/support/factory.ex index fb82be0c4..80b882ee4 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -31,7 +31,7 @@ def user_factory do nickname: sequence(:nickname, &"nick#{&1}"), password_hash: Pbkdf2.hash_pwd_salt("test"), bio: sequence(:bio, &"Tester Number #{&1}"), - discoverable: true, + is_discoverable: true, last_digest_emailed_at: NaiveDateTime.utc_now(), last_refreshed_at: NaiveDateTime.utc_now(), notification_settings: %Pleroma.User.NotificationSetting{}, diff --git a/test/user_search_test.exs b/test/user_search_test.exs index c4b805005..31d787ffa 100644 --- a/test/user_search_test.exs +++ b/test/user_search_test.exs @@ -66,7 +66,7 @@ test "excludes invisible users from results" do end test "excludes users when discoverable is false" do - insert(:user, %{nickname: "john 3000", discoverable: false}) + insert(:user, %{nickname: "john 3000", is_discoverable: false}) insert(:user, %{nickname: "john 3001"}) users = User.search("john") diff --git a/test/user_test.exs b/test/user_test.exs index d506f7047..7d7bf4b78 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -1467,7 +1467,7 @@ test "delete/1 purges a user when they wouldn't be fully deleted" do pleroma_settings_store: %{"q" => "x"}, fields: [%{"gg" => "qq"}], raw_fields: [%{"gg" => "qq"}], - discoverable: true, + is_discoverable: true, also_known_as: ["https://lol.olo/users/loll"] }) @@ -1509,7 +1509,7 @@ test "delete/1 purges a user when they wouldn't be fully deleted" do pleroma_settings_store: %{}, fields: [], raw_fields: [], - discoverable: false, + is_discoverable: false, also_known_as: [] } = user end diff --git a/test/web/admin_api/search_test.exs b/test/web/admin_api/search_test.exs index d88867c52..ceec64f1e 100644 --- a/test/web/admin_api/search_test.exs +++ b/test/web/admin_api/search_test.exs @@ -180,7 +180,7 @@ test "it returns unapproved user" do test "it returns non-discoverable users" do insert(:user) - insert(:user, discoverable: false) + insert(:user, is_discoverable: false) {:ok, _results, total} = Search.user() diff --git a/test/web/mastodon_api/controllers/account_controller/update_credentials_test.exs b/test/web/mastodon_api/controllers/account_controller/update_credentials_test.exs index 2e6704726..d31cc27cc 100644 --- a/test/web/mastodon_api/controllers/account_controller/update_credentials_test.exs +++ b/test/web/mastodon_api/controllers/account_controller/update_credentials_test.exs @@ -147,14 +147,14 @@ test "updates the user's hide_followers status", %{conn: conn} do end test "updates the user's discoverable status", %{conn: conn} do - assert %{"source" => %{"pleroma" => %{"discoverable" => true}}} = + assert %{"source" => %{"pleroma" => %{"is_discoverable" => true}}} = conn - |> patch("/api/v1/accounts/update_credentials", %{discoverable: "true"}) + |> patch("/api/v1/accounts/update_credentials", %{is_discoverable: "true"}) |> json_response_and_validate_schema(:ok) - assert %{"source" => %{"pleroma" => %{"discoverable" => false}}} = + assert %{"source" => %{"pleroma" => %{"is_discoverable" => false}}} = conn - |> patch("/api/v1/accounts/update_credentials", %{discoverable: "false"}) + |> patch("/api/v1/accounts/update_credentials", %{is_discoverable: "false"}) |> json_response_and_validate_schema(:ok) end diff --git a/test/web/mastodon_api/controllers/account_controller_test.exs b/test/web/mastodon_api/controllers/account_controller_test.exs index f7f1369e4..f7eb97dbb 100644 --- a/test/web/mastodon_api/controllers/account_controller_test.exs +++ b/test/web/mastodon_api/controllers/account_controller_test.exs @@ -1278,7 +1278,7 @@ test "registration from trusted app" do "note" => "", "pleroma" => %{ "actor_type" => "Person", - "discoverable" => false, + "is_discoverable" => false, "no_rich_text" => false, "show_role" => true }, diff --git a/test/web/mastodon_api/views/account_view_test.exs b/test/web/mastodon_api/views/account_view_test.exs index a5f39b215..3b0454df2 100644 --- a/test/web/mastodon_api/views/account_view_test.exs +++ b/test/web/mastodon_api/views/account_view_test.exs @@ -69,7 +69,7 @@ test "Represent a user account" do sensitive: false, pleroma: %{ actor_type: "Person", - discoverable: true + is_discoverable: true }, fields: [] }, @@ -167,7 +167,7 @@ test "Represent a Service(bot) account" do sensitive: false, pleroma: %{ actor_type: "Service", - discoverable: true + is_discoverable: true }, fields: [] }, diff --git a/test/web/metadata/metadata_test.exs b/test/web/metadata/metadata_test.exs index ca6cbe67f..8fb946540 100644 --- a/test/web/metadata/metadata_test.exs +++ b/test/web/metadata/metadata_test.exs @@ -16,14 +16,14 @@ test "for remote user" do end test "for local user" do - user = insert(:user, discoverable: false) + user = insert(:user, is_discoverable: false) assert Pleroma.Web.Metadata.build_tags(%{user: user}) =~ "" end test "for local user set to discoverable" do - user = insert(:user, discoverable: true) + user = insert(:user, is_discoverable: true) refute Pleroma.Web.Metadata.build_tags(%{user: user}) =~ "" @@ -33,14 +33,14 @@ test "for local user set to discoverable" do describe "no metadata for private instances" do test "for local user set to discoverable" do clear_config([:instance, :public], false) - user = insert(:user, bio: "This is my secret fedi account bio", discoverable: true) + user = insert(:user, bio: "This is my secret fedi account bio", is_discoverable: true) assert "" = Pleroma.Web.Metadata.build_tags(%{user: user}) end test "search exclusion metadata is included" do clear_config([:instance, :public], false) - user = insert(:user, bio: "This is my secret fedi account bio", discoverable: false) + user = insert(:user, bio: "This is my secret fedi account bio", is_discoverable: false) assert ~s() == Pleroma.Web.Metadata.build_tags(%{user: user}) diff --git a/test/web/metadata/restrict_indexing_test.exs b/test/web/metadata/restrict_indexing_test.exs index 6b3a65372..282d132c8 100644 --- a/test/web/metadata/restrict_indexing_test.exs +++ b/test/web/metadata/restrict_indexing_test.exs @@ -14,13 +14,13 @@ test "for remote user" do test "for local user" do assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{ - user: %Pleroma.User{local: true, discoverable: true} + user: %Pleroma.User{local: true, is_discoverable: true} }) == [] end test "for local user when discoverable is false" do assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{ - user: %Pleroma.User{local: true, discoverable: false} + user: %Pleroma.User{local: true, is_discoverable: false} }) == [{:meta, [name: "robots", content: "noindex, noarchive"], []}] end end From 3242cfef20ea05bae53761ffaf54347c4c6f7bda Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 14 Oct 2020 09:54:07 -0500 Subject: [PATCH 02/18] Undo API breaking changes --- lib/pleroma/web/api_spec/operations/account_operation.ex | 4 ++-- lib/pleroma/web/api_spec/operations/chat_operation.ex | 2 +- lib/pleroma/web/api_spec/schemas/account.ex | 4 ++-- test/pleroma/web/mastodon_api/update_credentials_test.exs | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/pleroma/web/api_spec/operations/account_operation.ex b/lib/pleroma/web/api_spec/operations/account_operation.ex index 1696b19a5..d90ddb787 100644 --- a/lib/pleroma/web/api_spec/operations/account_operation.ex +++ b/lib/pleroma/web/api_spec/operations/account_operation.ex @@ -606,7 +606,7 @@ defp update_credentials_request do description: "Sets the background image of the user.", format: :binary }, - is_discoverable: %Schema{ + discoverable: %Schema{ allOf: [BooleanLike], nullable: true, description: @@ -630,7 +630,7 @@ defp update_credentials_request do pleroma_settings_store: %{"pleroma-fe" => %{"key" => "val"}}, skip_thread_containment: false, allow_following_move: false, - is_discoverable: false, + discoverable: false, actor_type: "Person" } } diff --git a/lib/pleroma/web/api_spec/operations/chat_operation.ex b/lib/pleroma/web/api_spec/operations/chat_operation.ex index 18693a5d7..0dcfdb354 100644 --- a/lib/pleroma/web/api_spec/operations/chat_operation.ex +++ b/lib/pleroma/web/api_spec/operations/chat_operation.ex @@ -253,7 +253,7 @@ def chats_response do "sensitive" => false, "note" => "lain", "pleroma" => %{ - "is_discoverable" => false, + "discoverable" => false, "actor_type" => "Person" }, "fields" => [] diff --git a/lib/pleroma/web/api_spec/schemas/account.ex b/lib/pleroma/web/api_spec/schemas/account.ex index 459e7dba6..ca79f0747 100644 --- a/lib/pleroma/web/api_spec/schemas/account.ex +++ b/lib/pleroma/web/api_spec/schemas/account.ex @@ -124,7 +124,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do type: :object, properties: %{ actor_type: ActorType, - is_discoverable: %Schema{ + discoverable: %Schema{ type: :boolean, description: "whether the user allows discovery of the account in search results and other services." @@ -205,7 +205,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do "note" => "foobar", "pleroma" => %{ "actor_type" => "Person", - "is_discoverable" => false, + "discoverable" => false, "no_rich_text" => false, "show_role" => true }, diff --git a/test/pleroma/web/mastodon_api/update_credentials_test.exs b/test/pleroma/web/mastodon_api/update_credentials_test.exs index 383d351cf..fe462caa3 100644 --- a/test/pleroma/web/mastodon_api/update_credentials_test.exs +++ b/test/pleroma/web/mastodon_api/update_credentials_test.exs @@ -147,14 +147,14 @@ test "updates the user's hide_followers status", %{conn: conn} do end test "updates the user's discoverable status", %{conn: conn} do - assert %{"source" => %{"pleroma" => %{"is_discoverable" => true}}} = + assert %{"source" => %{"pleroma" => %{"discoverable" => true}}} = conn - |> patch("/api/v1/accounts/update_credentials", %{is_discoverable: "true"}) + |> patch("/api/v1/accounts/update_credentials", %{discoverable: "true"}) |> json_response_and_validate_schema(:ok) - assert %{"source" => %{"pleroma" => %{"is_discoverable" => false}}} = + assert %{"source" => %{"pleroma" => %{"discoverable" => false}}} = conn - |> patch("/api/v1/accounts/update_credentials", %{is_discoverable: "false"}) + |> patch("/api/v1/accounts/update_credentials", %{discoverable: "false"}) |> json_response_and_validate_schema(:ok) end From b001237b79d50eef1f0636951cddc7b6da20260d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 14 Oct 2020 10:44:18 -0500 Subject: [PATCH 03/18] Finish undoing API breakage --- lib/pleroma/web/activity_pub/views/user_view.ex | 2 +- .../web/mastodon_api/controllers/account_controller.ex | 2 +- lib/pleroma/web/mastodon_api/views/account_view.ex | 2 +- .../web/mastodon_api/controllers/account_controller_test.exs | 2 +- test/pleroma/web/mastodon_api/views/account_view_test.exs | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/web/activity_pub/views/user_view.ex b/lib/pleroma/web/activity_pub/views/user_view.ex index 81cd7e81d..e57c91149 100644 --- a/lib/pleroma/web/activity_pub/views/user_view.ex +++ b/lib/pleroma/web/activity_pub/views/user_view.ex @@ -110,7 +110,7 @@ def render("user.json", %{user: user}) do "endpoints" => endpoints, "attachment" => fields, "tag" => emoji_tags, - "is_discoverable" => user.is_discoverable, + "discoverable" => user.is_discoverable, "capabilities" => capabilities } |> Map.merge(maybe_make_image(&User.avatar_url/2, "icon", user)) diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex index 6453880dc..9d2f42da9 100644 --- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex @@ -186,7 +186,6 @@ def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _p :show_role, :skip_thread_containment, :allow_following_move, - :is_discoverable, :accepts_chat_messages ] |> Enum.reduce(%{}, fn key, acc -> @@ -210,6 +209,7 @@ def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _p if bot, do: {:ok, "Service"}, else: {:ok, "Person"} end) |> Maps.put_if_present(:actor_type, params[:actor_type]) + |> Maps.put_if_present(:is_discoverable, params[:discoverable]) # What happens here: # diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 0636d9cc1..d57537ee3 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -261,7 +261,7 @@ defp do_render("show.json", %{user: user} = opts) do sensitive: false, fields: user.raw_fields, pleroma: %{ - is_discoverable: user.is_discoverable, + discoverable: user.is_discoverable, actor_type: user.actor_type } }, diff --git a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs index f7eb97dbb..f7f1369e4 100644 --- a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs @@ -1278,7 +1278,7 @@ test "registration from trusted app" do "note" => "", "pleroma" => %{ "actor_type" => "Person", - "is_discoverable" => false, + "discoverable" => false, "no_rich_text" => false, "show_role" => true }, diff --git a/test/pleroma/web/mastodon_api/views/account_view_test.exs b/test/pleroma/web/mastodon_api/views/account_view_test.exs index 3b0454df2..a5f39b215 100644 --- a/test/pleroma/web/mastodon_api/views/account_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs @@ -69,7 +69,7 @@ test "Represent a user account" do sensitive: false, pleroma: %{ actor_type: "Person", - is_discoverable: true + discoverable: true }, fields: [] }, @@ -167,7 +167,7 @@ test "Represent a Service(bot) account" do sensitive: false, pleroma: %{ actor_type: "Service", - is_discoverable: true + discoverable: true }, fields: [] }, From 42112b842ce80571e83f6ea35c4ba9ff817264cb Mon Sep 17 00:00:00 2001 From: swentel Date: Wed, 14 Oct 2020 21:32:18 +0200 Subject: [PATCH 04/18] Change handle and url of contact person for Indigenous client --- docs/clients.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/clients.md b/docs/clients.md index f84295b1f..1e2c14f1b 100644 --- a/docs/clients.md +++ b/docs/clients.md @@ -71,7 +71,7 @@ Feel free to contact us to be added to this list! ### Indigenous - Homepage: - Source Code: -- Contact: [@realize.be@realize.be](@realize.be@realize.be) +- Contact: [@swentel@realize.be](https://realize.be) - Platforms: Android - Features: No Streaming From 77bca415951be516f1b48dc6346600856c96ef5c Mon Sep 17 00:00:00 2001 From: feld Date: Wed, 14 Oct 2020 19:33:54 +0000 Subject: [PATCH 05/18] Apply 3 suggestion(s) to 3 file(s) --- lib/pleroma/web/activity_pub/activity_pub.ex | 2 +- lib/pleroma/web/api_spec/schemas/chat.ex | 2 +- lib/pleroma/web/api_spec/schemas/status.ex | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 236fefbb6..b04b72106 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1232,7 +1232,7 @@ defp object_to_user_data(data) do capabilities = data["capabilities"] || %{} accepts_chat_messages = capabilities["acceptsChatMessages"] data = Transmogrifier.maybe_fix_user_object(data) - is_discoverable = data["is_discoverable"] || false + is_discoverable = data["discoverable"] || false invisible = data["invisible"] || false actor_type = data["type"] || "Person" diff --git a/lib/pleroma/web/api_spec/schemas/chat.ex b/lib/pleroma/web/api_spec/schemas/chat.ex index da245d0de..b4986b734 100644 --- a/lib/pleroma/web/api_spec/schemas/chat.ex +++ b/lib/pleroma/web/api_spec/schemas/chat.ex @@ -44,7 +44,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Chat do "sensitive" => false, "note" => "lain", "pleroma" => %{ - "is_discoverable" => false, + "discoverable" => false, "actor_type" => "Person" }, "fields" => [] diff --git a/lib/pleroma/web/api_spec/schemas/status.ex b/lib/pleroma/web/api_spec/schemas/status.ex index 52b870d63..947e42890 100644 --- a/lib/pleroma/web/api_spec/schemas/status.ex +++ b/lib/pleroma/web/api_spec/schemas/status.ex @@ -284,7 +284,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do "source" => %{ "fields" => [], "note" => "Tester Number 6", - "pleroma" => %{"actor_type" => "Person", "is_discoverable" => false}, + "pleroma" => %{"actor_type" => "Person", "discoverable" => false}, "sensitive" => false }, "statuses_count" => 1, From 7a2f100061913ec59db9957893eb92bb2d150dc4 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 15 Oct 2020 12:28:25 +0200 Subject: [PATCH 06/18] ActivityPub: Show own replies to muted users. Aligns mute with block behavior. --- lib/pleroma/web/activity_pub/activity_pub.ex | 9 ++++++++- .../web/activity_pub/activity_pub_test.exs | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 8022f0402..ff7b9e778 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -827,7 +827,14 @@ defp restrict_muted(query, %{muting_user: %User{} = user} = opts) do query = from([activity] in query, where: fragment("not (? = ANY(?))", activity.actor, ^mutes), - where: fragment("not (?->'to' \\?| ?)", activity.data, ^mutes) + where: + fragment( + "not (?->'to' \\?| ?) or ? = ?", + activity.data, + ^mutes, + activity.actor, + ^user.ap_id + ) ) unless opts[:skip_preload] do diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs index 1a8a844ca..e6b6086e6 100644 --- a/test/pleroma/web/activity_pub/activity_pub_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_test.exs @@ -752,6 +752,22 @@ test "does return activities from followed users on blocked domains" do refute repeat_activity in activities end + test "returns your own posts regardless of mute" do + user = insert(:user) + muted = insert(:user) + + {:ok, muted_post} = CommonAPI.post(muted, %{status: "Im stupid"}) + + {:ok, reply} = + CommonAPI.post(user, %{status: "I'm muting you", in_reply_to_status_id: muted_post.id}) + + {:ok, _} = User.mute(user, muted) + + [activity] = ActivityPub.fetch_activities([], %{muting_user: user, skip_preload: true}) + + assert activity.id == reply.id + end + test "doesn't return muted activities" do activity_one = insert(:note_activity) activity_two = insert(:note_activity) From 20e68b30f08e0e0eae691dcf541968e344efdaae Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Tue, 14 Jul 2020 07:31:21 +0300 Subject: [PATCH 07/18] added generated `pleroma.env` --- .gitignore | 2 + .../CLI_tasks/release_environments.md | 9 +++ docs/installation/otp_en.md | 6 +- installation/pleroma.service | 2 + lib/mix/tasks/pleroma/release_env.ex | 64 +++++++++++++++++++ test/mix/tasks/pleroma/release_env_test.exs | 30 +++++++++ 6 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 docs/administration/CLI_tasks/release_environments.md create mode 100644 lib/mix/tasks/pleroma/release_env.ex create mode 100644 test/mix/tasks/pleroma/release_env_test.exs diff --git a/.gitignore b/.gitignore index 599b52b9e..6ae21e914 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,8 @@ erl_crash.dump # variables. /config/*.secret.exs /config/generated_config.exs +/config/*.env + # Database setup file, some may forget to delete it /config/setup_db.psql diff --git a/docs/administration/CLI_tasks/release_environments.md b/docs/administration/CLI_tasks/release_environments.md new file mode 100644 index 000000000..36ab43864 --- /dev/null +++ b/docs/administration/CLI_tasks/release_environments.md @@ -0,0 +1,9 @@ +# Generate release environment file + +```sh tab="OTP" + ./bin/pleroma_ctl release_env gen +``` + +```sh tab="From Source" +mix pleroma.release_env gen +``` diff --git a/docs/installation/otp_en.md b/docs/installation/otp_en.md index 62d4c8a72..07fabfc0d 100644 --- a/docs/installation/otp_en.md +++ b/docs/installation/otp_en.md @@ -149,6 +149,9 @@ chown -R pleroma /etc/pleroma # Run the config generator su pleroma -s $SHELL -lc "./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql" +# Run the environment file generator. +su pleroma -s $SHELL -lc "./bin/pleroma_ctl release_env gen" + # Create the postgres database su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql" @@ -159,7 +162,7 @@ su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate" # su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate --migrations-path priv/repo/optional_migrations/rum_indexing/" # Start the instance to verify that everything is working as expected -su pleroma -s $SHELL -lc "./bin/pleroma daemon" +su pleroma -s $SHELL -lc "export $( cat /opt/pleroma/config/pleroma.env | xargs); ./bin/pleroma daemon" # Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly sleep 20 && curl http://localhost:4000/api/v1/instance @@ -311,4 +314,3 @@ This will create an account withe the username of 'joeuser' with the email addre ## Questions Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**. - diff --git a/installation/pleroma.service b/installation/pleroma.service index 5dcbc1387..ee00a3b7a 100644 --- a/installation/pleroma.service +++ b/installation/pleroma.service @@ -17,6 +17,8 @@ Environment="MIX_ENV=prod" Environment="HOME=/var/lib/pleroma" ; Path to the folder containing the Pleroma installation. WorkingDirectory=/opt/pleroma +; Path to the environment file. the file contains RELEASE_COOKIE and etc +EnvironmentFile=/opt/pleroma/config/pleroma.env ; Path to the Mix binary. ExecStart=/usr/bin/mix phx.server diff --git a/lib/mix/tasks/pleroma/release_env.ex b/lib/mix/tasks/pleroma/release_env.ex new file mode 100644 index 000000000..cbbbdeff6 --- /dev/null +++ b/lib/mix/tasks/pleroma/release_env.ex @@ -0,0 +1,64 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Mix.Tasks.Pleroma.ReleaseEnv do + use Mix.Task + import Mix.Pleroma + + @shortdoc "Generate Pleroma environment file." + @moduledoc File.read!("docs/administration/CLI_tasks/release_environments.md") + + def run(["gen" | rest]) do + {options, [], []} = + OptionParser.parse( + rest, + strict: [ + force: :boolean, + path: :string + ], + aliases: [ + p: :path, + f: :force + ] + ) + + env_path = + get_option( + options, + :path, + "Environment file path", + "config/pleroma.env" + ) + |> Path.expand() + + proceed? = + if File.exists?(env_path) do + get_option( + options, + :force, + "Environment file is exist. Do you want overwritten the #{env_path} file? (y/n)", + "n" + ) === "y" + else + true + end + + if proceed? do + do_generate(env_path) + + shell_info( + "The file generated: #{env_path}.\nTo use the enviroment file need to add the line ';EnvironmentFile=#{ + env_path + }' in service file (/installation/pleroma.service)." + ) + end + end + + def do_generate(path) do + content = "RELEASE_COOKIE=#{Base.encode32(:crypto.strong_rand_bytes(32))}" + + File.mkdir_p!(Path.dirname(path)) + File.write!(path, content) + end +end diff --git a/test/mix/tasks/pleroma/release_env_test.exs b/test/mix/tasks/pleroma/release_env_test.exs new file mode 100644 index 000000000..519f1eba9 --- /dev/null +++ b/test/mix/tasks/pleroma/release_env_test.exs @@ -0,0 +1,30 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Mix.Tasks.Pleroma.ReleaseEnvTest do + use ExUnit.Case + import ExUnit.CaptureIO, only: [capture_io: 1] + + @path "config/pleroma.test.env" + + def do_clean do + if File.exists?(@path) do + File.rm_rf(@path) + end + end + + setup do + do_clean() + on_exit(fn -> do_clean() end) + :ok + end + + test "generate pleroma.env" do + assert capture_io(fn -> + Mix.Tasks.Pleroma.ReleaseEnv.run(["gen", "--path", @path, "--force"]) + end) =~ "The file generated" + + assert File.read!(@path) =~ "RELEASE_COOKIE=" + end +end From 14054cd004d91e89644c31d61b08d50ff0df09dd Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Thu, 16 Jul 2020 08:52:14 +0300 Subject: [PATCH 08/18] update task messages --- installation/init.d/pleroma | 1 + lib/mix/tasks/pleroma/release_env.ex | 32 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/installation/init.d/pleroma b/installation/init.d/pleroma index 384536f7e..e908cda1b 100755 --- a/installation/init.d/pleroma +++ b/installation/init.d/pleroma @@ -8,6 +8,7 @@ pidfile="/var/run/pleroma.pid" directory=/opt/pleroma healthcheck_delay=60 healthcheck_timer=30 +export $(cat /opt/pleroma/config/pleroma.env) : ${pleroma_port:-4000} diff --git a/lib/mix/tasks/pleroma/release_env.ex b/lib/mix/tasks/pleroma/release_env.ex index cbbbdeff6..63030c5cc 100644 --- a/lib/mix/tasks/pleroma/release_env.ex +++ b/lib/mix/tasks/pleroma/release_env.ex @@ -23,14 +23,15 @@ def run(["gen" | rest]) do ] ) - env_path = + file_path = get_option( options, :path, "Environment file path", - "config/pleroma.env" + "./config/pleroma.env" ) - |> Path.expand() + + env_path = Path.expand(file_path) proceed? = if File.exists?(env_path) do @@ -45,13 +46,24 @@ def run(["gen" | rest]) do end if proceed? do - do_generate(env_path) + case do_generate(env_path) do + {:error, reason} -> + shell_error( + File.Error.message(%{action: "write to file", reason: reason, path: env_path}) + ) - shell_info( - "The file generated: #{env_path}.\nTo use the enviroment file need to add the line ';EnvironmentFile=#{ - env_path - }' in service file (/installation/pleroma.service)." - ) + _ -> + shell_info("\nThe file generated: #{env_path}.\n") + + shell_info(""" + WARNING: before start pleroma app please to made the file read-only and non-modifiable. + Example: + chmod 0444 #{file_path} + chattr +i #{file_path} + """) + end + else + shell_info("\nThe file is exist. #{env_path}.\n") end end @@ -59,6 +71,6 @@ def do_generate(path) do content = "RELEASE_COOKIE=#{Base.encode32(:crypto.strong_rand_bytes(32))}" File.mkdir_p!(Path.dirname(path)) - File.write!(path, content) + File.write(path, content) end end From 499df7b73aa723aab9c623754b531307b98cf584 Mon Sep 17 00:00:00 2001 From: Maksim Date: Thu, 16 Jul 2020 13:30:17 +0000 Subject: [PATCH 09/18] Apply 1 suggestion(s) to 1 file(s) --- lib/mix/tasks/pleroma/release_env.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mix/tasks/pleroma/release_env.ex b/lib/mix/tasks/pleroma/release_env.ex index 63030c5cc..4d8b6ff27 100644 --- a/lib/mix/tasks/pleroma/release_env.ex +++ b/lib/mix/tasks/pleroma/release_env.ex @@ -56,7 +56,7 @@ def run(["gen" | rest]) do shell_info("\nThe file generated: #{env_path}.\n") shell_info(""" - WARNING: before start pleroma app please to made the file read-only and non-modifiable. + WARNING: before start pleroma app please make sure to make the file read-only and non-modifiable. Example: chmod 0444 #{file_path} chattr +i #{file_path} From e2333f757a763f7ec7105df6b4de4585fc3eee05 Mon Sep 17 00:00:00 2001 From: Maksim Date: Thu, 16 Jul 2020 13:30:28 +0000 Subject: [PATCH 10/18] Apply 1 suggestion(s) to 1 file(s) --- lib/mix/tasks/pleroma/release_env.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mix/tasks/pleroma/release_env.ex b/lib/mix/tasks/pleroma/release_env.ex index 4d8b6ff27..9da74ffcf 100644 --- a/lib/mix/tasks/pleroma/release_env.ex +++ b/lib/mix/tasks/pleroma/release_env.ex @@ -38,7 +38,7 @@ def run(["gen" | rest]) do get_option( options, :force, - "Environment file is exist. Do you want overwritten the #{env_path} file? (y/n)", + "Environment file already exists. Do you want to overwrite the #{env_path} file? (y/n)", "n" ) === "y" else From 2f6bbd53b5b2da2bf1e3e396b8edbe23c5345b81 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Thu, 16 Jul 2020 16:35:09 +0300 Subject: [PATCH 11/18] fix docs --- docs/installation/otp_en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/installation/otp_en.md b/docs/installation/otp_en.md index 07fabfc0d..676b10699 100644 --- a/docs/installation/otp_en.md +++ b/docs/installation/otp_en.md @@ -162,7 +162,7 @@ su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate" # su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate --migrations-path priv/repo/optional_migrations/rum_indexing/" # Start the instance to verify that everything is working as expected -su pleroma -s $SHELL -lc "export $( cat /opt/pleroma/config/pleroma.env | xargs); ./bin/pleroma daemon" +su pleroma -s $SHELL -lc "export $(cat /opt/pleroma/config/pleroma.env); ./bin/pleroma daemon" # Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly sleep 20 && curl http://localhost:4000/api/v1/instance From 595da6080dc12675eb7673a3190b88ad5a3712ed Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Wed, 5 Aug 2020 19:04:12 +0300 Subject: [PATCH 12/18] fixed install docs --- docs/installation/debian_based_en.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/installation/debian_based_en.md b/docs/installation/debian_based_en.md index 6a9026d94..6badfeed7 100644 --- a/docs/installation/debian_based_en.md +++ b/docs/installation/debian_based_en.md @@ -101,6 +101,10 @@ sudo -Hu pleroma mix deps.get mv config/{generated_config.exs,prod.secret.exs} ``` +* Generate the environment file: `sudo -Hu pleroma mix pleroma.release_env gen` + * Input path to env file or keep default value `./config/pleroma.env` + + * The previous command creates also the file `config/setup_db.psql`, with which you can create the database: ```shell @@ -181,6 +185,7 @@ sudo cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.se ``` * Edit the service file and make sure that all paths fit your installation +* Check that `EnvironmentFile` contains the correct path to the env file. Or generate the env file: `sudo -Hu pleroma mix pleroma.release_env gen` * Enable and start `pleroma.service`: ```shell From cf53e300f8e850aeacb88e6e6b4d465378acc199 Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Fri, 7 Aug 2020 15:55:08 +0300 Subject: [PATCH 13/18] added generate the release env to `pleroma.instance gen` --- docs/administration/CLI_tasks/instance.md | 1 + docs/installation/debian_based_en.md | 3 --- lib/mix/tasks/pleroma/instance.ex | 13 ++++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/administration/CLI_tasks/instance.md b/docs/administration/CLI_tasks/instance.md index d6913280a..d922b44df 100644 --- a/docs/administration/CLI_tasks/instance.md +++ b/docs/administration/CLI_tasks/instance.md @@ -40,3 +40,4 @@ If any of the options are left unspecified, you will be prompted interactively. - `--strip-uploads ` - use ExifTool to strip uploads of sensitive location data - `--anonymize-uploads ` - randomize uploaded filenames - `--dedupe-uploads ` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames +- `--skip-release-env` - skip generation the release environment file diff --git a/docs/installation/debian_based_en.md b/docs/installation/debian_based_en.md index 6badfeed7..b9fc4e112 100644 --- a/docs/installation/debian_based_en.md +++ b/docs/installation/debian_based_en.md @@ -101,9 +101,6 @@ sudo -Hu pleroma mix deps.get mv config/{generated_config.exs,prod.secret.exs} ``` -* Generate the environment file: `sudo -Hu pleroma mix pleroma.release_env gen` - * Input path to env file or keep default value `./config/pleroma.env` - * The previous command creates also the file `config/setup_db.psql`, with which you can create the database: diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex index fc21ae062..caa7dfbd3 100644 --- a/lib/mix/tasks/pleroma/instance.ex +++ b/lib/mix/tasks/pleroma/instance.ex @@ -36,7 +36,8 @@ def run(["gen" | rest]) do listen_port: :string, strip_uploads: :string, anonymize_uploads: :string, - dedupe_uploads: :string + dedupe_uploads: :string, + skip_release_env: :boolean ], aliases: [ o: :output, @@ -241,6 +242,16 @@ def run(["gen" | rest]) do write_robots_txt(static_dir, indexable, template_dir) + if Keyword.get(options, :skip_release_env, false) do + shell_info(""" + Release environment file is skip. Please generate the release env file before start. + `MIX_ENV=#{Mix.env()} mix pleroma.release_env gen` + """) + else + shell_info("Generation the environment file:") + Mix.Tasks.Pleroma.ReleaseEnv.run(["gen"]) + end + shell_info( "\n All files successfully written! Refer to the installation instructions for your platform for next steps." ) From 2030ffd4904b6ab5e99cefa62887154a49aaf4db Mon Sep 17 00:00:00 2001 From: Maksim Pechnikov Date: Sat, 8 Aug 2020 06:49:19 +0300 Subject: [PATCH 14/18] fix test --- docs/administration/CLI_tasks/instance.md | 1 + lib/mix/tasks/pleroma/instance.ex | 13 +++++++++++-- test/mix/tasks/pleroma/instance_test.exs | 11 ++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/administration/CLI_tasks/instance.md b/docs/administration/CLI_tasks/instance.md index d922b44df..982b22bf3 100644 --- a/docs/administration/CLI_tasks/instance.md +++ b/docs/administration/CLI_tasks/instance.md @@ -41,3 +41,4 @@ If any of the options are left unspecified, you will be prompted interactively. - `--anonymize-uploads ` - randomize uploaded filenames - `--dedupe-uploads ` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames - `--skip-release-env` - skip generation the release environment file +- `--release-env-file` - release environment file path diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex index caa7dfbd3..1915aacd9 100644 --- a/lib/mix/tasks/pleroma/instance.ex +++ b/lib/mix/tasks/pleroma/instance.ex @@ -37,7 +37,8 @@ def run(["gen" | rest]) do strip_uploads: :string, anonymize_uploads: :string, dedupe_uploads: :string, - skip_release_env: :boolean + skip_release_env: :boolean, + release_env_file: :string ], aliases: [ o: :output, @@ -249,7 +250,15 @@ def run(["gen" | rest]) do """) else shell_info("Generation the environment file:") - Mix.Tasks.Pleroma.ReleaseEnv.run(["gen"]) + + release_env_args = + with path when not is_nil(path) <- Keyword.get(options, :release_env_file) do + ["gen", "--path", path] + else + _ -> ["gen"] + end + + Mix.Tasks.Pleroma.ReleaseEnv.run(release_env_args) end shell_info( diff --git a/test/mix/tasks/pleroma/instance_test.exs b/test/mix/tasks/pleroma/instance_test.exs index 8a02710ee..fe69a2def 100644 --- a/test/mix/tasks/pleroma/instance_test.exs +++ b/test/mix/tasks/pleroma/instance_test.exs @@ -5,6 +5,8 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do use ExUnit.Case + @release_env_file "./test/pleroma.test.env" + setup do File.mkdir_p!(tmp_path()) @@ -16,6 +18,8 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do File.rm_rf(Path.join(static_dir, "robots.txt")) end + if File.exists?(@release_env_file), do: File.rm_rf(@release_env_file) + Pleroma.Config.put([:instance, :static_dir], static_dir) end) @@ -69,7 +73,9 @@ test "running gen" do "--dedupe-uploads", "n", "--anonymize-uploads", - "n" + "n", + "--release-env-file", + @release_env_file ]) end @@ -91,6 +97,9 @@ test "running gen" do assert generated_config =~ "filters: [Pleroma.Upload.Filter.ExifTool]" assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql() assert File.exists?(Path.expand("./test/instance/static/robots.txt")) + assert File.exists?(@release_env_file) + + assert File.read!(@release_env_file) =~ ~r/^RELEASE_COOKIE=.*/ end defp generated_setup_psql do From 724e4b7f00041667b9fa61fd1b7dd51c8eeaa102 Mon Sep 17 00:00:00 2001 From: Haelwenn Date: Thu, 15 Oct 2020 21:03:48 +0000 Subject: [PATCH 15/18] Apply 1 suggestion(s) to 1 file(s) --- lib/pleroma/web/admin_api/views/account_view.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/admin_api/views/account_view.ex b/lib/pleroma/web/admin_api/views/account_view.ex index 5f3a78a0f..9c477feab 100644 --- a/lib/pleroma/web/admin_api/views/account_view.ex +++ b/lib/pleroma/web/admin_api/views/account_view.ex @@ -52,7 +52,7 @@ def render("credentials.json", %{user: user, for: for_user}) do :skip_thread_containment, :pleroma_settings_store, :raw_fields, - :is_discoverable, + :discoverable, :actor_type ]) |> Map.merge(%{ From 405f27b4f8c430ddf7c47b09c5c693f5a17bcbc2 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Fri, 16 Oct 2020 17:41:44 +0000 Subject: [PATCH 16/18] The suggestions are problematic as they need to be real local account names --- config/description.exs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/config/description.exs b/config/description.exs index 2a1898922..0da1da57d 100644 --- a/config/description.exs +++ b/config/description.exs @@ -829,13 +829,7 @@ key: :autofollowed_nicknames, type: {:list, :string}, description: - "Set to nicknames of (local) users that every new user should automatically follow", - suggestions: [ - "lain", - "kaniini", - "lanodan", - "rinpatch" - ] + "Set to nicknames of (local) users that every new user should automatically follow" }, %{ key: :attachment_links, From cb3ee4d543861e65a1de974c3920fdecdcf6a6a7 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sat, 17 Oct 2020 11:52:33 -0500 Subject: [PATCH 17/18] Fix duplicate Added sections in the changelog --- CHANGELOG.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36a84b1a8..05e94581a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Mix tasks for controlling user account confirmation status in bulk (`mix pleroma.user confirm_all` and `mix pleroma.user unconfirm_all`) - Mix task for sending confirmation emails to all unconfirmed users (`mix pleroma.email send_confirmation_mails`) - Mix task option for force-unfollowing relays +- Media preview proxy (requires `ffmpeg` and `ImageMagick` to be installed and media proxy to be enabled; see `:media_preview_proxy` config for more details). +- Pleroma API: Importing the mutes users from CSV files. +- Experimental websocket-based federation between Pleroma instances. ### Changed @@ -23,11 +26,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Minimum lifetime for ephmeral activities changed to 10 minutes and made configurable (`:min_lifetime` option). - Introduced optional dependencies on `ffmpeg`, `ImageMagick`, `exiftool` software packages. Please refer to `docs/installation/optional/media_graphics_packages.md`. -### Added -- Media preview proxy (requires `ffmpeg` and `ImageMagick` to be installed and media proxy to be enabled; see `:media_preview_proxy` config for more details). -- Pleroma API: Importing the mutes users from CSV files. -- Experimental websocket-based federation between Pleroma instances. -
API Changes From ccd1e75e35e9b6d82f4f7f4768b624a8a07bd686 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 20 Oct 2020 02:36:45 +0200 Subject: [PATCH 18/18] CI: Install file-dev in alpine release targets --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e65cae9d8..06cf614c2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -217,7 +217,7 @@ amd64-musl: cache: *release-cache variables: *release-variables before_script: &before-release-musl - - apk add git gcc g++ musl-dev make cmake + - apk add git gcc g++ musl-dev make cmake file-dev - echo "import Mix.Config" > config/prod.secret.exs - mix local.hex --force - mix local.rebar --force