Merge branch 'develop' into paradedb-search-backend
This commit is contained in:
commit
865ddfdce0
26 changed files with 264 additions and 99 deletions
1
changelog.d/database-config-whitelist.add
Normal file
1
changelog.d/database-config-whitelist.add
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add reasonable defaults for :database_config_whitelist
|
||||||
0
changelog.d/mix-exs-update.skip
Normal file
0
changelog.d/mix-exs-update.skip
Normal file
0
changelog.d/plug-test-typo.skip
Normal file
0
changelog.d/plug-test-typo.skip
Normal file
1
changelog.d/update-comment.ignore
Normal file
1
changelog.d/update-comment.ignore
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Update comment for prepare_object, rename prepare_outgoing
|
||||||
|
|
@ -969,6 +969,15 @@ config :pleroma, Pleroma.Search.QdrantSearch,
|
||||||
vectors: %{size: 384, distance: "Cosine"}
|
vectors: %{size: 384, distance: "Cosine"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config :pleroma, :database_config_whitelist, [
|
||||||
|
{:pleroma},
|
||||||
|
{:cors_plug},
|
||||||
|
{:ex_aws, :s3},
|
||||||
|
{:mime},
|
||||||
|
{:prometheus, Pleroma.Web.Endpoint.MetricsExporter},
|
||||||
|
{:web_push_encryption, :vapid_details}
|
||||||
|
]
|
||||||
|
|
||||||
# Import environment specific config. This must remain at the bottom
|
# Import environment specific config. This must remain at the bottom
|
||||||
# of this file so it overrides the configuration defined above.
|
# of this file so it overrides the configuration defined above.
|
||||||
import_config "#{Mix.env()}.exs"
|
import_config "#{Mix.env()}.exs"
|
||||||
|
|
|
||||||
|
|
@ -170,3 +170,17 @@ This forcibly removes any enabled MRF that does not exist and will fix the abili
|
||||||
```sh
|
```sh
|
||||||
mix pleroma.config fix_mrf_policies
|
mix pleroma.config fix_mrf_policies
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Remove non-whitelisted configs from the database
|
||||||
|
|
||||||
|
This removes any configuration value that is not explicitly whitelisted by `:pleroma, :database_config_whitelist`. Might be useful after updating the whitelist.
|
||||||
|
|
||||||
|
=== "OTP"
|
||||||
|
```sh
|
||||||
|
./bin/pleroma_ctl config filter_whitelisted
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
```sh
|
||||||
|
mix pleroma.config filter_whitelisted
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -1132,8 +1132,9 @@ Boolean, enables/disables in-database configuration. Read [Transferring the conf
|
||||||
|
|
||||||
List of valid configuration sections which are allowed to be configured from the
|
List of valid configuration sections which are allowed to be configured from the
|
||||||
database. Settings stored in the database before the whitelist is configured are
|
database. Settings stored in the database before the whitelist is configured are
|
||||||
still applied, so it is suggested to only use the whitelist on instances that
|
still applied. Consider running the `mix pleroma.config filter_whitelisted` task
|
||||||
have not migrated the config to the database.
|
after updating the whitelist. Read [Remove non-whitelisted configs from the database](../administration/CLI_tasks/config.md#remove-non-whitelisted-configs-from-the-database)
|
||||||
|
for more information.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```elixir
|
```elixir
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,61 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Removes non-whitelisted configuration sections
|
||||||
|
def run(["filter_whitelisted" | rest]) do
|
||||||
|
{options, [], []} =
|
||||||
|
OptionParser.parse(
|
||||||
|
rest,
|
||||||
|
strict: [force: :boolean],
|
||||||
|
aliases: [f: :force]
|
||||||
|
)
|
||||||
|
|
||||||
|
force = Keyword.get(options, :force, false)
|
||||||
|
|
||||||
|
start_pleroma()
|
||||||
|
|
||||||
|
whitelisted_configs = Pleroma.Config.get(:database_config_whitelist)
|
||||||
|
|
||||||
|
if whitelisted_configs in [nil, false] do
|
||||||
|
shell_error("No unwanted settings in ConfigDB. No changes made.")
|
||||||
|
else
|
||||||
|
whitelisted_groups =
|
||||||
|
whitelisted_configs
|
||||||
|
|> Enum.filter(fn
|
||||||
|
{_group} -> true
|
||||||
|
_ -> false
|
||||||
|
end)
|
||||||
|
|> Enum.map(fn {group} -> group end)
|
||||||
|
|
||||||
|
whitelisted_keys =
|
||||||
|
whitelisted_configs
|
||||||
|
|> Enum.filter(fn
|
||||||
|
{_group, _key} -> true
|
||||||
|
_ -> false
|
||||||
|
end)
|
||||||
|
|
||||||
|
filtered =
|
||||||
|
from(c in ConfigDB)
|
||||||
|
|> Repo.all()
|
||||||
|
|> Enum.filter(¬_whitelisted?(&1, whitelisted_groups, whitelisted_keys))
|
||||||
|
|
||||||
|
if not Enum.empty?(filtered) do
|
||||||
|
shell_info("The following settings will be removed from ConfigDB:\n")
|
||||||
|
Enum.each(filtered, &dump(&1))
|
||||||
|
|
||||||
|
if force or shell_prompt("Are you sure you want to continue?", "n") in ~w(Yn Y y) do
|
||||||
|
filtered_ids = Enum.map(filtered, fn %{id: id} -> id end)
|
||||||
|
|
||||||
|
Repo.delete_all(from(c in ConfigDB, where: c.id in ^filtered_ids))
|
||||||
|
else
|
||||||
|
shell_error("No changes made.")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
shell_error("No unwanted settings in ConfigDB. No changes made.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@spec migrate_to_db(Path.t() | nil) :: any()
|
@spec migrate_to_db(Path.t() | nil) :: any()
|
||||||
def migrate_to_db(file_path \\ nil) do
|
def migrate_to_db(file_path \\ nil) do
|
||||||
with :ok <- Pleroma.Config.DeprecationWarnings.warn() do
|
with :ok <- Pleroma.Config.DeprecationWarnings.warn() do
|
||||||
|
|
@ -434,4 +489,9 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
Ecto.Adapters.SQL.query!(Repo, "TRUNCATE config;")
|
Ecto.Adapters.SQL.query!(Repo, "TRUNCATE config;")
|
||||||
Ecto.Adapters.SQL.query!(Repo, "ALTER SEQUENCE config_id_seq RESTART;")
|
Ecto.Adapters.SQL.query!(Repo, "ALTER SEQUENCE config_id_seq RESTART;")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp not_whitelisted?(%{group: group, key: key}, whitelisted_groups, whitelisted_keys) do
|
||||||
|
not Enum.member?(whitelisted_groups, group) and
|
||||||
|
not Enum.member?(whitelisted_keys, {group, key})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -342,7 +342,7 @@ defmodule Pleroma.User.Backup do
|
||||||
dir,
|
dir,
|
||||||
"outbox",
|
"outbox",
|
||||||
fn a ->
|
fn a ->
|
||||||
with {:ok, activity} <- Transmogrifier.prepare_outgoing(a.data) do
|
with {:ok, activity} <- Transmogrifier.prepare_activity(a.data) do
|
||||||
{:ok, Map.delete(activity, "@context")}
|
{:ok, Map.delete(activity, "@context")}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
||||||
Determine if an activity can be represented by running it through Transmogrifier.
|
Determine if an activity can be represented by running it through Transmogrifier.
|
||||||
"""
|
"""
|
||||||
def representable?(%Activity{} = activity) do
|
def representable?(%Activity{} = activity) do
|
||||||
with {:ok, _data} <- @transmogrifier_impl.prepare_outgoing(activity.data) do
|
with {:ok, _data} <- @transmogrifier_impl.prepare_activity(activity.data) do
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
_e ->
|
_e ->
|
||||||
|
|
@ -102,14 +102,14 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
||||||
Logger.debug("Federating #{ap_id} to #{inbox}")
|
Logger.debug("Federating #{ap_id} to #{inbox}")
|
||||||
uri = %{path: path} = URI.parse(inbox)
|
uri = %{path: path} = URI.parse(inbox)
|
||||||
|
|
||||||
{:ok, data} = @transmogrifier_impl.prepare_outgoing(activity.data)
|
{:ok, data} = @transmogrifier_impl.prepare_activity(activity.data)
|
||||||
|
|
||||||
{actor, data} =
|
{actor, data} =
|
||||||
with {_, false} <- {:actor_changed?, data["actor"] != activity.data["actor"]} do
|
with {_, false} <- {:actor_changed?, data["actor"] != activity.data["actor"]} do
|
||||||
{actor, data}
|
{actor, data}
|
||||||
else
|
else
|
||||||
{:actor_changed?, true} ->
|
{:actor_changed?, true} ->
|
||||||
# If prepare_outgoing changes the actor, re-get it from the db
|
# If prepare_activity changes the actor, re-get it from the db
|
||||||
new_actor = User.get_cached_by_ap_id(data["actor"])
|
new_actor = User.get_cached_by_ap_id(data["actor"])
|
||||||
{new_actor, data}
|
{new_actor, data}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -783,7 +783,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
|
|
||||||
def set_replies(obj_data), do: obj_data
|
def set_replies(obj_data), do: obj_data
|
||||||
|
|
||||||
# Prepares the object of an outgoing create activity.
|
# Prepares and sanitizes the object for federation.
|
||||||
def prepare_object(object) do
|
def prepare_object(object) do
|
||||||
object
|
object
|
||||||
|> add_hashtags
|
|> add_hashtags
|
||||||
|
|
@ -824,7 +824,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
# internal -> Mastodon
|
# internal -> Mastodon
|
||||||
# """
|
# """
|
||||||
|
|
||||||
def prepare_outgoing(%{"type" => activity_type, "object" => object_id} = data)
|
def prepare_activity(%{"type" => activity_type, "object" => object_id} = data)
|
||||||
when activity_type in ["Create", "Listen"] do
|
when activity_type in ["Create", "Listen"] do
|
||||||
object =
|
object =
|
||||||
object_id
|
object_id
|
||||||
|
|
@ -840,7 +840,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
{:ok, data}
|
{:ok, data}
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_outgoing(%{"type" => "Update", "object" => %{"type" => objtype} = object} = data)
|
def prepare_activity(%{"type" => "Update", "object" => %{"type" => objtype} = object} = data)
|
||||||
when objtype in Pleroma.Constants.updatable_object_types() do
|
when objtype in Pleroma.Constants.updatable_object_types() do
|
||||||
data =
|
data =
|
||||||
data
|
data
|
||||||
|
|
@ -851,7 +851,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
{:ok, data}
|
{:ok, data}
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_outgoing(%{"type" => "Update", "object" => %{"type" => objtype} = object} = data)
|
def prepare_activity(%{"type" => "Update", "object" => %{"type" => objtype} = object} = data)
|
||||||
when objtype in Pleroma.Constants.actor_types() do
|
when objtype in Pleroma.Constants.actor_types() do
|
||||||
object =
|
object =
|
||||||
object
|
object
|
||||||
|
|
@ -868,11 +868,11 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
{:ok, data}
|
{:ok, data}
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_outgoing(%{"type" => "Update", "object" => %{}} = data) do
|
def prepare_activity(%{"type" => "Update", "object" => %{}} = data) do
|
||||||
raise "Requested to serve an Update for non-updateable object type: #{inspect(data)}"
|
raise "Requested to serve an Update for non-updateable object type: #{inspect(data)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_outgoing(%{"type" => "Announce", "actor" => ap_id, "object" => object_id} = data) do
|
def prepare_activity(%{"type" => "Announce", "actor" => ap_id, "object" => object_id} = data) do
|
||||||
object =
|
object =
|
||||||
object_id
|
object_id
|
||||||
|> Object.normalize(fetch: false)
|
|> Object.normalize(fetch: false)
|
||||||
|
|
@ -895,7 +895,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
|
|
||||||
# Mastodon Accept/Reject requires a non-normalized object containing the actor URIs,
|
# Mastodon Accept/Reject requires a non-normalized object containing the actor URIs,
|
||||||
# because of course it does.
|
# because of course it does.
|
||||||
def prepare_outgoing(%{"type" => "Accept"} = data) do
|
def prepare_activity(%{"type" => "Accept"} = data) do
|
||||||
with follow_activity <- Activity.normalize(data["object"]) do
|
with follow_activity <- Activity.normalize(data["object"]) do
|
||||||
object = %{
|
object = %{
|
||||||
"actor" => follow_activity.actor,
|
"actor" => follow_activity.actor,
|
||||||
|
|
@ -913,7 +913,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_outgoing(%{"type" => "Reject"} = data) do
|
def prepare_activity(%{"type" => "Reject"} = data) do
|
||||||
with follow_activity <- Activity.normalize(data["object"]) do
|
with follow_activity <- Activity.normalize(data["object"]) do
|
||||||
object = %{
|
object = %{
|
||||||
"actor" => follow_activity.actor,
|
"actor" => follow_activity.actor,
|
||||||
|
|
@ -931,7 +931,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_outgoing(%{"type" => "Flag"} = data) do
|
def prepare_activity(%{"type" => "Flag"} = data) do
|
||||||
with {:ok, stripped_activity} <- Utils.strip_report_status_data(data),
|
with {:ok, stripped_activity} <- Utils.strip_report_status_data(data),
|
||||||
stripped_activity <- Utils.maybe_anonymize_reporter(stripped_activity),
|
stripped_activity <- Utils.maybe_anonymize_reporter(stripped_activity),
|
||||||
stripped_activity <- Map.merge(stripped_activity, Utils.make_json_ld_header()) do
|
stripped_activity <- Map.merge(stripped_activity, Utils.make_json_ld_header()) do
|
||||||
|
|
@ -939,7 +939,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_outgoing(%{"type" => _type} = data) do
|
def prepare_activity(%{"type" => _type} = data) do
|
||||||
data =
|
data =
|
||||||
data
|
data
|
||||||
|> strip_internal_fields
|
|> strip_internal_fields
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,5 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.API do
|
||||||
Behaviour for the subset of Transmogrifier used by Publisher.
|
Behaviour for the subset of Transmogrifier used by Publisher.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@callback prepare_outgoing(map()) :: {:ok, map()} | {:error, term()}
|
@callback prepare_activity(map()) :: {:ok, map()} | {:error, term()}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectView do
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("object.json", %{object: %Activity{} = activity}) do
|
def render("object.json", %{object: %Activity{} = activity}) do
|
||||||
{:ok, ap_data} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, ap_data} = Transmogrifier.prepare_activity(activity.data)
|
||||||
ap_data
|
ap_data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
||||||
}) do
|
}) do
|
||||||
collection =
|
collection =
|
||||||
Enum.map(activities, fn activity ->
|
Enum.map(activities, fn activity ->
|
||||||
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, data} = Transmogrifier.prepare_activity(activity.data)
|
||||||
data
|
data
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,8 @@ defmodule Pleroma.Web.AdminAPI.ConfigController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp whitelisted_config?(":pleroma", ":database_config_whitelist"), do: false
|
||||||
|
|
||||||
defp whitelisted_config?(group, key) do
|
defp whitelisted_config?(group, key) do
|
||||||
if whitelisted_configs = Config.get(:database_config_whitelist) do
|
if whitelisted_configs = Config.get(:database_config_whitelist) do
|
||||||
Enum.any?(whitelisted_configs, fn
|
Enum.any?(whitelisted_configs, fn
|
||||||
|
|
|
||||||
86
mix.exs
86
mix.exs
|
|
@ -114,7 +114,7 @@ defmodule Pleroma.Mixfile do
|
||||||
if Version.match?(System.version(), "<1.15.0-rc.0") do
|
if Version.match?(System.version(), "<1.15.0-rc.0") do
|
||||||
[]
|
[]
|
||||||
else
|
else
|
||||||
[{:logger_backends, "~> 1.0"}]
|
[{:logger_backends, "~> 1.0.0"}]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -125,61 +125,61 @@ defmodule Pleroma.Mixfile do
|
||||||
[
|
[
|
||||||
{:phoenix,
|
{:phoenix,
|
||||||
git: "https://github.com/feld/phoenix", branch: "v1.7.14-websocket-headers", override: true},
|
git: "https://github.com/feld/phoenix", branch: "v1.7.14-websocket-headers", override: true},
|
||||||
{:phoenix_ecto, "~> 4.4"},
|
{:phoenix_ecto, "~> 4.6"},
|
||||||
{:ecto_sql, "~> 3.10"},
|
{:ecto_sql, "~> 3.13"},
|
||||||
{:ecto_enum, "~> 1.4"},
|
{:ecto_enum, "~> 1.4"},
|
||||||
{:postgrex, ">= 0.20.0"},
|
{:postgrex, ">= 0.21.1"},
|
||||||
{:phoenix_html, "~> 3.3"},
|
{:phoenix_html, "~> 3.3"},
|
||||||
{:phoenix_live_view, "~> 1.1.0"},
|
{:phoenix_live_view, "~> 1.1.19"},
|
||||||
{:phoenix_live_dashboard, "~> 0.8.0"},
|
{:phoenix_live_dashboard, "~> 0.8.7"},
|
||||||
{:telemetry_metrics, "~> 0.6"},
|
{:telemetry_metrics, "~> 0.6"},
|
||||||
{:telemetry_poller, "~> 1.0"},
|
{:telemetry_poller, "~> 1.3"},
|
||||||
{:tzdata, "~> 1.0.3"},
|
{:tzdata, "~> 1.0.5"},
|
||||||
{:plug_cowboy, "~> 2.7"},
|
{:plug_cowboy, "~> 2.7"},
|
||||||
{:oban, "~> 2.19.0"},
|
{:oban, "~> 2.19.4"},
|
||||||
{:oban_plugins_lazarus,
|
{:oban_plugins_lazarus,
|
||||||
git: "https://git.pleroma.social/pleroma/elixir-libraries/oban_plugins_lazarus.git",
|
git: "https://git.pleroma.social/pleroma/elixir-libraries/oban_plugins_lazarus.git",
|
||||||
ref: "e49fc355baaf0e435208bf5f534d31e26e897711"},
|
ref: "e49fc355baaf0e435208bf5f534d31e26e897711"},
|
||||||
{:oban_web, "~> 2.11"},
|
{:oban_web, "~> 2.11"},
|
||||||
{:gettext, "~> 0.20"},
|
{:gettext, "~> 0.24"},
|
||||||
{:bcrypt_elixir, "~> 2.2"},
|
{:bcrypt_elixir, "~> 2.3"},
|
||||||
{:trailing_format_plug, "~> 0.0.7"},
|
{:trailing_format_plug, "~> 0.0.7"},
|
||||||
{:fast_sanitize, "~> 0.2.0"},
|
{:fast_sanitize, "~> 0.2.3"},
|
||||||
{:html_entities, "~> 0.5", override: true},
|
{:html_entities, "~> 0.5", override: true},
|
||||||
{:calendar, "~> 1.0"},
|
{:calendar, "~> 1.0"},
|
||||||
{:cachex, "~> 3.2"},
|
{:cachex, "~> 3.6"},
|
||||||
{:tesla, "~> 1.11"},
|
{:tesla, "~> 1.15"},
|
||||||
{:castore, "~> 1.0"},
|
{:castore, "~> 1.0"},
|
||||||
{:cowlib, "~> 2.15"},
|
{:cowlib, "~> 2.15"},
|
||||||
{:gun, "~> 2.2"},
|
{:gun, "~> 2.2"},
|
||||||
{:finch, "~> 0.15"},
|
{:finch, "~> 0.20"},
|
||||||
{:jason, "~> 1.2"},
|
{:jason, "~> 1.4"},
|
||||||
{:mogrify, "~> 0.9.0", override: true},
|
{:mogrify, "~> 0.9.3", override: true},
|
||||||
{:ex_aws, "~> 2.1.6"},
|
{:ex_aws, "~> 2.1.9"},
|
||||||
{:ex_aws_s3, "~> 2.0"},
|
{:ex_aws_s3, "~> 2.5"},
|
||||||
{:sweet_xml, "~> 0.7.2"},
|
{:sweet_xml, "~> 0.7.5"},
|
||||||
{:earmark, "1.4.46"},
|
{:earmark, "1.4.46"},
|
||||||
{:bbcode_pleroma, "~> 0.2.0"},
|
{:bbcode_pleroma, "~> 0.2.0"},
|
||||||
{:cors_plug, "~> 2.0"},
|
{:cors_plug, "~> 2.0"},
|
||||||
{:web_push_encryption, "~> 0.3.1"},
|
{:web_push_encryption, "~> 0.3.1"},
|
||||||
{:swoosh, "~> 1.16.9"},
|
{:swoosh, "~> 1.16.12"},
|
||||||
{:phoenix_swoosh, "~> 1.1"},
|
{:phoenix_swoosh, "~> 1.2"},
|
||||||
{:gen_smtp, "~> 0.13"},
|
{:gen_smtp, "~> 0.15"},
|
||||||
{:mua, "~> 0.2.0"},
|
{:mua, "~> 0.2.4"},
|
||||||
{:mail, "~> 0.3.0"},
|
{:mail, "~> 0.3.1"},
|
||||||
{:ex_syslogger, "~> 1.4"},
|
{:ex_syslogger, "~> 1.5"},
|
||||||
{:floki, "~> 0.35"},
|
{:floki, "~> 0.38"},
|
||||||
{:timex, "~> 3.6"},
|
{:timex, "~> 3.7"},
|
||||||
{:ueberauth, "~> 0.4"},
|
{:ueberauth, "~> 0.10"},
|
||||||
{:linkify, "~> 0.5.3"},
|
{:linkify, "~> 0.5.3"},
|
||||||
{:http_signatures, "~> 0.1.2"},
|
{:http_signatures, "~> 0.1.2"},
|
||||||
{:telemetry, "~> 1.0.0", override: true},
|
{:telemetry, "~> 1.0.0", override: true},
|
||||||
{:poolboy, "~> 1.5"},
|
{:poolboy, "~> 1.5"},
|
||||||
{:prom_ex, "~> 1.9"},
|
{:prom_ex, "~> 1.9"},
|
||||||
{:recon, "~> 2.5"},
|
{:recon, "~> 2.5"},
|
||||||
{:joken, "~> 2.0"},
|
{:joken, "~> 2.6"},
|
||||||
{:pot, "~> 1.0"},
|
{:pot, "~> 1.0"},
|
||||||
{:ex_const, "~> 0.2"},
|
{:ex_const, "~> 0.3"},
|
||||||
{:plug_static_index_html, "~> 1.0.0"},
|
{:plug_static_index_html, "~> 1.0.0"},
|
||||||
{:flake_id, "~> 0.1.0"},
|
{:flake_id, "~> 0.1.0"},
|
||||||
{:concurrent_limiter, "~> 0.1.1"},
|
{:concurrent_limiter, "~> 0.1.1"},
|
||||||
|
|
@ -190,31 +190,31 @@ defmodule Pleroma.Mixfile do
|
||||||
git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
|
git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
|
||||||
ref: "e7b7cc34cc16b383461b966484c297e4ec9aeef6"},
|
ref: "e7b7cc34cc16b383461b966484c297e4ec9aeef6"},
|
||||||
{:restarter, path: "./restarter"},
|
{:restarter, path: "./restarter"},
|
||||||
{:majic, "~> 1.0"},
|
{:majic, "~> 1.1"},
|
||||||
{:open_api_spex, "~> 3.16"},
|
{:open_api_spex, "~> 3.22"},
|
||||||
{:ecto_psql_extras, "~> 0.8"},
|
{:ecto_psql_extras, "~> 0.8"},
|
||||||
{:vix, "~> 0.36"},
|
{:vix, "~> 0.36"},
|
||||||
{:elixir_make, "~> 0.7.7", override: true},
|
{:elixir_make, "~> 0.7.8", override: true},
|
||||||
{:blurhash, "~> 0.1.0", hex: :rinpatch_blurhash},
|
{:blurhash, "~> 0.1.0", hex: :rinpatch_blurhash},
|
||||||
{:exile, "~> 0.10.0"},
|
{:exile, "~> 0.10.0"},
|
||||||
{:bandit, "~> 1.5.2"},
|
{:bandit, "~> 1.5.7"},
|
||||||
{:websock_adapter, "~> 0.5.6"},
|
{:websock_adapter, "~> 0.5.8"},
|
||||||
{:oban_live_dashboard, "~> 0.1.1"},
|
{:oban_live_dashboard, "~> 0.1.1"},
|
||||||
{:multipart, "~> 0.4.0", optional: true},
|
{:multipart, "~> 0.4.0", optional: true},
|
||||||
{:argon2_elixir, "~> 4.0"},
|
{:argon2_elixir, "~> 4.1"},
|
||||||
|
|
||||||
## dev & test
|
## dev & test
|
||||||
{:phoenix_live_reload, "~> 1.3.3", only: :dev},
|
{:phoenix_live_reload, "~> 1.3.3", only: :dev},
|
||||||
{:poison, "~> 3.0", only: :test},
|
{:poison, "~> 3.1", only: :test},
|
||||||
{:ex_doc, "~> 0.22", only: :dev, runtime: false},
|
{:ex_doc, "~> 0.38", only: :dev, runtime: false},
|
||||||
{:ex_machina, "~> 2.4", only: :test},
|
{:ex_machina, "~> 2.8", only: :test},
|
||||||
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
|
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
|
||||||
{:mock, "~> 0.3.5", only: :test},
|
{:mock, "~> 0.3.9", only: :test},
|
||||||
{:covertool, "~> 2.0", only: :test},
|
{:covertool, "~> 2.0", only: :test},
|
||||||
{:hackney, "~> 1.25.0", override: true},
|
{:hackney, "~> 1.25.0", override: true},
|
||||||
{:mox, "~> 1.0", only: :test},
|
{:mox, "~> 1.2", only: :test},
|
||||||
{:websockex, "~> 0.4.3", only: :test},
|
{:websockex, "~> 0.4.3", only: :test},
|
||||||
{:benchee, "~> 1.0", only: :benchmark},
|
{:benchee, "~> 1.4", only: :benchmark},
|
||||||
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
|
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
|
||||||
] ++ oauth_deps() ++ logger_deps()
|
] ++ oauth_deps() ++ logger_deps()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -329,5 +329,39 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
||||||
|
|
||||||
assert config_records() == []
|
assert config_records() == []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "filters non-whitelisted settings" do
|
||||||
|
clear_config(:database_config_whitelist, [
|
||||||
|
{:pleroma},
|
||||||
|
{:web_push_encryption, :vapid_details}
|
||||||
|
])
|
||||||
|
|
||||||
|
insert_config_record(:web_push_encryption, :non_whitelisted_key, a: 1)
|
||||||
|
insert_config_record(:web_push_encryption, :vapid_details, b: 1)
|
||||||
|
|
||||||
|
MixTask.run(["filter_whitelisted", "--force"])
|
||||||
|
|
||||||
|
assert [
|
||||||
|
%ConfigDB{group: :pleroma, key: :instance},
|
||||||
|
%ConfigDB{group: :pleroma, key: Pleroma.Captcha},
|
||||||
|
%ConfigDB{group: :web_push_encryption, key: :vapid_details}
|
||||||
|
] = config_records()
|
||||||
|
end
|
||||||
|
|
||||||
|
test "filter_whitelisted doesn't crash when whitelist is unset" do
|
||||||
|
clear_config(:database_config_whitelist, nil)
|
||||||
|
|
||||||
|
existing = config_records()
|
||||||
|
MixTask.run(["filter_whitelisted", "--force"])
|
||||||
|
assert config_records() == existing
|
||||||
|
end
|
||||||
|
|
||||||
|
test "filter_whitelisted doesn't crash when whitelist is disabled" do
|
||||||
|
clear_config(:database_config_whitelist, false)
|
||||||
|
|
||||||
|
existing = config_records()
|
||||||
|
MixTask.run(["filter_whitelisted", "--force"])
|
||||||
|
assert config_records() == existing
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.HashtagPolicyTest do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "#nsfw hey"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "#nsfw hey"})
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert modified["object"]["sensitive"]
|
assert modified["object"]["sensitive"]
|
||||||
end
|
end
|
||||||
|
|
@ -94,7 +94,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.HashtagPolicyTest do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe hey"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe hey"})
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
refute modified["object"]["sensitive"]
|
refute modified["object"]["sensitive"]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
|
||||||
{:ok, edit} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "edited :blank:"})
|
{:ok, edit} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "edited :blank:"})
|
||||||
|
|
||||||
{:ok, %{"object" => external_rep}} =
|
{:ok, %{"object" => external_rep}} =
|
||||||
Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data)
|
Pleroma.Web.ActivityPub.Transmogrifier.prepare_activity(edit.data)
|
||||||
|
|
||||||
%{external_rep: external_rep}
|
%{external_rep: external_rep}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UpdateHandlingTest do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
{:ok, activity} = Pleroma.Web.CommonAPI.post(user, %{status: "mew mew :dinosaur:"})
|
{:ok, activity} = Pleroma.Web.CommonAPI.post(user, %{status: "mew mew :dinosaur:"})
|
||||||
{:ok, edit} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "edited :blank:"})
|
{:ok, edit} = Pleroma.Web.CommonAPI.update(activity, user, %{status: "edited :blank:"})
|
||||||
{:ok, external_rep} = Pleroma.Web.ActivityPub.Transmogrifier.prepare_outgoing(edit.data)
|
{:ok, external_rep} = Pleroma.Web.ActivityPub.Transmogrifier.prepare_activity(edit.data)
|
||||||
%{external_rep: external_rep}
|
%{external_rep: external_rep}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Publishes with the new actor if prepare_outgoing changes the actor." do
|
test "Publishes with the new actor if prepare_activity changes the actor." do
|
||||||
mock(fn
|
mock(fn
|
||||||
%{method: :post, url: "https://domain.com/users/nick1/inbox", body: body} ->
|
%{method: :post, url: "https://domain.com/users/nick1/inbox", body: body} ->
|
||||||
{:ok, %Tesla.Env{status: 200, body: body}}
|
{:ok, %Tesla.Env{status: 200, body: body}}
|
||||||
|
|
@ -281,7 +281,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
||||||
)
|
)
|
||||||
|
|
||||||
Pleroma.Web.ActivityPub.TransmogrifierMock
|
Pleroma.Web.ActivityPub.TransmogrifierMock
|
||||||
|> Mox.expect(:prepare_outgoing, fn data ->
|
|> Mox.expect(:prepare_activity, fn data ->
|
||||||
{:ok, Map.put(data, "actor", replaced_actor.ap_id)}
|
{:ok, Map.put(data, "actor", replaced_actor.ap_id)}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnswerHandlingTest do
|
||||||
|> Kernel.put_in(["object", "to"], user.ap_id)
|
|> Kernel.put_in(["object", "to"], user.ap_id)
|
||||||
|
|
||||||
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||||
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, data} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert data["object"]["type"] == "Note"
|
assert data["object"]["type"] == "Note"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
|
||||||
|
|
||||||
{:ok, activity} = Transmogrifier.handle_incoming(message)
|
{:ok, activity} = Transmogrifier.handle_incoming(message)
|
||||||
|
|
||||||
{:ok, _} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, _} = Transmogrifier.prepare_activity(activity.data)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "successfully reserializes a message with AS2 objects in IR" do
|
test "successfully reserializes a message with AS2 objects in IR" do
|
||||||
|
|
@ -537,7 +537,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
|
||||||
|
|
||||||
{:ok, activity} = Transmogrifier.handle_incoming(message)
|
{:ok, activity} = Transmogrifier.handle_incoming(message)
|
||||||
|
|
||||||
{:ok, _} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, _} = Transmogrifier.prepare_activity(activity.data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -433,7 +433,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
|
|
||||||
{:ok, announce_activity} = CommonAPI.repeat(activity.id, user)
|
{:ok, announce_activity} = CommonAPI.repeat(activity.id, user)
|
||||||
|
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(announce_activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(announce_activity.data)
|
||||||
|
|
||||||
assert modified["object"]["content"] == "hey"
|
assert modified["object"]["content"] == "hey"
|
||||||
assert modified["object"]["actor"] == modified["object"]["attributedTo"]
|
assert modified["object"]["actor"] == modified["object"]["attributedTo"]
|
||||||
|
|
@ -448,7 +448,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
|
|
||||||
with_mock Pleroma.Notification,
|
with_mock Pleroma.Notification,
|
||||||
get_notified_from_activity: fn _, _ -> [] end do
|
get_notified_from_activity: fn _, _ -> [] end do
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
object = modified["object"]
|
object = modified["object"]
|
||||||
|
|
||||||
|
|
@ -474,7 +474,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert modified["@context"] == Utils.make_json_ld_header()["@context"]
|
assert modified["@context"] == Utils.make_json_ld_header()["@context"]
|
||||||
|
|
||||||
|
|
@ -485,7 +485,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert modified["object"]["actor"] == modified["object"]["attributedTo"]
|
assert modified["object"]["actor"] == modified["object"]["attributedTo"]
|
||||||
end
|
end
|
||||||
|
|
@ -501,7 +501,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
"name" => "#2hu"
|
"name" => "#2hu"
|
||||||
}
|
}
|
||||||
|
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert modified["object"]["tag"] == [expected_tag]
|
assert modified["object"]["tag"] == [expected_tag]
|
||||||
end
|
end
|
||||||
|
|
@ -524,7 +524,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
url: "https://pleroma.social"
|
url: "https://pleroma.social"
|
||||||
} == activity.object.data["generator"]
|
} == activity.object.data["generator"]
|
||||||
|
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert length(modified["object"]["tag"]) == 2
|
assert length(modified["object"]["tag"]) == 2
|
||||||
|
|
||||||
|
|
@ -541,7 +541,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
test "it strips internal fields of article" do
|
test "it strips internal fields of article" do
|
||||||
activity = insert(:article_activity)
|
activity = insert(:article_activity)
|
||||||
|
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert length(modified["object"]["tag"]) == 2
|
assert length(modified["object"]["tag"]) == 2
|
||||||
|
|
||||||
|
|
@ -558,13 +558,13 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "2hu :moominmamma:"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "2hu :moominmamma:"})
|
||||||
|
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert modified["directMessage"] == false
|
assert modified["directMessage"] == false
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "@#{other_user.nickname} :moominmamma:"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "@#{other_user.nickname} :moominmamma:"})
|
||||||
|
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert modified["directMessage"] == false
|
assert modified["directMessage"] == false
|
||||||
|
|
||||||
|
|
@ -574,7 +574,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
visibility: "direct"
|
visibility: "direct"
|
||||||
})
|
})
|
||||||
|
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert modified["directMessage"] == true
|
assert modified["directMessage"] == true
|
||||||
end
|
end
|
||||||
|
|
@ -585,7 +585,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "foobar", visibility: "list:#{list.id}"})
|
||||||
|
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert is_nil(modified["bcc"])
|
assert is_nil(modified["bcc"])
|
||||||
end
|
end
|
||||||
|
|
@ -594,7 +594,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
listen_activity = insert(:listen)
|
listen_activity = insert(:listen)
|
||||||
|
|
||||||
# This has an inlined object as in ObjectView
|
# This has an inlined object as in ObjectView
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(listen_activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(listen_activity.data)
|
||||||
|
|
||||||
assert modified["type"] == "Listen"
|
assert modified["type"] == "Listen"
|
||||||
|
|
||||||
|
|
@ -610,7 +610,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
object_type = activity.object.data["type"]
|
object_type = activity.object.data["type"]
|
||||||
|
|
||||||
# This does not have an inlined object
|
# This does not have an inlined object
|
||||||
{:ok, modified2} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified2} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert match?(
|
assert match?(
|
||||||
%{
|
%{
|
||||||
|
|
@ -640,7 +640,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"})
|
||||||
|
|
||||||
{:ok, prepared} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, prepared} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert length(prepared["object"]["tag"]) == 1
|
assert length(prepared["object"]["tag"]) == 1
|
||||||
|
|
||||||
|
|
@ -655,7 +655,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"})
|
||||||
{:ok, update} = CommonAPI.update(activity, user, %{status: "mew mew :blank:"})
|
{:ok, update} = CommonAPI.update(activity, user, %{status: "mew mew :blank:"})
|
||||||
|
|
||||||
{:ok, prepared} = Transmogrifier.prepare_outgoing(update.data)
|
{:ok, prepared} = Transmogrifier.prepare_activity(update.data)
|
||||||
|
|
||||||
assert %{
|
assert %{
|
||||||
"content" => "mew mew :blank:",
|
"content" => "mew mew :blank:",
|
||||||
|
|
@ -689,7 +689,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
user_update_changeset: changeset
|
user_update_changeset: changeset
|
||||||
)
|
)
|
||||||
|
|
||||||
assert {:ok, prepared} = Transmogrifier.prepare_outgoing(activity.data)
|
assert {:ok, prepared} = Transmogrifier.prepare_activity(activity.data)
|
||||||
assert prepared["type"] == "Update"
|
assert prepared["type"] == "Update"
|
||||||
assert prepared["@context"]
|
assert prepared["@context"]
|
||||||
assert prepared["object"]["type"] == user.actor_type
|
assert prepared["object"]["type"] == user.actor_type
|
||||||
|
|
@ -704,7 +704,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
|
|
||||||
{:ok, %Activity{} = block_activity} = CommonAPI.block(blocked, blocker)
|
{:ok, %Activity{} = block_activity} = CommonAPI.block(blocked, blocker)
|
||||||
{:ok, %Activity{} = undo_activity} = CommonAPI.unblock(blocked, blocker)
|
{:ok, %Activity{} = undo_activity} = CommonAPI.unblock(blocked, blocker)
|
||||||
{:ok, data} = Transmogrifier.prepare_outgoing(undo_activity.data)
|
{:ok, data} = Transmogrifier.prepare_activity(undo_activity.data)
|
||||||
|
|
||||||
block_ap_id = block_activity.data["id"]
|
block_ap_id = block_activity.data["id"]
|
||||||
assert is_binary(block_ap_id)
|
assert is_binary(block_ap_id)
|
||||||
|
|
@ -738,7 +738,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
assert is_binary(note_ap_id)
|
assert is_binary(note_ap_id)
|
||||||
|
|
||||||
{:ok, react_activity} = CommonAPI.react_with_emoji(note_activity.id, user, "🐈")
|
{:ok, react_activity} = CommonAPI.react_with_emoji(note_activity.id, user, "🐈")
|
||||||
{:ok, data} = Transmogrifier.prepare_outgoing(react_activity.data)
|
{:ok, data} = Transmogrifier.prepare_activity(react_activity.data)
|
||||||
|
|
||||||
assert match?(
|
assert match?(
|
||||||
%{
|
%{
|
||||||
|
|
@ -764,7 +764,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
note_activity = insert(:note_activity)
|
note_activity = insert(:note_activity)
|
||||||
|
|
||||||
{:ok, react_activity} = CommonAPI.react_with_emoji(note_activity.id, user, ":dinosaur:")
|
{:ok, react_activity} = CommonAPI.react_with_emoji(note_activity.id, user, ":dinosaur:")
|
||||||
{:ok, data} = Transmogrifier.prepare_outgoing(react_activity.data)
|
{:ok, data} = Transmogrifier.prepare_activity(react_activity.data)
|
||||||
|
|
||||||
assert length(data["tag"]) == 1
|
assert length(data["tag"]) == 1
|
||||||
|
|
||||||
|
|
@ -781,7 +781,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
{:ok, quoted_post} = CommonAPI.post(user, %{status: "hey"})
|
{:ok, quoted_post} = CommonAPI.post(user, %{status: "hey"})
|
||||||
{:ok, quote_post} = CommonAPI.post(user, %{status: "hey", quoted_status_id: quoted_post.id})
|
{:ok, quote_post} = CommonAPI.post(user, %{status: "hey", quoted_status_id: quoted_post.id})
|
||||||
|
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(quote_post.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(quote_post.data)
|
||||||
|
|
||||||
%{data: %{"id" => quote_id}} = Object.normalize(quoted_post)
|
%{data: %{"id" => quote_id}} = Object.normalize(quoted_post)
|
||||||
|
|
||||||
|
|
@ -793,7 +793,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "Cześć", language: "pl"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "Cześć", language: "pl"})
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.object.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.object.data)
|
||||||
|
|
||||||
assert [_, _, %{"@language" => "pl"}] = modified["@context"]
|
assert [_, _, %{"@language" => "pl"}] = modified["@context"]
|
||||||
end
|
end
|
||||||
|
|
@ -802,7 +802,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post(user, %{status: "Cześć", language: "pl"})
|
{:ok, activity} = CommonAPI.post(user, %{status: "Cześć", language: "pl"})
|
||||||
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, modified} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
assert [_, _, %{"@language" => "pl"}] = modified["@context"]
|
assert [_, _, %{"@language" => "pl"}] = modified["@context"]
|
||||||
end
|
end
|
||||||
|
|
@ -825,7 +825,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
content: content
|
content: content
|
||||||
})
|
})
|
||||||
|
|
||||||
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, data} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
expected_data =
|
expected_data =
|
||||||
activity.data
|
activity.data
|
||||||
|
|
@ -859,7 +859,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
clear_config([:activitypub, :anonymize_reporter], true)
|
clear_config([:activitypub, :anonymize_reporter], true)
|
||||||
clear_config([:activitypub, :anonymize_reporter_local_nickname], placeholder.nickname)
|
clear_config([:activitypub, :anonymize_reporter_local_nickname], placeholder.nickname)
|
||||||
|
|
||||||
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
{:ok, data} = Transmogrifier.prepare_activity(activity.data)
|
||||||
|
|
||||||
expected_data =
|
expected_data =
|
||||||
activity.data
|
activity.data
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,16 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
|
|
||||||
setup do: clear_config(:configurable_from_database, true)
|
setup do: clear_config(:configurable_from_database, true)
|
||||||
|
|
||||||
|
setup do:
|
||||||
|
clear_config(:database_config_whitelist, [
|
||||||
|
{:pleroma},
|
||||||
|
{:http},
|
||||||
|
{:idna},
|
||||||
|
{:oban},
|
||||||
|
{:tesla},
|
||||||
|
{:ueberauth}
|
||||||
|
])
|
||||||
|
|
||||||
test "create new config setting in db", %{conn: conn} do
|
test "create new config setting in db", %{conn: conn} do
|
||||||
ueberauth = Application.get_env(:ueberauth, Ueberauth)
|
ueberauth = Application.get_env(:ueberauth, Ueberauth)
|
||||||
on_exit(fn -> Application.put_env(:ueberauth, Ueberauth, ueberauth) end)
|
on_exit(fn -> Application.put_env(:ueberauth, Ueberauth, ueberauth) end)
|
||||||
|
|
@ -807,7 +817,7 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
%{
|
%{
|
||||||
"tuple" => [
|
"tuple" => [
|
||||||
"/websocket",
|
"/websocket",
|
||||||
"Phoenix.Endpoint.CowboyWebSocket",
|
":sth",
|
||||||
%{
|
%{
|
||||||
"tuple" => [
|
"tuple" => [
|
||||||
"Phoenix.Transports.WebSocket",
|
"Phoenix.Transports.WebSocket",
|
||||||
|
|
@ -871,7 +881,7 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
%{
|
%{
|
||||||
"tuple" => [
|
"tuple" => [
|
||||||
"/websocket",
|
"/websocket",
|
||||||
"Phoenix.Endpoint.CowboyWebSocket",
|
":sth",
|
||||||
%{
|
%{
|
||||||
"tuple" => [
|
"tuple" => [
|
||||||
"Phoenix.Transports.WebSocket",
|
"Phoenix.Transports.WebSocket",
|
||||||
|
|
@ -1210,6 +1220,31 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
assert Application.get_env(:not_real, :anything) == "value6"
|
assert Application.get_env(:not_real, :anything) == "value6"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "doesn't allow updating the database_config_whitelist itself", %{conn: conn} do
|
||||||
|
original_whitelist = Pleroma.Config.get(:database_config_whitelist)
|
||||||
|
|
||||||
|
refute ConfigDB.get_by_group_and_key(:pleroma, :database_config_whitelist)
|
||||||
|
|
||||||
|
conn =
|
||||||
|
conn
|
||||||
|
|> put_req_header("content-type", "application/json")
|
||||||
|
|> post("/api/pleroma/admin/config", %{
|
||||||
|
configs: [
|
||||||
|
%{
|
||||||
|
group: ":pleroma",
|
||||||
|
key: ":database_config_whitelist",
|
||||||
|
value: [%{"tuple" => [":pleroma", ":key1"]}]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
%{"configs" => configs} = json_response_and_validate_schema(conn, 200)
|
||||||
|
|
||||||
|
assert configs == []
|
||||||
|
assert Pleroma.Config.get(:database_config_whitelist) == original_whitelist
|
||||||
|
refute ConfigDB.get_by_group_and_key(:pleroma, :database_config_whitelist)
|
||||||
|
end
|
||||||
|
|
||||||
test "args for Pleroma.Upload.Filter.Mogrify with custom tuples", %{conn: conn} do
|
test "args for Pleroma.Upload.Filter.Mogrify with custom tuples", %{conn: conn} do
|
||||||
assert conn
|
assert conn
|
||||||
|> put_req_header("content-type", "application/json")
|
|> put_req_header("content-type", "application/json")
|
||||||
|
|
@ -1472,5 +1507,13 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
web_endpoint = Enum.find(children, fn c -> c["key"] == "Pleroma.Upload" end)
|
web_endpoint = Enum.find(children, fn c -> c["key"] == "Pleroma.Upload" end)
|
||||||
assert web_endpoint["children"]
|
assert web_endpoint["children"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "all keys from description are whitelisted", %{conn: conn} do
|
||||||
|
conn = get(conn, "/api/pleroma/admin/config/descriptions")
|
||||||
|
|
||||||
|
assert response = json_response_and_validate_schema(conn, 200)
|
||||||
|
|
||||||
|
assert length(response) == length(Pleroma.Docs.JSON.compiled_descriptions())
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2096,7 +2096,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
result =
|
result =
|
||||||
conn
|
conn
|
||||||
|> assign(:user, user)
|
|> assign(:user, user)
|
||||||
|> get("api/v1/blocks")
|
|> get("/api/v1/blocks")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [
|
assert [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue