From 8efae57d67f327265176d21553ef57987fc540e8 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 21 Jan 2024 14:32:18 -0500 Subject: [PATCH 01/20] Dialyzer: suppress Mix.Task errors Callback info about the 'Elixir.Mix.Task' behaviour is not available. --- mix.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/mix.exs b/mix.exs index 794d3aa54b..a8eacc54be 100644 --- a/mix.exs +++ b/mix.exs @@ -10,6 +10,7 @@ def project do compilers: Mix.compilers(), elixirc_options: [warnings_as_errors: warnings_as_errors()], xref: [exclude: [:eldap]], + dialyzer: [plt_add_apps: [:mix]], start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), From 653b14e1c798bbddc34821fa56f32fef9c227f01 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 21 Jan 2024 14:40:14 -0500 Subject: [PATCH 02/20] Use config to control Uploader callback timeout --- config/config.exs | 2 ++ config/test.exs | 2 ++ lib/pleroma/uploaders/uploader.ex | 9 +-------- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/config/config.exs b/config/config.exs index 7ff3aaa22a..bb17ab145d 100644 --- a/config/config.exs +++ b/config/config.exs @@ -911,6 +911,8 @@ max_restarts: 3, streamer_registry: true +config :pleroma, Pleroma.Uploaders.Uploader, timeout: 30_000 + # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/config/test.exs b/config/test.exs index 28d0364c6d..40e93705df 100644 --- a/config/test.exs +++ b/config/test.exs @@ -170,6 +170,8 @@ streamer_registry: false, test_http_pools: true +config :pleroma, Pleroma.Uploaders.Uploader, timeout: 1_000 + if File.exists?("./config/test.secret.exs") do import_config "test.secret.exs" else diff --git a/lib/pleroma/uploaders/uploader.ex b/lib/pleroma/uploaders/uploader.ex index 23caaff1a4..3396fe06aa 100644 --- a/lib/pleroma/uploaders/uploader.ex +++ b/lib/pleroma/uploaders/uploader.ex @@ -5,8 +5,6 @@ defmodule Pleroma.Uploaders.Uploader do import Pleroma.Web.Gettext - @mix_env Mix.env() - @moduledoc """ Defines the contract to put and get an uploaded file to any backend. """ @@ -75,10 +73,5 @@ defp handle_callback(uploader, upload) do end end - defp callback_timeout do - case @mix_env do - :test -> 1_000 - _ -> 30_000 - end - end + defp callback_timeout, do: Application.get_env(:pleroma, __MODULE__)[:timeout] end From 6df93e61c4bb4ccacee7092cd20efe9add9a8500 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 21 Jan 2024 14:57:15 -0500 Subject: [PATCH 03/20] Use config to determine sending to the streamer registry instead of MIX_ENV compile time function definition --- lib/pleroma/web/streamer.ex | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index 0c9f04f828..35c015e241 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -20,7 +20,6 @@ defmodule Pleroma.Web.Streamer do alias Pleroma.Web.Plugs.OAuthScopesPlug alias Pleroma.Web.StreamerView - @mix_env Mix.env() @registry Pleroma.Web.StreamerRegistry def registry, do: @registry @@ -396,25 +395,20 @@ def close_streams_by_oauth_token(oauth_token) do end end - # In test environment, only return true if the registry is started. - # In benchmark environment, returns false. - # In any other environment, always returns true. - cond do - @mix_env == :test -> - def should_env_send? do - case Process.whereis(@registry) do - nil -> - false + # In dev/prod the streamer registry is expected to be started, so return true + # In test it is possible to have the registry started for a test so it will check + # In benchmark it will never find the process alive and return false + def should_env_send? do + if Application.get_env(:pleroma, Pleroma.Application)[:streamer_registry] do + true + else + case Process.whereis(@registry) do + nil -> + false - pid -> - Process.alive?(pid) - end + pid -> + Process.alive?(pid) end - - @mix_env == :benchmark -> - def should_env_send?, do: false - - true -> - def should_env_send?, do: true + end end end From eb4dd50f533380218bcde1a4107e2c0d38b4ec0d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 21 Jan 2024 14:57:29 -0500 Subject: [PATCH 04/20] Use config to control inclusion of test emoji --- config/test.exs | 2 ++ lib/pleroma/emoji/loader.ex | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/test.exs b/config/test.exs index 40e93705df..9d752bdf8e 100644 --- a/config/test.exs +++ b/config/test.exs @@ -172,6 +172,8 @@ config :pleroma, Pleroma.Uploaders.Uploader, timeout: 1_000 +config :pleroma, Pleroma.Emoji.Loader, test_emoji: true + if File.exists?("./config/test.secret.exs") do import_config "test.secret.exs" else diff --git a/lib/pleroma/emoji/loader.ex b/lib/pleroma/emoji/loader.ex index eb6f6816b3..b6e5443237 100644 --- a/lib/pleroma/emoji/loader.ex +++ b/lib/pleroma/emoji/loader.ex @@ -15,8 +15,6 @@ defmodule Pleroma.Emoji.Loader do require Logger - @mix_env Mix.env() - @type pattern :: Regex.t() | module() | String.t() @type patterns :: pattern() | [pattern()] @type group_patterns :: keyword(patterns()) @@ -79,7 +77,7 @@ def load do # for testing emoji.txt entries we do not want exposed in normal operation test_emoji = - if @mix_env == :test do + if Application.get_env(:pleroma, __MODULE__)[:test_emoji] do load_from_file("test/config/emoji.txt", emoji_groups) else [] From 38ebefce9c25cf59e6c9e95969712bd13fa79df3 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 21 Jan 2024 15:54:20 -0500 Subject: [PATCH 05/20] Announcement: fix dialyzer errors and add typespec for the changeset It was possible for this to raise (no_local_return) because the data key could be missing from the params --- lib/pleroma/announcement.ex | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/announcement.ex b/lib/pleroma/announcement.ex index d97c5e7282..5a3c710e8f 100644 --- a/lib/pleroma/announcement.ex +++ b/lib/pleroma/announcement.ex @@ -23,19 +23,21 @@ defmodule Pleroma.Announcement do timestamps(type: :utc_datetime) end - def change(struct, params \\ %{}) do - struct - |> cast(validate_params(struct, params), [:data, :starts_at, :ends_at, :rendered]) + @doc "Generates changeset for %Pleroma.Announcement{}" + @spec changeset(%__MODULE__{}, map()) :: %Ecto.Changeset{} + def changeset(announcement \\ %__MODULE__{}, params \\ %{data: %{}}) do + announcement + |> cast(validate_params(announcement, params), [:data, :starts_at, :ends_at, :rendered]) |> validate_required([:data]) end - defp validate_params(struct, params) do + defp validate_params(announcement, params) do base_data = %{ "content" => "", "all_day" => false } - |> Map.merge((struct && struct.data) || %{}) + |> Map.merge((announcement && announcement.data) || %{}) merged_data = Map.merge(base_data, params.data) @@ -61,13 +63,13 @@ def add_rendered_properties(params) do end def add(params) do - changeset = change(%__MODULE__{}, params) + changeset = changeset(%__MODULE__{}, params) Repo.insert(changeset) end def update(announcement, params) do - changeset = change(announcement, params) + changeset = changeset(announcement, params) Repo.update(changeset) end From bff47479a7a2344bc8e7e1caf1c876ea484b3134 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 15:34:30 -0500 Subject: [PATCH 06/20] Exile: fix for MacOS dev environments --- changelog.d/exile-macos.skip | 0 mix.exs | 2 +- mix.lock | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 changelog.d/exile-macos.skip diff --git a/changelog.d/exile-macos.skip b/changelog.d/exile-macos.skip new file mode 100644 index 0000000000..e69de29bb2 diff --git a/mix.exs b/mix.exs index a8eacc54be..d332900de0 100644 --- a/mix.exs +++ b/mix.exs @@ -187,7 +187,7 @@ defp deps do {:blurhash, "~> 0.1.0", hex: :rinpatch_blurhash}, {:exile, git: "https://git.pleroma.social/pleroma/elixir-libraries/exile.git", - ref: "486f0695f3c8855343b46acdba7e45941487c275"}, + ref: "0d6337cf68e7fbc8a093cae000955aa93b067f91"}, ## dev & test {:ex_doc, "~> 0.22", only: :dev, runtime: false}, diff --git a/mix.lock b/mix.lock index 6f5dce1166..ba1ac2c9d2 100644 --- a/mix.lock +++ b/mix.lock @@ -46,7 +46,7 @@ "ex_doc": {:hex, :ex_doc, "0.29.4", "6257ecbb20c7396b1fe5accd55b7b0d23f44b6aa18017b415cb4c2b91d997729", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2c6699a737ae46cb61e4ed012af931b57b699643b24dabe2400a8168414bc4f5"}, "ex_machina": {:hex, :ex_machina, "2.7.0", "b792cc3127fd0680fecdb6299235b4727a4944a09ff0fa904cc639272cd92dc7", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm", "419aa7a39bde11894c87a615c4ecaa52d8f107bbdd81d810465186f783245bf8"}, "ex_syslogger": {:hex, :ex_syslogger, "1.5.2", "72b6aa2d47a236e999171f2e1ec18698740f40af0bd02c8c650bf5f1fd1bac79", [:mix], [{:poison, ">= 1.5.0", [hex: :poison, repo: "hexpm", optional: true]}, {:syslog, "~> 1.1.0", [hex: :syslog, repo: "hexpm", optional: false]}], "hexpm", "ab9fab4136dbc62651ec6f16fa4842f10cf02ab4433fa3d0976c01be99398399"}, - "exile": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/exile.git", "486f0695f3c8855343b46acdba7e45941487c275", [ref: "486f0695f3c8855343b46acdba7e45941487c275"]}, + "exile": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/exile.git", "0d6337cf68e7fbc8a093cae000955aa93b067f91", [ref: "0d6337cf68e7fbc8a093cae000955aa93b067f91"]}, "expo": {:hex, :expo, "0.4.1", "1c61d18a5df197dfda38861673d392e642649a9cef7694d2f97a587b2cfb319b", [:mix], [], "hexpm", "2ff7ba7a798c8c543c12550fa0e2cbc81b95d4974c65855d8d15ba7b37a1ce47"}, "fast_html": {:hex, :fast_html, "2.0.5", "c61760340606c1077ff1f196f17834056cb1dd3d5cb92a9f2cabf28bc6221c3c", [:make, :mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}], "hexpm", "605f4f4829443c14127694ebabb681778712ceecb4470ec32aa31012330e6506"}, "fast_sanitize": {:hex, :fast_sanitize, "0.2.3", "67b93dfb34e302bef49fec3aaab74951e0f0602fd9fa99085987af05bd91c7a5", [:mix], [{:fast_html, "~> 2.0", [hex: :fast_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "e8ad286d10d0386e15d67d0ee125245ebcfbc7d7290b08712ba9013c8c5e56e2"}, From 13618562138375a55a1286c15c82b011594a5fbd Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 17:11:22 -0500 Subject: [PATCH 07/20] Pleroma.User.Backup: fix some dialyzer errors lib/pleroma/user/backup.ex:207:call The function call will not succeed. :zip.create( string(), [:"\"actor.json\"", :"\"outbox.json\"", :"\"likes.json\"", :"\"bookmarks.json\""], [{:cwd, binary()}, ...] ) will never return since the success typing is: ( atom() | [atom() | [any()] | char()], [ atom() | [atom() | [any()] | char()] | {atom() | [atom() | [any()] | char()], binary()} | {atom() | [atom() | [any()] | char()], binary(), {:file_info, :undefined | non_neg_integer(), :device | :directory | :other | :regular | :symlink | :undefined, :none | :read | :read_write | :undefined | :write, :undefined | non_neg_integer() | {_, _}, :undefined | non_neg_integer() | {_, _}, :undefined | non_neg_integer() | {_, _}, :undefined | non_neg_integer(), :undefined | non_neg_integer(), :undefined | non_neg_integer(), :undefined | non_neg_integer(), :undefined | non_neg_integer(), :undefined | non_neg_integer(), :undefined | non_neg_integer()}} ], [ :cooked | :memory | :verbose | {:comment, string()} | {:compress, :all | [[any()]] | {:add, [any()]} | {:del, [any()]}} | {:cwd, string()} | {:uncompress, :all | [[any()]] | {:add, [any()]} | {:del, [any()]}} ] ) :: {:error, _} | {:ok, atom() | [atom() | [any()] | char()] | {atom() | [atom() | [any()] | char()], binary()}} and the contract is (name, fileList, options) :: retValue when name: :file.name(), fileList: [:FileSpec], fileSpec: :file.name() | {:file.name(), binary()} | {:file.name(), binary(), :file.file_info()}, options: [:Option], option: create_option(), retValue: {:ok, FileName :: filename()} | {:ok, {FileName :: filename(), binary()}} | {:error, Reason :: term()} --- lib/pleroma/user/backup.ex | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/user/backup.ex b/lib/pleroma/user/backup.ex index 74e0ec0738..b7f00bbf7f 100644 --- a/lib/pleroma/user/backup.ex +++ b/lib/pleroma/user/backup.ex @@ -22,6 +22,8 @@ defmodule Pleroma.User.Backup do alias Pleroma.Web.ActivityPub.UserView alias Pleroma.Workers.BackupWorker + @type t :: %__MODULE__{} + schema "backups" do field(:content_type, :string) field(:file_name, :string) @@ -195,6 +197,7 @@ defp wait_backup(backup, current_processed, task) do end @files ['actor.json', 'outbox.json', 'likes.json', 'bookmarks.json'] + @spec export(Pleroma.User.Backup.t(), pid()) :: {:ok, String.t()} | :error def export(%__MODULE__{} = backup, caller_pid) do backup = Repo.preload(backup, :user) dir = backup_tempdir(backup) @@ -204,9 +207,11 @@ def export(%__MODULE__{} = backup, caller_pid) do :ok <- statuses(dir, backup.user, caller_pid), :ok <- likes(dir, backup.user, caller_pid), :ok <- bookmarks(dir, backup.user, caller_pid), - {:ok, zip_path} <- :zip.create(String.to_charlist(dir <> ".zip"), @files, cwd: dir), + {:ok, zip_path} <- :zip.create(backup.file_name, @files, cwd: dir), {:ok, _} <- File.rm_rf(dir) do - {:ok, to_string(zip_path)} + {:ok, zip_path} + else + _ -> :error end end @@ -382,6 +387,8 @@ def do_process(backup, current_pid) do [:file_size, :processed, :state] ) |> Repo.update() + else + e -> {:error, e} end end end From 40feac086f3efd463f7aeb630adf55a0a1fa4365 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 17:13:45 -0500 Subject: [PATCH 08/20] Pleroma.User: fix dialyzer errors lib/pleroma/user.ex:1514:unknown_type Unknown type: Pleroma.UserRelationship.t/0. lib/pleroma/user.ex:2629:unknown_type Unknown type: Pleroma.UserRelationship.t/0. lib/pleroma/user.ex:2638:unknown_type Unknown type: Pleroma.UserRelationship.t/0. --- lib/pleroma/user_relationship.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pleroma/user_relationship.ex b/lib/pleroma/user_relationship.ex index fbecf31292..82fcc1cdd6 100644 --- a/lib/pleroma/user_relationship.ex +++ b/lib/pleroma/user_relationship.ex @@ -14,6 +14,8 @@ defmodule Pleroma.UserRelationship do alias Pleroma.User alias Pleroma.UserRelationship + @type t :: %__MODULE__{} + schema "user_relationships" do belongs_to(:source, User, type: FlakeId.Ecto.CompatType) belongs_to(:target, User, type: FlakeId.Ecto.CompatType) From 10f3a2833fe6f6909b6540343955c05392763d17 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 17:17:13 -0500 Subject: [PATCH 09/20] Pleroma.User.Query: fix dialyzer error lib/pleroma/user/query.ex:74:unknown_type Unknown type: Query.t/0. --- lib/pleroma/user/query.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/user/query.ex b/lib/pleroma/user/query.ex index 874e8ec2b4..cd95864521 100644 --- a/lib/pleroma/user/query.ex +++ b/lib/pleroma/user/query.ex @@ -71,7 +71,7 @@ defmodule Pleroma.User.Query do @equal_criteria [:email] @contains_criteria [:ap_id, :nickname] - @spec build(Query.t(), criteria()) :: Query.t() + @spec build(Ecto.Query.t(), criteria()) :: Ecto.Query.t() def build(query \\ base_query(), criteria) do prepare_query(query, criteria) end From 39da451b6d76bb84a7e070525a1946aa1c80bc51 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 17:20:21 -0500 Subject: [PATCH 10/20] Pleroma.Web.ActivityPub.Builder: fix dialyzer errors lib/pleroma/web/activity_pub/builder.ex:35:unknown_type Unknown type: Activity.t/0. lib/pleroma/web/activity_pub/builder.ex:40:unknown_type Unknown type: Activity.t/0. lib/pleroma/web/activity_pub/builder.ex:144:unknown_type Unknown type: Activity.t/0. ________________________________________________________________________________ lib/pleroma/web/activity_pub/builder.ex:204:unknown_type Unknown type: Pleroma.Web.CommonAPI.ActivityDraft.t/0. --- lib/pleroma/web/activity_pub/builder.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pleroma/web/activity_pub/builder.ex b/lib/pleroma/web/activity_pub/builder.ex index eb0bb0e332..404975757e 100644 --- a/lib/pleroma/web/activity_pub/builder.ex +++ b/lib/pleroma/web/activity_pub/builder.ex @@ -9,6 +9,7 @@ defmodule Pleroma.Web.ActivityPub.Builder do This module encodes our addressing policies and general shape of our objects. """ + alias Pleroma.Activity alias Pleroma.Emoji alias Pleroma.Object alias Pleroma.User From 36355d3ed971e56274f7b09b0c8ce7d3f5c0da14 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 17:22:36 -0500 Subject: [PATCH 11/20] Pleroma.Web.ActivityPub.Builder: fix dialyzer error lib/pleroma/web/activity_pub/builder.ex:205:unknown_type Unknown type: Pleroma.Web.CommonAPI.ActivityDraft.t/0. --- lib/pleroma/web/common_api/activity_draft.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pleroma/web/common_api/activity_draft.ex b/lib/pleroma/web/common_api/activity_draft.ex index 8910ad5b8a..bc46a8a364 100644 --- a/lib/pleroma/web/common_api/activity_draft.ex +++ b/lib/pleroma/web/common_api/activity_draft.ex @@ -14,6 +14,8 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do import Pleroma.Web.Gettext import Pleroma.Web.Utils.Guards, only: [not_empty_string: 1] + @type t :: %__MODULE__{} + defstruct valid?: true, errors: [], user: nil, From c74c5f479aff38c67c3c9d0b3d0822f06a3d2f9c Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 17:24:01 -0500 Subject: [PATCH 12/20] Pleroma.Migrators.Support.BaseMigratorState: fix dialyzer error lib/pleroma/migrators/support/base_migrator_state.ex:10:unknown_type Unknown type: Pleroma.DataMigration.t/0. --- lib/pleroma/data_migration.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/pleroma/data_migration.ex b/lib/pleroma/data_migration.ex index 8451678fc4..be4bf64899 100644 --- a/lib/pleroma/data_migration.ex +++ b/lib/pleroma/data_migration.ex @@ -12,6 +12,8 @@ defmodule Pleroma.DataMigration do import Ecto.Changeset import Ecto.Query + @type t :: %__MODULE__{} + schema "data_migrations" do field(:name, :string) field(:state, State, default: :pending) From 65d49ac090bfe70cfea9b00bae79f9cba5c50c43 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 17:26:04 -0500 Subject: [PATCH 13/20] Pleroma.HTTP.AdapterHelper: fix dialyzer errors lib/pleroma/http/adapter_helper.ex:18:unknown_type Unknown type: Connection.host/0. lib/pleroma/http/adapter_helper.ex:19:unknown_type Unknown type: Connection.host/0. lib/pleroma/http/adapter_helper.ex:19:unknown_type Unknown type: Connection.proxy_type/0. --- lib/pleroma/http/adapter_helper.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/http/adapter_helper.ex b/lib/pleroma/http/adapter_helper.ex index e9bb2023a8..dcb27a29d0 100644 --- a/lib/pleroma/http/adapter_helper.ex +++ b/lib/pleroma/http/adapter_helper.ex @@ -15,8 +15,8 @@ defmodule Pleroma.HTTP.AdapterHelper do require Logger @type proxy :: - {Connection.host(), pos_integer()} - | {Connection.proxy_type(), Connection.host(), pos_integer()} + {host(), pos_integer()} + | {proxy_type(), host(), pos_integer()} @callback options(keyword(), URI.t()) :: keyword() From 6ce7011a2e07d9e8e7d7fdc1a6fe340bac6e1404 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 17:48:55 -0500 Subject: [PATCH 14/20] Pleroma.Gun.ConnectionPool.WorkerSupervisor: fix dialyzer error lib/pleroma/gun/connection_pool/worker_supervisor.ex:24:guard_fail The guard clause: when _ :: true === nil can never succeed. --- lib/pleroma/gun/connection_pool/worker_supervisor.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/gun/connection_pool/worker_supervisor.ex b/lib/pleroma/gun/connection_pool/worker_supervisor.ex index d26a70be3e..b2be4ff873 100644 --- a/lib/pleroma/gun/connection_pool/worker_supervisor.ex +++ b/lib/pleroma/gun/connection_pool/worker_supervisor.ex @@ -21,7 +21,7 @@ def init(_opts) do def start_worker(opts, retry \\ false) do case DynamicSupervisor.start_child(__MODULE__, {Pleroma.Gun.ConnectionPool.Worker, opts}) do {:error, :max_children} -> - if retry or free_pool() == :error do + if Enum.any?([retry, free_pool()], &match?(&1, :error)) do :telemetry.execute([:pleroma, :connection_pool, :provision_failure], %{opts: opts}) {:error, :pool_full} else From a7fa6f18dc7919b3a441fcea2a35e1c313f89555 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 18:05:41 -0500 Subject: [PATCH 15/20] Pleroma.Migrators.Support.BaseMigrator: Fix dialyzer errors lib/pleroma/migrators/context_objects_deletion_migrator.ex:13:exact_eq The test :error | float() == 0 can never evaluate to 'true'. lib/pleroma/migrators/hashtags_table_migrator.ex:13:exact_eq The test :error | float() == 0 can never evaluate to 'true'. --- lib/pleroma/migrators/support/base_migrator.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/migrators/support/base_migrator.ex b/lib/pleroma/migrators/support/base_migrator.ex index ce88caac71..76a5d45907 100644 --- a/lib/pleroma/migrators/support/base_migrator.ex +++ b/lib/pleroma/migrators/support/base_migrator.ex @@ -188,10 +188,11 @@ defp update_status(status, message \\ nil) do end defp fault_rate do - with failures_count when is_integer(failures_count) <- failures_count() do + with failures_count when is_integer(failures_count) <- failures_count(), + true <- failures_count > 0 do failures_count / Enum.max([get_stat(:affected_count, 0), 1]) else - _ -> :error + _ -> 0 end end From 5f71928f6b12584ba456cbeb8a92c38078a468ae Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 18:09:15 -0500 Subject: [PATCH 16/20] MRF.InlineQuotePolicy: fix dialyzer error lib/pleroma/web/activity_pub/mrf/inline_quote_policy.ex:60:callback_type_mismatch Type mismatch for @callback config_description/0 in Pleroma.Web.ActivityPub.MRF.Policy behaviour. Expected type: %{ :description => binary(), :key => atom(), :label => binary(), :related_policy => binary(), :children => [map()] } Actual type: %{ :children => [ %{ :description => <<_::808>>, :key => :template, :suggestions => [any(), ...], :type => :string }, ... ], :description => <<_::336>>, :key => :mrf_inline_quote, :label => <<_::184>>, :related_policy => <<_::360>>, :type => :group } --- lib/pleroma/web/activity_pub/mrf/inline_quote_policy.ex | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/mrf/inline_quote_policy.ex b/lib/pleroma/web/activity_pub/mrf/inline_quote_policy.ex index 171b22c5e2..b7a01c27c2 100644 --- a/lib/pleroma/web/activity_pub/mrf/inline_quote_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/inline_quote_policy.ex @@ -62,7 +62,6 @@ def config_description do key: :mrf_inline_quote, related_policy: "Pleroma.Web.ActivityPub.MRF.InlineQuotePolicy", label: "MRF Inline Quote Policy", - type: :group, description: "Force quote url to appear in post content.", children: [ %{ From 0dd65246eac9c1c738cc4ea47798caec1797ad6d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 18:11:15 -0500 Subject: [PATCH 17/20] MRF.HashtagPolicy: fix dialyzer error lib/pleroma/web/activity_pub/mrf/hashtag_policy.ex:87:exact_eq The test <<_::32>> == <<_::48>> can never evaluate to 'true'. --- changelog.d/mrf_hashtags.fix | 1 + lib/pleroma/web/activity_pub/mrf/hashtag_policy.ex | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/mrf_hashtags.fix diff --git a/changelog.d/mrf_hashtags.fix b/changelog.d/mrf_hashtags.fix new file mode 100644 index 0000000000..c44c2376b4 --- /dev/null +++ b/changelog.d/mrf_hashtags.fix @@ -0,0 +1 @@ +Federated timeline removal of hashtags via MRF HashtagPolicy diff --git a/lib/pleroma/web/activity_pub/mrf/hashtag_policy.ex b/lib/pleroma/web/activity_pub/mrf/hashtag_policy.ex index d13d980cc1..fdb9a9dba8 100644 --- a/lib/pleroma/web/activity_pub/mrf/hashtag_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/hashtag_policy.ex @@ -84,7 +84,7 @@ def filter(%{"type" => type, "object" => object} = message) when type in ["Creat if hashtags != [] do with {:ok, message} <- check_reject(message, hashtags), {:ok, message} <- - (if "type" == "Create" do + (if type == "Create" do check_ftl_removal(message, hashtags) else {:ok, message} From 115b2ad63875b1dc92d194e7e17b6ccde3b3d395 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 18:27:33 -0500 Subject: [PATCH 18/20] MRF.KeywordPolicy: fix dialyzer error lib/pleroma/web/activity_pub/mrf/keyword_policy.ex:13:neg_guard_fail Guard test: not is_binary(_string :: binary()) can never succeed. --- lib/pleroma/web/activity_pub/mrf/keyword_policy.ex | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/pleroma/web/activity_pub/mrf/keyword_policy.ex b/lib/pleroma/web/activity_pub/mrf/keyword_policy.ex index 874fe9ab96..729da4e9c9 100644 --- a/lib/pleroma/web/activity_pub/mrf/keyword_policy.ex +++ b/lib/pleroma/web/activity_pub/mrf/keyword_policy.ex @@ -10,15 +10,12 @@ defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicy do @moduledoc "Reject or Word-Replace messages with a keyword or regex" @behaviour Pleroma.Web.ActivityPub.MRF.Policy - defp string_matches?(string, _) when not is_binary(string) do - false - end defp string_matches?(string, pattern) when is_binary(pattern) do String.contains?(string, pattern) end - defp string_matches?(string, pattern) do + defp string_matches?(string, %Regex{} = pattern) do String.match?(string, pattern) end From 138b3cb608f7b87ec1c51d524db4e98a4c6d4bcf Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 18:32:22 -0500 Subject: [PATCH 19/20] Clear up missing function dialyzer errors for :eldap --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index d332900de0..a13c89c04b 100644 --- a/mix.exs +++ b/mix.exs @@ -10,7 +10,7 @@ def project do compilers: Mix.compilers(), elixirc_options: [warnings_as_errors: warnings_as_errors()], xref: [exclude: [:eldap]], - dialyzer: [plt_add_apps: [:mix]], + dialyzer: [plt_add_apps: [:mix, :eldap]], start_permanent: Mix.env() == :prod, aliases: aliases(), deps: deps(), From 3a8594e92759aa10d3e6ad5b4a1892beb6d74cc9 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 22 Jan 2024 18:35:07 -0500 Subject: [PATCH 20/20] MastodonAPI.Controller.StatusController: fix dialyzer error lib/pleroma/web/mastodon_api/controllers/status_controller.ex:333:pattern_match The pattern can never match the type. Pattern: {:ok, _activity} Type: {:error, _} --- lib/pleroma/web/common_api.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/common_api.ex b/lib/pleroma/web/common_api.ex index dfc0a625df..61d9e1c7c2 100644 --- a/lib/pleroma/web/common_api.ex +++ b/lib/pleroma/web/common_api.ex @@ -505,7 +505,7 @@ defp activity_is_public(activity) do end end - @spec unpin(String.t(), User.t()) :: {:ok, User.t()} | {:error, term()} + @spec unpin(String.t(), User.t()) :: {:ok, Activity.t()} | {:error, term()} def unpin(id, user) do with %Activity{} = activity <- create_activity_by_id(id), {:ok, unpin_data, _} <- Builder.unpin(user, activity.object),