diff --git a/CHANGELOG.md b/CHANGELOG.md index b2b7e5671..504ba2fb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Admin API: An endpoint to manage frontends. - Streaming API: Add follow relationships updates. - WebPush: Introduce `pleroma:chat_mention` and `pleroma:emoji_reaction` notification types. +- Mastodon API: Add monthly active users to `/api/v1/instance` (`pleroma.stats.mau`). +- Mastodon API: Home, public, hashtag & list timelines accept `only_media`, `remote` & `local` parameters for filtration. - Mastodon API: `/api/v1/accounts/:id` & `/api/v1/mutes` endpoints accept `with_relationships` parameter and return filled `pleroma.relationship` field. @@ -59,6 +61,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Creating incorrect IPv4 address-style HTTP links when encountering certain numbers. - Reblog API Endpoint: Do not set visibility parameter to public by default and let CommonAPI to infer it from status, so a user can reblog their private status without explicitly setting reblog visibility to private. - Tag URLs in statuses are now absolute +- Removed duplicate jobs to purge expired activities
API Changes diff --git a/config/description.exs b/config/description.exs index fac5a006e..f84b52a4f 100644 --- a/config/description.exs +++ b/config/description.exs @@ -3224,6 +3224,12 @@ type: :string, description: "S3 host", suggestions: ["s3.eu-central-1.amazonaws.com"] + }, + %{ + key: :region, + type: :string, + description: "S3 region (for AWS)", + suggestions: ["us-east-1"] } ] }, diff --git a/docs/development/API/differences_in_mastoapi_responses.md b/docs/development/API/differences_in_mastoapi_responses.md index b532d14ed..38d70fa78 100644 --- a/docs/development/API/differences_in_mastoapi_responses.md +++ b/docs/development/API/differences_in_mastoapi_responses.md @@ -16,6 +16,12 @@ Adding the parameter `reply_visibility` to the public and home timelines queries Adding the parameter `instance=lain.com` to the public timeline will show only statuses originating from `lain.com` (or any remote instance). +Home, public, hashtag & list timelines accept these parameters: + +- `only_media`: show only statuses with media attached +- `local`: show only local statuses +- `remote`: show only remote statuses + ## Statuses - `visibility`: has additional possible values `list` and `local` (for local-only statuses) @@ -54,6 +60,16 @@ The `id` parameter can also be the `nickname` of the user. This only works in th - `/api/v1/accounts/:id` - `/api/v1/accounts/:id/statuses` +`/api/v1/accounts/:id/statuses` endpoint accepts these parameters: + +- `pinned`: include only pinned statuses +- `tagged`: with tag +- `only_media`: include only statuses with media attached +- `with_muted`: include statuses/reactions from muted accounts +- `exclude_reblogs`: exclude reblogs +- `exclude_replies`: exclude replies +- `exclude_visibilities`: exclude visibilities + Endpoints which accept `with_relationships` parameter: - `/api/v1/accounts/:id` diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index e422b59f1..06cdb42af 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -146,6 +146,7 @@ defmodule Pleroma.User do field(:inbox, :string) field(:shared_inbox, :string) field(:accepts_chat_messages, :boolean, default: nil) + field(:last_active_at, :naive_datetime) embeds_one( :notification_settings, @@ -2444,4 +2445,19 @@ def sanitize_html(%User{} = user, filter) do def get_host(%User{ap_id: ap_id} = _user) do URI.parse(ap_id).host end + + def update_last_active_at(%__MODULE__{local: true} = user) do + user + |> cast(%{last_active_at: NaiveDateTime.utc_now()}, [:last_active_at]) + |> update_and_set_cache() + end + + def active_user_count(weeks \\ 4) do + active_after = Timex.shift(NaiveDateTime.utc_now(), weeks: -weeks) + + __MODULE__ + |> where([u], u.last_active_at >= ^active_after) + |> where([u], u.local == true) + |> Repo.aggregate(:count) + end end diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index d0bb07aab..98051032a 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -735,6 +735,12 @@ defp restrict_local(query, %{local_only: true}) do defp restrict_local(query, _), do: query + defp restrict_remote(query, %{remote: true}) do + from(activity in query, where: activity.local == false) + end + + defp restrict_remote(query, _), do: query + defp restrict_actor(query, %{actor_id: actor_id}) do from(activity in query, where: activity.actor == ^actor_id) end @@ -1111,6 +1117,7 @@ def fetch_activities_query(recipients, opts \\ %{}) do |> restrict_tag_all(opts) |> restrict_since(opts) |> restrict_local(opts) + |> restrict_remote(opts) |> restrict_actor(opts) |> restrict_type(opts) |> restrict_state(opts) diff --git a/lib/pleroma/web/api_spec/operations/account_operation.ex b/lib/pleroma/web/api_spec/operations/account_operation.ex index d7e01f55b..3d451cd5a 100644 --- a/lib/pleroma/web/api_spec/operations/account_operation.ex +++ b/lib/pleroma/web/api_spec/operations/account_operation.ex @@ -133,7 +133,7 @@ def statuses_operation do :with_muted, :query, BooleanLike, - "Include statuses from muted acccounts." + "Include statuses from muted accounts." ), Operation.parameter(:exclude_reblogs, :query, BooleanLike, "Exclude reblogs"), Operation.parameter(:exclude_replies, :query, BooleanLike, "Exclude replies"), @@ -147,7 +147,7 @@ def statuses_operation do :with_muted, :query, BooleanLike, - "Include reactions from muted acccounts." + "Include reactions from muted accounts." ) ] ++ pagination_params(), responses: %{ diff --git a/lib/pleroma/web/api_spec/operations/timeline_operation.ex b/lib/pleroma/web/api_spec/operations/timeline_operation.ex index e1ebdab38..01396642c 100644 --- a/lib/pleroma/web/api_spec/operations/timeline_operation.ex +++ b/lib/pleroma/web/api_spec/operations/timeline_operation.ex @@ -25,6 +25,8 @@ def home_operation do security: [%{"oAuth" => ["read:statuses"]}], parameters: [ local_param(), + remote_param(), + only_media_param(), with_muted_param(), exclude_visibilities_param(), reply_visibility_param() | pagination_params() @@ -61,6 +63,7 @@ def public_operation do local_param(), instance_param(), only_media_param(), + remote_param(), with_muted_param(), exclude_visibilities_param(), reply_visibility_param() | pagination_params() @@ -107,6 +110,7 @@ def hashtag_operation do ), local_param(), only_media_param(), + remote_param(), with_muted_param(), exclude_visibilities_param() | pagination_params() ], @@ -132,6 +136,9 @@ def list_operation do required: true ), with_muted_param(), + local_param(), + remote_param(), + only_media_param(), exclude_visibilities_param() | pagination_params() ], operationId: "TimelineController.list", @@ -198,4 +205,13 @@ defp only_media_param do "Show only statuses with media attached?" ) end + + defp remote_param do + Operation.parameter( + :remote, + :query, + %Schema{allOf: [BooleanLike], default: false}, + "Show only remote statuses?" + ) + end end diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index 94703cd05..8e274de88 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -23,6 +23,18 @@ defmodule Pleroma.Web.Endpoint do # InstanceStatic needs to be before Plug.Static to be able to override shipped-static files # If you're adding new paths to `only:` you'll need to configure them in InstanceStatic as well # Cache-control headers are duplicated in case we turn off etags in the future + plug( + Pleroma.Web.Plugs.InstanceStatic, + at: "/", + from: :pleroma, + only: ["emoji", "images"], + gzip: true, + cache_control_for_etags: "public, max-age=1209600", + headers: %{ + "cache-control" => "public, max-age=1209600" + } + ) + plug(Pleroma.Web.Plugs.InstanceStatic, at: "/", gzip: true, diff --git a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex index 08e6f23b9..cef299aa4 100644 --- a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex @@ -51,6 +51,8 @@ def home(%{assigns: %{user: user}} = conn, params) do |> Map.put(:reply_filtering_user, user) |> Map.put(:announce_filtering_user, user) |> Map.put(:user, user) + |> Map.put(:local_only, params[:local]) + |> Map.delete(:local) activities = [user.ap_id | User.following(user)] @@ -190,6 +192,7 @@ def list(%{assigns: %{user: user}} = conn, %{list_id: id} = params) do |> Map.put(:blocking_user, user) |> Map.put(:user, user) |> Map.put(:muting_user, user) + |> Map.put(:local_only, params[:local]) # we must filter the following list for the user to avoid leaking statuses the user # does not actually have permission to see (for more info, peruse security issue #270). diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 1edbdbe11..73205fb6d 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -45,6 +45,7 @@ def render("show.json", _) do fields_limits: fields_limits(), post_formats: Config.get([:instance, :allowed_post_formats]) }, + stats: %{mau: Pleroma.User.active_user_count()}, vapid_public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key) } } diff --git a/lib/pleroma/web/plugs/user_tracking_plug.ex b/lib/pleroma/web/plugs/user_tracking_plug.ex new file mode 100644 index 000000000..c9a988f00 --- /dev/null +++ b/lib/pleroma/web/plugs/user_tracking_plug.ex @@ -0,0 +1,30 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2021 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.Plugs.UserTrackingPlug do + alias Pleroma.User + + import Plug.Conn, only: [assign: 3] + + @update_interval :timer.hours(24) + + def init(opts), do: opts + + def call(%{assigns: %{user: %User{id: id} = user}} = conn, _) when not is_nil(id) do + with true <- needs_update?(user), + {:ok, user} <- User.update_last_active_at(user) do + assign(conn, :user, user) + else + _ -> conn + end + end + + def call(conn, _), do: conn + + defp needs_update?(%User{last_active_at: nil}), do: true + + defp needs_update?(%User{last_active_at: last_active_at}) do + NaiveDateTime.diff(NaiveDateTime.utc_now(), last_active_at, :millisecond) >= @update_interval + end +end diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index a9e332fa1..7521f5dc3 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -56,6 +56,7 @@ defmodule Pleroma.Web.Router do plug(Pleroma.Web.Plugs.UserEnabledPlug) plug(Pleroma.Web.Plugs.SetUserSessionIdPlug) plug(Pleroma.Web.Plugs.EnsureUserTokenAssignsPlug) + plug(Pleroma.Web.Plugs.UserTrackingPlug) end pipeline :base_api do diff --git a/lib/pleroma/workers/attachments_cleanup_worker.ex b/lib/pleroma/workers/attachments_cleanup_worker.ex index a2373ebb9..f5090dae7 100644 --- a/lib/pleroma/workers/attachments_cleanup_worker.ex +++ b/lib/pleroma/workers/attachments_cleanup_worker.ex @@ -17,12 +17,14 @@ def perform(%Job{ "object" => %{"data" => %{"attachment" => [_ | _] = attachments, "actor" => actor}} } }) do - attachments - |> Enum.flat_map(fn item -> Enum.map(item["url"], & &1["href"]) end) - |> fetch_objects - |> prepare_objects(actor, Enum.map(attachments, & &1["name"])) - |> filter_objects - |> do_clean + if Pleroma.Config.get([:instance, :cleanup_attachments], false) do + attachments + |> Enum.flat_map(fn item -> Enum.map(item["url"], & &1["href"]) end) + |> fetch_objects + |> prepare_objects(actor, Enum.map(attachments, & &1["name"])) + |> filter_objects + |> do_clean + end {:ok, :success} end diff --git a/lib/pleroma/workers/purge_expired_activity.ex b/lib/pleroma/workers/purge_expired_activity.ex index 01256831b..027171c1e 100644 --- a/lib/pleroma/workers/purge_expired_activity.ex +++ b/lib/pleroma/workers/purge_expired_activity.ex @@ -7,7 +7,7 @@ defmodule Pleroma.Workers.PurgeExpiredActivity do Worker which purges expired activity. """ - use Oban.Worker, queue: :activity_expiration, max_attempts: 1 + use Oban.Worker, queue: :activity_expiration, max_attempts: 1, unique: [period: :infinity] import Ecto.Query diff --git a/priv/repo/migrations/20210122151424_add_last_active_at_to_users.exs b/priv/repo/migrations/20210122151424_add_last_active_at_to_users.exs new file mode 100644 index 000000000..9671e495b --- /dev/null +++ b/priv/repo/migrations/20210122151424_add_last_active_at_to_users.exs @@ -0,0 +1,11 @@ +defmodule Pleroma.Repo.Migrations.AddLastActiveAtToUsers do + use Ecto.Migration + + def change do + alter table(:users) do + add(:last_active_at, :naive_datetime) + end + + create_if_not_exists(index(:users, [:last_active_at])) + end +end diff --git a/priv/repo/migrations/20210128092834_remove_duplicates_from_activity_expiration_queue.exs b/priv/repo/migrations/20210128092834_remove_duplicates_from_activity_expiration_queue.exs new file mode 100644 index 000000000..309009205 --- /dev/null +++ b/priv/repo/migrations/20210128092834_remove_duplicates_from_activity_expiration_queue.exs @@ -0,0 +1,29 @@ +defmodule Pleroma.Repo.Migrations.RemoveDuplicatesFromActivityExpirationQueue do + use Ecto.Migration + + import Ecto.Query, only: [from: 2] + + def up do + duplicate_ids = + from(j in Oban.Job, + where: j.queue == "activity_expiration", + where: j.worker == "Pleroma.Workers.PurgeExpiredActivity", + where: j.state == "scheduled", + select: + {fragment("(?)->>'activity_id'", j.args), fragment("array_agg(?)", j.id), count(j.id)}, + group_by: fragment("(?)->>'activity_id'", j.args), + having: count(j.id) > 1 + ) + |> Pleroma.Repo.all() + |> Enum.map(fn {_, ids, _} -> + max_id = Enum.max(ids) + List.delete(ids, max_id) + end) + |> List.flatten() + + from(j in Oban.Job, where: j.id in ^duplicate_ids) + |> Pleroma.Repo.delete_all() + end + + def down, do: :noop +end diff --git a/priv/static/index.html b/priv/static/index.html index c4dcf5d37..79d67c4c2 100644 --- a/priv/static/index.html +++ b/priv/static/index.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/priv/static/static/js/10.a11a612e4c1ef51ded17.js b/priv/static/static/js/10.8702741bef65422a8655.js similarity index 99% rename from priv/static/static/js/10.a11a612e4c1ef51ded17.js rename to priv/static/static/js/10.8702741bef65422a8655.js index 2a1ffcc2b..0a0795bcd 100644 Binary files a/priv/static/static/js/10.a11a612e4c1ef51ded17.js and b/priv/static/static/js/10.8702741bef65422a8655.js differ diff --git a/priv/static/static/js/12.c6df5166dc6cdcf749e5.js.map b/priv/static/static/js/10.8702741bef65422a8655.js.map similarity index 56% rename from priv/static/static/js/12.c6df5166dc6cdcf749e5.js.map rename to priv/static/static/js/10.8702741bef65422a8655.js.map index c0bac6f0f..cb936cec1 100644 Binary files a/priv/static/static/js/12.c6df5166dc6cdcf749e5.js.map and b/priv/static/static/js/10.8702741bef65422a8655.js.map differ diff --git a/priv/static/static/js/11.22872a1f83121e70a148.js b/priv/static/static/js/11.a3e462fd9190986433f8.js similarity index 99% rename from priv/static/static/js/11.22872a1f83121e70a148.js rename to priv/static/static/js/11.a3e462fd9190986433f8.js index a2e9cee51..6b49bb02d 100644 Binary files a/priv/static/static/js/11.22872a1f83121e70a148.js and b/priv/static/static/js/11.a3e462fd9190986433f8.js differ diff --git a/priv/static/static/js/10.a11a612e4c1ef51ded17.js.map b/priv/static/static/js/11.a3e462fd9190986433f8.js.map similarity index 56% rename from priv/static/static/js/10.a11a612e4c1ef51ded17.js.map rename to priv/static/static/js/11.a3e462fd9190986433f8.js.map index fd81b28be..496d6a6f1 100644 Binary files a/priv/static/static/js/10.a11a612e4c1ef51ded17.js.map and b/priv/static/static/js/11.a3e462fd9190986433f8.js.map differ diff --git a/priv/static/static/js/12.c6df5166dc6cdcf749e5.js b/priv/static/static/js/12.7d5889019e7177d19bc2.js similarity index 99% rename from priv/static/static/js/12.c6df5166dc6cdcf749e5.js rename to priv/static/static/js/12.7d5889019e7177d19bc2.js index 441071f37..6dc87809f 100644 Binary files a/priv/static/static/js/12.c6df5166dc6cdcf749e5.js and b/priv/static/static/js/12.7d5889019e7177d19bc2.js differ diff --git a/priv/static/static/js/13.77214c18c6d2a9865281.js.map b/priv/static/static/js/12.7d5889019e7177d19bc2.js.map similarity index 56% rename from priv/static/static/js/13.77214c18c6d2a9865281.js.map rename to priv/static/static/js/12.7d5889019e7177d19bc2.js.map index 3d7abf273..cf9631696 100644 Binary files a/priv/static/static/js/13.77214c18c6d2a9865281.js.map and b/priv/static/static/js/12.7d5889019e7177d19bc2.js.map differ diff --git a/priv/static/static/js/13.77214c18c6d2a9865281.js b/priv/static/static/js/13.bb129366e7d54b5678d4.js similarity index 99% rename from priv/static/static/js/13.77214c18c6d2a9865281.js rename to priv/static/static/js/13.bb129366e7d54b5678d4.js index 08e356de2..8c73a0022 100644 Binary files a/priv/static/static/js/13.77214c18c6d2a9865281.js and b/priv/static/static/js/13.bb129366e7d54b5678d4.js differ diff --git a/priv/static/static/js/11.22872a1f83121e70a148.js.map b/priv/static/static/js/13.bb129366e7d54b5678d4.js.map similarity index 56% rename from priv/static/static/js/11.22872a1f83121e70a148.js.map rename to priv/static/static/js/13.bb129366e7d54b5678d4.js.map index 6467c58a5..b5a0af8a3 100644 Binary files a/priv/static/static/js/11.22872a1f83121e70a148.js.map and b/priv/static/static/js/13.bb129366e7d54b5678d4.js.map differ diff --git a/priv/static/static/js/14.e560f5e2f902b9ad2d0d.js b/priv/static/static/js/14.3546063198fc4cb3852c.js similarity index 99% rename from priv/static/static/js/14.e560f5e2f902b9ad2d0d.js rename to priv/static/static/js/14.3546063198fc4cb3852c.js index d2d291725..8897a50ce 100644 Binary files a/priv/static/static/js/14.e560f5e2f902b9ad2d0d.js and b/priv/static/static/js/14.3546063198fc4cb3852c.js differ diff --git a/priv/static/static/js/14.3546063198fc4cb3852c.js.map b/priv/static/static/js/14.3546063198fc4cb3852c.js.map new file mode 100644 index 000000000..e7596b961 Binary files /dev/null and b/priv/static/static/js/14.3546063198fc4cb3852c.js.map differ diff --git a/priv/static/static/js/14.e560f5e2f902b9ad2d0d.js.map b/priv/static/static/js/14.e560f5e2f902b9ad2d0d.js.map deleted file mode 100644 index f9797f1b6..000000000 Binary files a/priv/static/static/js/14.e560f5e2f902b9ad2d0d.js.map and /dev/null differ diff --git a/priv/static/static/js/15.2893c12f1ca2bcdc3cbf.js.map b/priv/static/static/js/15.2893c12f1ca2bcdc3cbf.js.map deleted file mode 100644 index 00cab138d..000000000 Binary files a/priv/static/static/js/15.2893c12f1ca2bcdc3cbf.js.map and /dev/null differ diff --git a/priv/static/static/js/15.2893c12f1ca2bcdc3cbf.js b/priv/static/static/js/15.e0cc6ce336f523c26f4d.js similarity index 98% rename from priv/static/static/js/15.2893c12f1ca2bcdc3cbf.js rename to priv/static/static/js/15.e0cc6ce336f523c26f4d.js index 82318f797..ec162d862 100644 Binary files a/priv/static/static/js/15.2893c12f1ca2bcdc3cbf.js and b/priv/static/static/js/15.e0cc6ce336f523c26f4d.js differ diff --git a/priv/static/static/js/15.e0cc6ce336f523c26f4d.js.map b/priv/static/static/js/15.e0cc6ce336f523c26f4d.js.map new file mode 100644 index 000000000..d6ec98aaf Binary files /dev/null and b/priv/static/static/js/15.e0cc6ce336f523c26f4d.js.map differ diff --git a/priv/static/static/js/16.be7f4b788716bec25023.js b/priv/static/static/js/16.67b2bcf7dd3271e31643.js similarity index 99% rename from priv/static/static/js/16.be7f4b788716bec25023.js rename to priv/static/static/js/16.67b2bcf7dd3271e31643.js index ea5b554f1..b4f1fcb57 100644 Binary files a/priv/static/static/js/16.be7f4b788716bec25023.js and b/priv/static/static/js/16.67b2bcf7dd3271e31643.js differ diff --git a/priv/static/static/js/16.67b2bcf7dd3271e31643.js.map b/priv/static/static/js/16.67b2bcf7dd3271e31643.js.map new file mode 100644 index 000000000..31f00875c Binary files /dev/null and b/priv/static/static/js/16.67b2bcf7dd3271e31643.js.map differ diff --git a/priv/static/static/js/16.be7f4b788716bec25023.js.map b/priv/static/static/js/16.be7f4b788716bec25023.js.map deleted file mode 100644 index 121a49be1..000000000 Binary files a/priv/static/static/js/16.be7f4b788716bec25023.js.map and /dev/null differ diff --git a/priv/static/static/js/17.4ddba89b4f8c284f6392.js.map b/priv/static/static/js/17.4ddba89b4f8c284f6392.js.map deleted file mode 100644 index 322db8c6b..000000000 Binary files a/priv/static/static/js/17.4ddba89b4f8c284f6392.js.map and /dev/null differ diff --git a/priv/static/static/js/17.4ddba89b4f8c284f6392.js b/priv/static/static/js/17.a8395e49508cd81ecdf4.js similarity index 94% rename from priv/static/static/js/17.4ddba89b4f8c284f6392.js rename to priv/static/static/js/17.a8395e49508cd81ecdf4.js index 39283f245..0b90485ff 100644 Binary files a/priv/static/static/js/17.4ddba89b4f8c284f6392.js and b/priv/static/static/js/17.a8395e49508cd81ecdf4.js differ diff --git a/priv/static/static/js/17.a8395e49508cd81ecdf4.js.map b/priv/static/static/js/17.a8395e49508cd81ecdf4.js.map new file mode 100644 index 000000000..33b1c8e34 Binary files /dev/null and b/priv/static/static/js/17.a8395e49508cd81ecdf4.js.map differ diff --git a/priv/static/static/js/18.1b9a9aedd06803dbb3e4.js b/priv/static/static/js/18.1b9a9aedd06803dbb3e4.js new file mode 100644 index 000000000..621616a3f Binary files /dev/null and b/priv/static/static/js/18.1b9a9aedd06803dbb3e4.js differ diff --git a/priv/static/static/js/18.1b9a9aedd06803dbb3e4.js.map b/priv/static/static/js/18.1b9a9aedd06803dbb3e4.js.map new file mode 100644 index 000000000..46f4d2a0c Binary files /dev/null and b/priv/static/static/js/18.1b9a9aedd06803dbb3e4.js.map differ diff --git a/priv/static/static/js/18.990b88b57bf3a6809098.js b/priv/static/static/js/18.990b88b57bf3a6809098.js deleted file mode 100644 index 96de50c61..000000000 Binary files a/priv/static/static/js/18.990b88b57bf3a6809098.js and /dev/null differ diff --git a/priv/static/static/js/18.990b88b57bf3a6809098.js.map b/priv/static/static/js/18.990b88b57bf3a6809098.js.map deleted file mode 100644 index b0fb3b629..000000000 Binary files a/priv/static/static/js/18.990b88b57bf3a6809098.js.map and /dev/null differ diff --git a/priv/static/static/js/19.783715f17e3f98e8898e.js.map b/priv/static/static/js/19.783715f17e3f98e8898e.js.map deleted file mode 100644 index d3bd148d5..000000000 Binary files a/priv/static/static/js/19.783715f17e3f98e8898e.js.map and /dev/null differ diff --git a/priv/static/static/js/19.783715f17e3f98e8898e.js b/priv/static/static/js/19.af8826ed7cd146d80620.js similarity index 99% rename from priv/static/static/js/19.783715f17e3f98e8898e.js rename to priv/static/static/js/19.af8826ed7cd146d80620.js index bf4fd22fd..d941e222e 100644 Binary files a/priv/static/static/js/19.783715f17e3f98e8898e.js and b/priv/static/static/js/19.af8826ed7cd146d80620.js differ diff --git a/priv/static/static/js/19.af8826ed7cd146d80620.js.map b/priv/static/static/js/19.af8826ed7cd146d80620.js.map new file mode 100644 index 000000000..886699ead Binary files /dev/null and b/priv/static/static/js/19.af8826ed7cd146d80620.js.map differ diff --git a/priv/static/static/js/2.88fa7ac80b2020ac2b46.js b/priv/static/static/js/2.88fa7ac80b2020ac2b46.js deleted file mode 100644 index b2c2eeb25..000000000 Binary files a/priv/static/static/js/2.88fa7ac80b2020ac2b46.js and /dev/null differ diff --git a/priv/static/static/js/2.88fa7ac80b2020ac2b46.js.map b/priv/static/static/js/2.88fa7ac80b2020ac2b46.js.map deleted file mode 100644 index f6aafd426..000000000 Binary files a/priv/static/static/js/2.88fa7ac80b2020ac2b46.js.map and /dev/null differ diff --git a/priv/static/static/js/2.cac6da00a889ad330fef.js b/priv/static/static/js/2.cac6da00a889ad330fef.js new file mode 100644 index 000000000..0e34c12d2 Binary files /dev/null and b/priv/static/static/js/2.cac6da00a889ad330fef.js differ diff --git a/priv/static/static/js/2.cac6da00a889ad330fef.js.map b/priv/static/static/js/2.cac6da00a889ad330fef.js.map new file mode 100644 index 000000000..05f611b86 Binary files /dev/null and b/priv/static/static/js/2.cac6da00a889ad330fef.js.map differ diff --git a/priv/static/static/js/20.96c40f6c9db8c08633bd.js.map b/priv/static/static/js/20.96c40f6c9db8c08633bd.js.map deleted file mode 100644 index d7d40ed07..000000000 Binary files a/priv/static/static/js/20.96c40f6c9db8c08633bd.js.map and /dev/null differ diff --git a/priv/static/static/js/20.96c40f6c9db8c08633bd.js b/priv/static/static/js/20.c45b976fb08603acced8.js similarity index 99% rename from priv/static/static/js/20.96c40f6c9db8c08633bd.js rename to priv/static/static/js/20.c45b976fb08603acced8.js index a3b3d7894..6012aebb1 100644 Binary files a/priv/static/static/js/20.96c40f6c9db8c08633bd.js and b/priv/static/static/js/20.c45b976fb08603acced8.js differ diff --git a/priv/static/static/js/20.c45b976fb08603acced8.js.map b/priv/static/static/js/20.c45b976fb08603acced8.js.map new file mode 100644 index 000000000..c0cc39285 Binary files /dev/null and b/priv/static/static/js/20.c45b976fb08603acced8.js.map differ diff --git a/priv/static/static/js/21.5a9f8e39a7833c1aa117.js b/priv/static/static/js/21.11c34dd4260444732ab0.js similarity index 99% rename from priv/static/static/js/21.5a9f8e39a7833c1aa117.js rename to priv/static/static/js/21.11c34dd4260444732ab0.js index 4114db7db..b5b0d7403 100644 Binary files a/priv/static/static/js/21.5a9f8e39a7833c1aa117.js and b/priv/static/static/js/21.11c34dd4260444732ab0.js differ diff --git a/priv/static/static/js/21.11c34dd4260444732ab0.js.map b/priv/static/static/js/21.11c34dd4260444732ab0.js.map new file mode 100644 index 000000000..11b0f1cdb Binary files /dev/null and b/priv/static/static/js/21.11c34dd4260444732ab0.js.map differ diff --git a/priv/static/static/js/21.5a9f8e39a7833c1aa117.js.map b/priv/static/static/js/21.5a9f8e39a7833c1aa117.js.map deleted file mode 100644 index 898948286..000000000 Binary files a/priv/static/static/js/21.5a9f8e39a7833c1aa117.js.map and /dev/null differ diff --git a/priv/static/static/js/22.d65671b9e5e00a0eb625.js b/priv/static/static/js/22.6155d82624c0297d5694.js similarity index 99% rename from priv/static/static/js/22.d65671b9e5e00a0eb625.js rename to priv/static/static/js/22.6155d82624c0297d5694.js index 3748a53b2..7054f1a7c 100644 Binary files a/priv/static/static/js/22.d65671b9e5e00a0eb625.js and b/priv/static/static/js/22.6155d82624c0297d5694.js differ diff --git a/priv/static/static/js/22.6155d82624c0297d5694.js.map b/priv/static/static/js/22.6155d82624c0297d5694.js.map new file mode 100644 index 000000000..721b74faf Binary files /dev/null and b/priv/static/static/js/22.6155d82624c0297d5694.js.map differ diff --git a/priv/static/static/js/22.d65671b9e5e00a0eb625.js.map b/priv/static/static/js/22.d65671b9e5e00a0eb625.js.map deleted file mode 100644 index 110cadd41..000000000 Binary files a/priv/static/static/js/22.d65671b9e5e00a0eb625.js.map and /dev/null differ diff --git a/priv/static/static/js/23.bf697d60801d277815e0.js.map b/priv/static/static/js/23.bf697d60801d277815e0.js.map deleted file mode 100644 index 20c74e93b..000000000 Binary files a/priv/static/static/js/23.bf697d60801d277815e0.js.map and /dev/null differ diff --git a/priv/static/static/js/23.bf697d60801d277815e0.js b/priv/static/static/js/23.d89535c0e277447a45a7.js similarity index 99% rename from priv/static/static/js/23.bf697d60801d277815e0.js rename to priv/static/static/js/23.d89535c0e277447a45a7.js index e61cf01d7..8979bc0fe 100644 Binary files a/priv/static/static/js/23.bf697d60801d277815e0.js and b/priv/static/static/js/23.d89535c0e277447a45a7.js differ diff --git a/priv/static/static/js/23.d89535c0e277447a45a7.js.map b/priv/static/static/js/23.d89535c0e277447a45a7.js.map new file mode 100644 index 000000000..336c6ecd4 Binary files /dev/null and b/priv/static/static/js/23.d89535c0e277447a45a7.js.map differ diff --git a/priv/static/static/js/24.914e51bfcfc620a93c0e.js b/priv/static/static/js/24.4693bde7d2a49831dbe2.js similarity index 99% rename from priv/static/static/js/24.914e51bfcfc620a93c0e.js rename to priv/static/static/js/24.4693bde7d2a49831dbe2.js index abdad101e..7faf73baa 100644 Binary files a/priv/static/static/js/24.914e51bfcfc620a93c0e.js and b/priv/static/static/js/24.4693bde7d2a49831dbe2.js differ diff --git a/priv/static/static/js/24.4693bde7d2a49831dbe2.js.map b/priv/static/static/js/24.4693bde7d2a49831dbe2.js.map new file mode 100644 index 000000000..1b2573a33 Binary files /dev/null and b/priv/static/static/js/24.4693bde7d2a49831dbe2.js.map differ diff --git a/priv/static/static/js/24.914e51bfcfc620a93c0e.js.map b/priv/static/static/js/24.914e51bfcfc620a93c0e.js.map deleted file mode 100644 index 1ddfced9a..000000000 Binary files a/priv/static/static/js/24.914e51bfcfc620a93c0e.js.map and /dev/null differ diff --git a/priv/static/static/js/25.fa8acda1a0ba7de2ab58.js b/priv/static/static/js/25.8f7cea2eb70da626b21d.js similarity index 99% rename from priv/static/static/js/25.fa8acda1a0ba7de2ab58.js rename to priv/static/static/js/25.8f7cea2eb70da626b21d.js index 719148fcd..726304c49 100644 Binary files a/priv/static/static/js/25.fa8acda1a0ba7de2ab58.js and b/priv/static/static/js/25.8f7cea2eb70da626b21d.js differ diff --git a/priv/static/static/js/25.8f7cea2eb70da626b21d.js.map b/priv/static/static/js/25.8f7cea2eb70da626b21d.js.map new file mode 100644 index 000000000..c8e52eac5 Binary files /dev/null and b/priv/static/static/js/25.8f7cea2eb70da626b21d.js.map differ diff --git a/priv/static/static/js/25.fa8acda1a0ba7de2ab58.js.map b/priv/static/static/js/25.fa8acda1a0ba7de2ab58.js.map deleted file mode 100644 index ec5910108..000000000 Binary files a/priv/static/static/js/25.fa8acda1a0ba7de2ab58.js.map and /dev/null differ diff --git a/priv/static/static/js/26.3f806866a23f516b7e87.js b/priv/static/static/js/26.3f806866a23f516b7e87.js new file mode 100644 index 000000000..48273248b Binary files /dev/null and b/priv/static/static/js/26.3f806866a23f516b7e87.js differ diff --git a/priv/static/static/js/26.3f806866a23f516b7e87.js.map b/priv/static/static/js/26.3f806866a23f516b7e87.js.map new file mode 100644 index 000000000..68cc924a8 Binary files /dev/null and b/priv/static/static/js/26.3f806866a23f516b7e87.js.map differ diff --git a/priv/static/static/js/26.5233739c17e00ab514f7.js b/priv/static/static/js/26.5233739c17e00ab514f7.js deleted file mode 100644 index 9adba8a0c..000000000 Binary files a/priv/static/static/js/26.5233739c17e00ab514f7.js and /dev/null differ diff --git a/priv/static/static/js/26.5233739c17e00ab514f7.js.map b/priv/static/static/js/26.5233739c17e00ab514f7.js.map deleted file mode 100644 index 9aad55492..000000000 Binary files a/priv/static/static/js/26.5233739c17e00ab514f7.js.map and /dev/null differ diff --git a/priv/static/static/js/27.79a2337abb067d8a36ce.js b/priv/static/static/js/27.2d655ddddf874f532191.js similarity index 94% rename from priv/static/static/js/27.79a2337abb067d8a36ce.js rename to priv/static/static/js/27.2d655ddddf874f532191.js index 07b8fbea4..b52d610aa 100644 Binary files a/priv/static/static/js/27.79a2337abb067d8a36ce.js and b/priv/static/static/js/27.2d655ddddf874f532191.js differ diff --git a/priv/static/static/js/27.2d655ddddf874f532191.js.map b/priv/static/static/js/27.2d655ddddf874f532191.js.map new file mode 100644 index 000000000..0042ffa62 Binary files /dev/null and b/priv/static/static/js/27.2d655ddddf874f532191.js.map differ diff --git a/priv/static/static/js/27.79a2337abb067d8a36ce.js.map b/priv/static/static/js/27.79a2337abb067d8a36ce.js.map deleted file mode 100644 index a55aeae77..000000000 Binary files a/priv/static/static/js/27.79a2337abb067d8a36ce.js.map and /dev/null differ diff --git a/priv/static/static/js/28.ed355decbad274c26485.js b/priv/static/static/js/28.ed355decbad274c26485.js deleted file mode 100644 index e4cfd3d70..000000000 Binary files a/priv/static/static/js/28.ed355decbad274c26485.js and /dev/null differ diff --git a/priv/static/static/js/28.ed355decbad274c26485.js.map b/priv/static/static/js/28.ed355decbad274c26485.js.map deleted file mode 100644 index 0349f2c68..000000000 Binary files a/priv/static/static/js/28.ed355decbad274c26485.js.map and /dev/null differ diff --git a/priv/static/static/js/28.f738a8b568b00299a569.js b/priv/static/static/js/28.f738a8b568b00299a569.js new file mode 100644 index 000000000..64de7926b Binary files /dev/null and b/priv/static/static/js/28.f738a8b568b00299a569.js differ diff --git a/priv/static/static/js/28.f738a8b568b00299a569.js.map b/priv/static/static/js/28.f738a8b568b00299a569.js.map new file mode 100644 index 000000000..1e1aa98e3 Binary files /dev/null and b/priv/static/static/js/28.f738a8b568b00299a569.js.map differ diff --git a/priv/static/static/js/29.d3d8f3c066d579644c9a.js b/priv/static/static/js/29.64d5389501dc6e6c77f2.js similarity index 99% rename from priv/static/static/js/29.d3d8f3c066d579644c9a.js rename to priv/static/static/js/29.64d5389501dc6e6c77f2.js index 8a8a3b51f..6d1246a86 100644 Binary files a/priv/static/static/js/29.d3d8f3c066d579644c9a.js and b/priv/static/static/js/29.64d5389501dc6e6c77f2.js differ diff --git a/priv/static/static/js/29.64d5389501dc6e6c77f2.js.map b/priv/static/static/js/29.64d5389501dc6e6c77f2.js.map new file mode 100644 index 000000000..075022565 Binary files /dev/null and b/priv/static/static/js/29.64d5389501dc6e6c77f2.js.map differ diff --git a/priv/static/static/js/29.d3d8f3c066d579644c9a.js.map b/priv/static/static/js/29.d3d8f3c066d579644c9a.js.map deleted file mode 100644 index 0ef69d368..000000000 Binary files a/priv/static/static/js/29.d3d8f3c066d579644c9a.js.map and /dev/null differ diff --git a/priv/static/static/js/3.0b1cb0c49b906b834801.js b/priv/static/static/js/3.91e3846705ce522e8366.js similarity index 99% rename from priv/static/static/js/3.0b1cb0c49b906b834801.js rename to priv/static/static/js/3.91e3846705ce522e8366.js index 5b79d06b1..a01c4760a 100644 Binary files a/priv/static/static/js/3.0b1cb0c49b906b834801.js and b/priv/static/static/js/3.91e3846705ce522e8366.js differ diff --git a/priv/static/static/js/3.0b1cb0c49b906b834801.js.map b/priv/static/static/js/3.91e3846705ce522e8366.js.map similarity index 99% rename from priv/static/static/js/3.0b1cb0c49b906b834801.js.map rename to priv/static/static/js/3.91e3846705ce522e8366.js.map index 08e6ffdfe..dba83509c 100644 Binary files a/priv/static/static/js/3.0b1cb0c49b906b834801.js.map and b/priv/static/static/js/3.91e3846705ce522e8366.js.map differ diff --git a/priv/static/static/js/30.04694ca04ca2fb3b9695.js b/priv/static/static/js/30.04694ca04ca2fb3b9695.js deleted file mode 100644 index cc60c675d..000000000 Binary files a/priv/static/static/js/30.04694ca04ca2fb3b9695.js and /dev/null differ diff --git a/priv/static/static/js/30.04694ca04ca2fb3b9695.js.map b/priv/static/static/js/30.04694ca04ca2fb3b9695.js.map deleted file mode 100644 index b347f4f84..000000000 Binary files a/priv/static/static/js/30.04694ca04ca2fb3b9695.js.map and /dev/null differ diff --git a/priv/static/static/js/30.d0724c72975d6ce2243c.js b/priv/static/static/js/30.d0724c72975d6ce2243c.js new file mode 100644 index 000000000..04132ef83 Binary files /dev/null and b/priv/static/static/js/30.d0724c72975d6ce2243c.js differ diff --git a/priv/static/static/js/30.d0724c72975d6ce2243c.js.map b/priv/static/static/js/30.d0724c72975d6ce2243c.js.map new file mode 100644 index 000000000..330ad3596 Binary files /dev/null and b/priv/static/static/js/30.d0724c72975d6ce2243c.js.map differ diff --git a/priv/static/static/js/31.ef44f6a2b08f7f78dd8e.js b/priv/static/static/js/31.31627923fc0b0d75672f.js similarity index 99% rename from priv/static/static/js/31.ef44f6a2b08f7f78dd8e.js rename to priv/static/static/js/31.31627923fc0b0d75672f.js index 886c184d1..1dfae7798 100644 Binary files a/priv/static/static/js/31.ef44f6a2b08f7f78dd8e.js and b/priv/static/static/js/31.31627923fc0b0d75672f.js differ diff --git a/priv/static/static/js/31.31627923fc0b0d75672f.js.map b/priv/static/static/js/31.31627923fc0b0d75672f.js.map new file mode 100644 index 000000000..52ae7f8af Binary files /dev/null and b/priv/static/static/js/31.31627923fc0b0d75672f.js.map differ diff --git a/priv/static/static/js/31.ef44f6a2b08f7f78dd8e.js.map b/priv/static/static/js/31.ef44f6a2b08f7f78dd8e.js.map deleted file mode 100644 index 1a4bd1a0a..000000000 Binary files a/priv/static/static/js/31.ef44f6a2b08f7f78dd8e.js.map and /dev/null differ diff --git a/priv/static/static/js/32.044555dd7095261d9faf.js.map b/priv/static/static/js/32.044555dd7095261d9faf.js.map deleted file mode 100644 index f7f4094ee..000000000 Binary files a/priv/static/static/js/32.044555dd7095261d9faf.js.map and /dev/null differ diff --git a/priv/static/static/js/32.044555dd7095261d9faf.js b/priv/static/static/js/32.f628f72f0c04549e3d56.js similarity index 68% rename from priv/static/static/js/32.044555dd7095261d9faf.js rename to priv/static/static/js/32.f628f72f0c04549e3d56.js index 6ca50349e..1fd7b588f 100644 Binary files a/priv/static/static/js/32.044555dd7095261d9faf.js and b/priv/static/static/js/32.f628f72f0c04549e3d56.js differ diff --git a/priv/static/static/js/32.f628f72f0c04549e3d56.js.map b/priv/static/static/js/32.f628f72f0c04549e3d56.js.map new file mode 100644 index 000000000..8a5717322 Binary files /dev/null and b/priv/static/static/js/32.f628f72f0c04549e3d56.js.map differ diff --git a/priv/static/static/js/4.15e71ac865c2606c30a6.js b/priv/static/static/js/4.14dd3a6fcb972eb61829.js similarity index 80% rename from priv/static/static/js/4.15e71ac865c2606c30a6.js rename to priv/static/static/js/4.14dd3a6fcb972eb61829.js index 3406cc065..a92d5cc42 100644 Binary files a/priv/static/static/js/4.15e71ac865c2606c30a6.js and b/priv/static/static/js/4.14dd3a6fcb972eb61829.js differ diff --git a/priv/static/static/js/4.15e71ac865c2606c30a6.js.map b/priv/static/static/js/4.14dd3a6fcb972eb61829.js.map similarity index 99% rename from priv/static/static/js/4.15e71ac865c2606c30a6.js.map rename to priv/static/static/js/4.14dd3a6fcb972eb61829.js.map index 023d90430..3a5561a41 100644 Binary files a/priv/static/static/js/4.15e71ac865c2606c30a6.js.map and b/priv/static/static/js/4.14dd3a6fcb972eb61829.js.map differ diff --git a/priv/static/static/js/5.e116ac5b71f5e62029a1.js b/priv/static/static/js/5.41ab92595cefc4c72fe0.js similarity index 98% rename from priv/static/static/js/5.e116ac5b71f5e62029a1.js rename to priv/static/static/js/5.41ab92595cefc4c72fe0.js index acd64094e..4a7b85b13 100644 Binary files a/priv/static/static/js/5.e116ac5b71f5e62029a1.js and b/priv/static/static/js/5.41ab92595cefc4c72fe0.js differ diff --git a/priv/static/static/js/5.e116ac5b71f5e62029a1.js.map b/priv/static/static/js/5.41ab92595cefc4c72fe0.js.map similarity index 57% rename from priv/static/static/js/5.e116ac5b71f5e62029a1.js.map rename to priv/static/static/js/5.41ab92595cefc4c72fe0.js.map index 0017a3bfd..74e16ebfa 100644 Binary files a/priv/static/static/js/5.e116ac5b71f5e62029a1.js.map and b/priv/static/static/js/5.41ab92595cefc4c72fe0.js.map differ diff --git a/priv/static/static/js/6.4e804674e0bff336a51b.js b/priv/static/static/js/6.22a79587289c1f1e1e99.js similarity index 99% rename from priv/static/static/js/6.4e804674e0bff336a51b.js rename to priv/static/static/js/6.22a79587289c1f1e1e99.js index b33bbd652..e1b663f59 100644 Binary files a/priv/static/static/js/6.4e804674e0bff336a51b.js and b/priv/static/static/js/6.22a79587289c1f1e1e99.js differ diff --git a/priv/static/static/js/6.4e804674e0bff336a51b.js.map b/priv/static/static/js/6.22a79587289c1f1e1e99.js.map similarity index 57% rename from priv/static/static/js/6.4e804674e0bff336a51b.js.map rename to priv/static/static/js/6.22a79587289c1f1e1e99.js.map index bbb049a88..aa2f9be2c 100644 Binary files a/priv/static/static/js/6.4e804674e0bff336a51b.js.map and b/priv/static/static/js/6.22a79587289c1f1e1e99.js.map differ diff --git a/priv/static/static/js/7.e8595e0b6e063c6d9478.js b/priv/static/static/js/7.cf211d851ab1c77ec4c3.js similarity index 99% rename from priv/static/static/js/7.e8595e0b6e063c6d9478.js rename to priv/static/static/js/7.cf211d851ab1c77ec4c3.js index 7622e0d7a..c013d64c7 100644 Binary files a/priv/static/static/js/7.e8595e0b6e063c6d9478.js and b/priv/static/static/js/7.cf211d851ab1c77ec4c3.js differ diff --git a/priv/static/static/js/7.e8595e0b6e063c6d9478.js.map b/priv/static/static/js/7.cf211d851ab1c77ec4c3.js.map similarity index 57% rename from priv/static/static/js/7.e8595e0b6e063c6d9478.js.map rename to priv/static/static/js/7.cf211d851ab1c77ec4c3.js.map index 40327d1fd..16461348e 100644 Binary files a/priv/static/static/js/7.e8595e0b6e063c6d9478.js.map and b/priv/static/static/js/7.cf211d851ab1c77ec4c3.js.map differ diff --git a/priv/static/static/js/8.2d08c6fbb6b6ef23752f.js b/priv/static/static/js/8.08dd17e532ddcdd39742.js similarity index 99% rename from priv/static/static/js/8.2d08c6fbb6b6ef23752f.js rename to priv/static/static/js/8.08dd17e532ddcdd39742.js index 085a9e004..bf83ae385 100644 Binary files a/priv/static/static/js/8.2d08c6fbb6b6ef23752f.js and b/priv/static/static/js/8.08dd17e532ddcdd39742.js differ diff --git a/priv/static/static/js/8.2d08c6fbb6b6ef23752f.js.map b/priv/static/static/js/8.08dd17e532ddcdd39742.js.map similarity index 57% rename from priv/static/static/js/8.2d08c6fbb6b6ef23752f.js.map rename to priv/static/static/js/8.08dd17e532ddcdd39742.js.map index 50222e2be..c4c701b5f 100644 Binary files a/priv/static/static/js/8.2d08c6fbb6b6ef23752f.js.map and b/priv/static/static/js/8.08dd17e532ddcdd39742.js.map differ diff --git a/priv/static/static/js/9.7d9dd95c4a1c9aa47453.js b/priv/static/static/js/9.1ea2330cb884e98f8257.js similarity index 99% rename from priv/static/static/js/9.7d9dd95c4a1c9aa47453.js rename to priv/static/static/js/9.1ea2330cb884e98f8257.js index 41ab62b92..35cc53089 100644 Binary files a/priv/static/static/js/9.7d9dd95c4a1c9aa47453.js and b/priv/static/static/js/9.1ea2330cb884e98f8257.js differ diff --git a/priv/static/static/js/9.1ea2330cb884e98f8257.js.map b/priv/static/static/js/9.1ea2330cb884e98f8257.js.map new file mode 100644 index 000000000..f72847ec6 Binary files /dev/null and b/priv/static/static/js/9.1ea2330cb884e98f8257.js.map differ diff --git a/priv/static/static/js/9.7d9dd95c4a1c9aa47453.js.map b/priv/static/static/js/9.7d9dd95c4a1c9aa47453.js.map deleted file mode 100644 index c215e9a03..000000000 Binary files a/priv/static/static/js/9.7d9dd95c4a1c9aa47453.js.map and /dev/null differ diff --git a/priv/static/static/js/app.c6b8a1c86149ed63e6ff.js b/priv/static/static/js/app.c6b8a1c86149ed63e6ff.js new file mode 100644 index 000000000..83b640a87 Binary files /dev/null and b/priv/static/static/js/app.c6b8a1c86149ed63e6ff.js differ diff --git a/priv/static/static/js/app.c6b8a1c86149ed63e6ff.js.map b/priv/static/static/js/app.c6b8a1c86149ed63e6ff.js.map new file mode 100644 index 000000000..742d5229b Binary files /dev/null and b/priv/static/static/js/app.c6b8a1c86149ed63e6ff.js.map differ diff --git a/priv/static/static/js/app.eb8f7164fc75862a251d.js b/priv/static/static/js/app.eb8f7164fc75862a251d.js deleted file mode 100644 index 55414d124..000000000 Binary files a/priv/static/static/js/app.eb8f7164fc75862a251d.js and /dev/null differ diff --git a/priv/static/static/js/app.eb8f7164fc75862a251d.js.map b/priv/static/static/js/app.eb8f7164fc75862a251d.js.map deleted file mode 100644 index f1dbb68bb..000000000 Binary files a/priv/static/static/js/app.eb8f7164fc75862a251d.js.map and /dev/null differ diff --git a/priv/static/static/js/vendors~app.54838a79dee084ec3dad.js b/priv/static/static/js/vendors~app.3b02e2e5bd8cdca42216.js similarity index 96% rename from priv/static/static/js/vendors~app.54838a79dee084ec3dad.js rename to priv/static/static/js/vendors~app.3b02e2e5bd8cdca42216.js index 38dd65643..066573a52 100644 Binary files a/priv/static/static/js/vendors~app.54838a79dee084ec3dad.js and b/priv/static/static/js/vendors~app.3b02e2e5bd8cdca42216.js differ diff --git a/priv/static/static/js/vendors~app.54838a79dee084ec3dad.js.map b/priv/static/static/js/vendors~app.3b02e2e5bd8cdca42216.js.map similarity index 99% rename from priv/static/static/js/vendors~app.54838a79dee084ec3dad.js.map rename to priv/static/static/js/vendors~app.3b02e2e5bd8cdca42216.js.map index 35b5fd52f..72d5e4e8a 100644 Binary files a/priv/static/static/js/vendors~app.54838a79dee084ec3dad.js.map and b/priv/static/static/js/vendors~app.3b02e2e5bd8cdca42216.js.map differ diff --git a/priv/static/sw-pleroma.js b/priv/static/sw-pleroma.js index 25879eb45..6731447d4 100644 Binary files a/priv/static/sw-pleroma.js and b/priv/static/sw-pleroma.js differ diff --git a/priv/static/sw-pleroma.js.map b/priv/static/sw-pleroma.js.map index 62cea8c08..ed747c6d6 100644 Binary files a/priv/static/sw-pleroma.js.map and b/priv/static/sw-pleroma.js.map differ diff --git a/test/mix/tasks/pleroma/robots_txt_test.exs b/test/mix/tasks/pleroma/robots_txt_test.exs index 4b369d83c..028aa4ccc 100644 --- a/test/mix/tasks/pleroma/robots_txt_test.exs +++ b/test/mix/tasks/pleroma/robots_txt_test.exs @@ -12,7 +12,7 @@ defmodule Mix.Tasks.Pleroma.RobotsTxtTest do test "creates new dir" do path = "test/fixtures/new_dir/" file_path = path <> "robots.txt" - Pleroma.Config.put([:instance, :static_dir], path) + clear_config([:instance, :static_dir], path) on_exit(fn -> {:ok, ["test/fixtures/new_dir/", "test/fixtures/new_dir/robots.txt"]} = File.rm_rf(path) @@ -29,7 +29,7 @@ test "creates new dir" do test "to existance folder" do path = "test/fixtures/" file_path = path <> "robots.txt" - Pleroma.Config.put([:instance, :static_dir], path) + clear_config([:instance, :static_dir], path) on_exit(fn -> :ok = File.rm(file_path) diff --git a/test/pleroma/activity_test.exs b/test/pleroma/activity_test.exs index 83757ad56..390a06344 100644 --- a/test/pleroma/activity_test.exs +++ b/test/pleroma/activity_test.exs @@ -168,7 +168,7 @@ test "find only local statuses for unauthenticated users", %{local_activity: loc test "find only local statuses for unauthenticated users when `limit_to_local_content` is `:all`", %{local_activity: local_activity} do - Pleroma.Config.put([:instance, :limit_to_local_content], :all) + clear_config([:instance, :limit_to_local_content], :all) assert [^local_activity] = Activity.search(nil, "find me") end @@ -177,7 +177,7 @@ test "find all statuses for unauthenticated users when `limit_to_local_content` local_activity: local_activity, remote_activity: remote_activity } do - Pleroma.Config.put([:instance, :limit_to_local_content], false) + clear_config([:instance, :limit_to_local_content], false) activities = Enum.sort_by(Activity.search(nil, "find me"), & &1.id) diff --git a/test/pleroma/application_requirements_test.exs b/test/pleroma/application_requirements_test.exs index d056cc817..683ac8c96 100644 --- a/test/pleroma/application_requirements_test.exs +++ b/test/pleroma/application_requirements_test.exs @@ -9,7 +9,6 @@ defmodule Pleroma.ApplicationRequirementsTest do import Mock alias Pleroma.ApplicationRequirements - alias Pleroma.Config alias Pleroma.Repo describe "check_repo_pool_size!/1" do @@ -37,8 +36,8 @@ test "doesn't raise if the pool size is unexpected but the respective flag is se setup do: clear_config([Pleroma.Emails.Mailer]) test "raises if welcome email enabled but mail disabled" do - Pleroma.Config.put([:welcome, :email, :enabled], true) - Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false) + clear_config([:welcome, :email, :enabled], true) + clear_config([Pleroma.Emails.Mailer, :enabled], false) assert_raise Pleroma.ApplicationRequirements.VerifyError, "The mail disabled.", fn -> capture_log(&Pleroma.ApplicationRequirements.verify!/0) @@ -59,8 +58,8 @@ test "raises if welcome email enabled but mail disabled" do setup do: clear_config([:instance, :account_activation_required]) test "raises if account confirmation is required but mailer isn't enable" do - Pleroma.Config.put([:instance, :account_activation_required], true) - Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false) + clear_config([:instance, :account_activation_required], true) + clear_config([Pleroma.Emails.Mailer, :enabled], false) assert_raise Pleroma.ApplicationRequirements.VerifyError, "Account activation enabled, but Mailer is disabled. Cannot send confirmation emails.", @@ -70,14 +69,14 @@ test "raises if account confirmation is required but mailer isn't enable" do end test "doesn't do anything if account confirmation is disabled" do - Pleroma.Config.put([:instance, :account_activation_required], false) - Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false) + clear_config([:instance, :account_activation_required], false) + clear_config([Pleroma.Emails.Mailer, :enabled], false) assert Pleroma.ApplicationRequirements.verify!() == :ok end test "doesn't do anything if account confirmation is required and mailer is enabled" do - Pleroma.Config.put([:instance, :account_activation_required], true) - Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], true) + clear_config([:instance, :account_activation_required], true) + clear_config([Pleroma.Emails.Mailer, :enabled], true) assert Pleroma.ApplicationRequirements.verify!() == :ok end end @@ -93,7 +92,7 @@ test "doesn't do anything if account confirmation is required and mailer is enab setup do: clear_config([:database, :rum_enabled]) test "raises if rum is enabled and detects unapplied rum migrations" do - Config.put([:database, :rum_enabled], true) + clear_config([:database, :rum_enabled], true) with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> false end]}]) do assert_raise ApplicationRequirements.VerifyError, @@ -105,7 +104,7 @@ test "raises if rum is enabled and detects unapplied rum migrations" do end test "raises if rum is disabled and detects rum migrations" do - Config.put([:database, :rum_enabled], false) + clear_config([:database, :rum_enabled], false) with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> true end]}]) do assert_raise ApplicationRequirements.VerifyError, @@ -117,7 +116,7 @@ test "raises if rum is disabled and detects rum migrations" do end test "doesn't do anything if rum enabled and applied migrations" do - Config.put([:database, :rum_enabled], true) + clear_config([:database, :rum_enabled], true) with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> true end]}]) do assert ApplicationRequirements.verify!() == :ok @@ -125,7 +124,7 @@ test "doesn't do anything if rum enabled and applied migrations" do end test "doesn't do anything if rum disabled" do - Config.put([:database, :rum_enabled], false) + clear_config([:database, :rum_enabled], false) with_mocks([{Repo, [:passthrough], [exists?: fn _, _ -> false end]}]) do assert ApplicationRequirements.verify!() == :ok @@ -161,7 +160,7 @@ test "raises if it detects unapplied migrations" do end test "doesn't do anything if disabled" do - Config.put([:i_am_aware_this_may_cause_data_loss, :disable_migration_check], true) + clear_config([:i_am_aware_this_may_cause_data_loss, :disable_migration_check], true) assert :ok == ApplicationRequirements.verify!() end diff --git a/test/pleroma/captcha_test.exs b/test/pleroma/captcha_test.exs index 5691c9506..fcb585112 100644 --- a/test/pleroma/captcha_test.exs +++ b/test/pleroma/captcha_test.exs @@ -69,7 +69,7 @@ test "new and validate" do describe "Captcha Wrapper" do test "validate" do - Pleroma.Config.put([Pleroma.Captcha, :enabled], true) + clear_config([Pleroma.Captcha, :enabled], true) new = Captcha.new() @@ -83,7 +83,7 @@ test "validate" do end test "doesn't validate invalid answer" do - Pleroma.Config.put([Pleroma.Captcha, :enabled], true) + clear_config([Pleroma.Captcha, :enabled], true) new = Captcha.new() @@ -99,7 +99,7 @@ test "doesn't validate invalid answer" do end test "nil answer_data" do - Pleroma.Config.put([Pleroma.Captcha, :enabled], true) + clear_config([Pleroma.Captcha, :enabled], true) new = Captcha.new() diff --git a/test/pleroma/config_test.exs b/test/pleroma/config_test.exs index e4e7f505f..3158a2ec8 100644 --- a/test/pleroma/config_test.exs +++ b/test/pleroma/config_test.exs @@ -30,9 +30,9 @@ test "get/1 with a list of keys" do describe "nil values" do setup do - Pleroma.Config.put(:lorem, nil) - Pleroma.Config.put(:ipsum, %{dolor: [sit: nil]}) - Pleroma.Config.put(:dolor, sit: %{amet: nil}) + clear_config(:lorem, nil) + clear_config(:ipsum, %{dolor: [sit: nil]}) + clear_config(:dolor, sit: %{amet: nil}) on_exit(fn -> Enum.each(~w(lorem ipsum dolor)a, &Pleroma.Config.delete/1) end) end @@ -57,9 +57,9 @@ test "get/2 with a list of keys for nil value" do end test "get/1 when value is false" do - Pleroma.Config.put([:instance, :false_test], false) - Pleroma.Config.put([:instance, :nested], []) - Pleroma.Config.put([:instance, :nested, :false_test], false) + clear_config([:instance, :false_test], false) + clear_config([:instance, :nested], []) + clear_config([:instance, :nested, :false_test], false) assert Pleroma.Config.get([:instance, :false_test]) == false assert Pleroma.Config.get([:instance, :nested, :false_test]) == false @@ -81,40 +81,40 @@ test "get!/1" do end test "get!/1 when value is false" do - Pleroma.Config.put([:instance, :false_test], false) - Pleroma.Config.put([:instance, :nested], []) - Pleroma.Config.put([:instance, :nested, :false_test], false) + clear_config([:instance, :false_test], false) + clear_config([:instance, :nested], []) + clear_config([:instance, :nested, :false_test], false) assert Pleroma.Config.get!([:instance, :false_test]) == false assert Pleroma.Config.get!([:instance, :nested, :false_test]) == false end test "put/2 with a key" do - Pleroma.Config.put(:config_test, true) + clear_config(:config_test, true) assert Pleroma.Config.get(:config_test) == true end test "put/2 with a list of keys" do - Pleroma.Config.put([:instance, :config_test], true) - Pleroma.Config.put([:instance, :config_nested_test], []) - Pleroma.Config.put([:instance, :config_nested_test, :x], true) + clear_config([:instance, :config_test], true) + clear_config([:instance, :config_nested_test], []) + clear_config([:instance, :config_nested_test, :x], true) assert Pleroma.Config.get([:instance, :config_test]) == true assert Pleroma.Config.get([:instance, :config_nested_test, :x]) == true end test "delete/1 with a key" do - Pleroma.Config.put([:delete_me], :delete_me) + clear_config([:delete_me], :delete_me) Pleroma.Config.delete([:delete_me]) assert Pleroma.Config.get([:delete_me]) == nil end test "delete/2 with a list of keys" do - Pleroma.Config.put([:delete_me], hello: "world", world: "Hello") + clear_config([:delete_me], hello: "world", world: "Hello") Pleroma.Config.delete([:delete_me, :world]) assert Pleroma.Config.get([:delete_me]) == [hello: "world"] - Pleroma.Config.put([:delete_me, :delete_me], hello: "world", world: "Hello") + clear_config([:delete_me, :delete_me], hello: "world", world: "Hello") Pleroma.Config.delete([:delete_me, :delete_me, :world]) assert Pleroma.Config.get([:delete_me, :delete_me]) == [hello: "world"] @@ -123,8 +123,8 @@ test "delete/2 with a list of keys" do end test "fetch/1" do - Pleroma.Config.put([:lorem], :ipsum) - Pleroma.Config.put([:ipsum], dolor: :sit) + clear_config([:lorem], :ipsum) + clear_config([:ipsum], dolor: :sit) assert Pleroma.Config.fetch([:lorem]) == {:ok, :ipsum} assert Pleroma.Config.fetch(:lorem) == {:ok, :ipsum} diff --git a/test/pleroma/gun/connection_pool_test.exs b/test/pleroma/gun/connection_pool_test.exs index 9cbaf0978..4b3158625 100644 --- a/test/pleroma/gun/connection_pool_test.exs +++ b/test/pleroma/gun/connection_pool_test.exs @@ -7,7 +7,6 @@ defmodule Pleroma.Gun.ConnectionPoolTest do import Mox import ExUnit.CaptureLog - alias Pleroma.Config alias Pleroma.Gun.ConnectionPool defp gun_mock(_) do @@ -49,7 +48,7 @@ test "gives the same connection to 2 concurrent requests" do test "connection limit is respected with concurrent requests" do clear_config([:connections_pool, :max_connections]) do - Config.put([:connections_pool, :max_connections], 1) + clear_config([:connections_pool, :max_connections], 1) # The supervisor needs a reboot to apply the new config setting Process.exit(Process.whereis(Pleroma.Gun.ConnectionPool.WorkerSupervisor), :kill) diff --git a/test/pleroma/http/adapter_helper/gun_test.exs b/test/pleroma/http/adapter_helper/gun_test.exs index 8e2fd69a6..cfb68557d 100644 --- a/test/pleroma/http/adapter_helper/gun_test.exs +++ b/test/pleroma/http/adapter_helper/gun_test.exs @@ -8,7 +8,6 @@ defmodule Pleroma.HTTP.AdapterHelper.GunTest do import Mox - alias Pleroma.Config alias Pleroma.HTTP.AdapterHelper.Gun setup :verify_on_exit! @@ -52,9 +51,7 @@ test "merges with defaul http adapter config" do end test "parses string proxy host & port" do - proxy = Config.get([:http, :proxy_url]) - Config.put([:http, :proxy_url], "localhost:8123") - on_exit(fn -> Config.put([:http, :proxy_url], proxy) end) + clear_config([:http, :proxy_url], "localhost:8123") uri = URI.parse("https://some-domain.com") opts = Gun.options([receive_conn: false], uri) @@ -62,9 +59,7 @@ test "parses string proxy host & port" do end test "parses tuple proxy scheme host and port" do - proxy = Config.get([:http, :proxy_url]) - Config.put([:http, :proxy_url], {:socks, 'localhost', 1234}) - on_exit(fn -> Config.put([:http, :proxy_url], proxy) end) + clear_config([:http, :proxy_url], {:socks, 'localhost', 1234}) uri = URI.parse("https://some-domain.com") opts = Gun.options([receive_conn: false], uri) @@ -72,9 +67,7 @@ test "parses tuple proxy scheme host and port" do end test "passed opts have more weight than defaults" do - proxy = Config.get([:http, :proxy_url]) - Config.put([:http, :proxy_url], {:socks5, 'localhost', 1234}) - on_exit(fn -> Config.put([:http, :proxy_url], proxy) end) + clear_config([:http, :proxy_url], {:socks5, 'localhost', 1234}) uri = URI.parse("https://some-domain.com") opts = Gun.options([receive_conn: false, proxy: {'example.com', 4321}], uri) diff --git a/test/pleroma/object/fetcher_test.exs b/test/pleroma/object/fetcher_test.exs index d9172a3ec..a7ac90348 100644 --- a/test/pleroma/object/fetcher_test.exs +++ b/test/pleroma/object/fetcher_test.exs @@ -6,7 +6,6 @@ defmodule Pleroma.Object.FetcherTest do use Pleroma.DataCase alias Pleroma.Activity - alias Pleroma.Config alias Pleroma.Object alias Pleroma.Object.Fetcher @@ -87,20 +86,20 @@ test "it works when fetching the OP actor errors out" do setup do: clear_config([:instance, :federation_incoming_replies_max_depth]) test "it returns thread depth exceeded error if thread depth is exceeded" do - Config.put([:instance, :federation_incoming_replies_max_depth], 0) + clear_config([:instance, :federation_incoming_replies_max_depth], 0) assert {:error, "Max thread distance exceeded."} = Fetcher.fetch_object_from_id(@ap_id, depth: 1) end test "it fetches object if max thread depth is restricted to 0 and depth is not specified" do - Config.put([:instance, :federation_incoming_replies_max_depth], 0) + clear_config([:instance, :federation_incoming_replies_max_depth], 0) assert {:ok, _} = Fetcher.fetch_object_from_id(@ap_id) end test "it fetches object if requested depth does not exceed max thread depth" do - Config.put([:instance, :federation_incoming_replies_max_depth], 10) + clear_config([:instance, :federation_incoming_replies_max_depth], 10) assert {:ok, _} = Fetcher.fetch_object_from_id(@ap_id, depth: 10) end @@ -245,7 +244,7 @@ test "it can refetch pruned objects" do Pleroma.Signature, [:passthrough], [] do - Config.put([:activitypub, :sign_object_fetches], true) + clear_config([:activitypub, :sign_object_fetches], true) Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367") @@ -256,7 +255,7 @@ test "it can refetch pruned objects" do Pleroma.Signature, [:passthrough], [] do - Config.put([:activitypub, :sign_object_fetches], false) + clear_config([:activitypub, :sign_object_fetches], false) Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367") diff --git a/test/pleroma/repo/migrations/autolinker_to_linkify_test.exs b/test/pleroma/repo/migrations/autolinker_to_linkify_test.exs index b4106ef8e..a7d4d493c 100644 --- a/test/pleroma/repo/migrations/autolinker_to_linkify_test.exs +++ b/test/pleroma/repo/migrations/autolinker_to_linkify_test.exs @@ -37,7 +37,7 @@ test "change/0 converts auto_linker opts for Pleroma.Formatter", %{migration: mi strip_prefix: false ] - Pleroma.Config.put(Pleroma.Formatter, new_opts) + clear_config(Pleroma.Formatter, new_opts) assert new_opts == Pleroma.Config.get(Pleroma.Formatter) {text, _mentions, []} = diff --git a/test/pleroma/repo/migrations/fix_malformed_formatter_config_test.exs b/test/pleroma/repo/migrations/fix_malformed_formatter_config_test.exs index 30c77e8e6..65c9961b0 100644 --- a/test/pleroma/repo/migrations/fix_malformed_formatter_config_test.exs +++ b/test/pleroma/repo/migrations/fix_malformed_formatter_config_test.exs @@ -34,7 +34,7 @@ test "change/0 converts a map into a list", %{migration: migration} do strip_prefix: false ] - Pleroma.Config.put(Pleroma.Formatter, new_opts) + clear_config(Pleroma.Formatter, new_opts) assert new_opts == Pleroma.Config.get(Pleroma.Formatter) {text, _mentions, []} = diff --git a/test/pleroma/scheduled_activity_test.exs b/test/pleroma/scheduled_activity_test.exs index 10188d116..ef91e9bce 100644 --- a/test/pleroma/scheduled_activity_test.exs +++ b/test/pleroma/scheduled_activity_test.exs @@ -15,7 +15,7 @@ defmodule Pleroma.ScheduledActivityTest do describe "creation" do test "scheduled activities with jobs when ScheduledActivity enabled" do - Pleroma.Config.put([ScheduledActivity, :enabled], true) + clear_config([ScheduledActivity, :enabled], true) user = insert(:user) today = @@ -34,7 +34,7 @@ test "scheduled activities with jobs when ScheduledActivity enabled" do end test "scheduled activities without jobs when ScheduledActivity disabled" do - Pleroma.Config.put([ScheduledActivity, :enabled], false) + clear_config([ScheduledActivity, :enabled], false) user = insert(:user) today = diff --git a/test/pleroma/upload/filter/anonymize_filename_test.exs b/test/pleroma/upload/filter/anonymize_filename_test.exs index 2a067fc4b..9387c1abc 100644 --- a/test/pleroma/upload/filter/anonymize_filename_test.exs +++ b/test/pleroma/upload/filter/anonymize_filename_test.exs @@ -5,7 +5,6 @@ defmodule Pleroma.Upload.Filter.AnonymizeFilenameTest do use Pleroma.DataCase - alias Pleroma.Config alias Pleroma.Upload setup do @@ -23,13 +22,13 @@ defmodule Pleroma.Upload.Filter.AnonymizeFilenameTest do setup do: clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text]) test "it replaces filename on pre-defined text", %{upload_file: upload_file} do - Config.put([Upload.Filter.AnonymizeFilename, :text], "custom-file.png") + clear_config([Upload.Filter.AnonymizeFilename, :text], "custom-file.png") {:ok, :filtered, %Upload{name: name}} = Upload.Filter.AnonymizeFilename.filter(upload_file) assert name == "custom-file.png" end test "it replaces filename on pre-defined text expression", %{upload_file: upload_file} do - Config.put([Upload.Filter.AnonymizeFilename, :text], "custom-file.{extension}") + clear_config([Upload.Filter.AnonymizeFilename, :text], "custom-file.{extension}") {:ok, :filtered, %Upload{name: name}} = Upload.Filter.AnonymizeFilename.filter(upload_file) assert name == "custom-file.jpg" end diff --git a/test/pleroma/upload/filter_test.exs b/test/pleroma/upload/filter_test.exs index 58c842080..f0053ed9b 100644 --- a/test/pleroma/upload/filter_test.exs +++ b/test/pleroma/upload/filter_test.exs @@ -5,13 +5,12 @@ defmodule Pleroma.Upload.FilterTest do use Pleroma.DataCase - alias Pleroma.Config alias Pleroma.Upload.Filter setup do: clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text]) test "applies filters" do - Config.put([Pleroma.Upload.Filter.AnonymizeFilename, :text], "custom-file.png") + clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text], "custom-file.png") File.cp!( "test/fixtures/image.jpg", diff --git a/test/pleroma/uploaders/s3_test.exs b/test/pleroma/uploaders/s3_test.exs index 709631a6a..2711e2c8d 100644 --- a/test/pleroma/uploaders/s3_test.exs +++ b/test/pleroma/uploaders/s3_test.exs @@ -5,7 +5,6 @@ defmodule Pleroma.Uploaders.S3Test do use Pleroma.DataCase - alias Pleroma.Config alias Pleroma.Uploaders.S3 import Mock @@ -27,13 +26,13 @@ test "it returns path to local folder for files" do end test "it returns path without bucket when truncated_namespace set to ''" do - Config.put([Pleroma.Uploaders.S3], + clear_config([Pleroma.Uploaders.S3], bucket: "test_bucket", bucket_namespace: "myaccount", truncated_namespace: "" ) - Config.put([Pleroma.Upload, :base_url], "https://s3.amazonaws.com") + clear_config([Pleroma.Upload, :base_url], "https://s3.amazonaws.com") assert S3.get_file("test_image.jpg") == { :ok, @@ -42,7 +41,7 @@ test "it returns path without bucket when truncated_namespace set to ''" do end test "it returns path with bucket namespace when namespace is set" do - Config.put([Pleroma.Uploaders.S3], + clear_config([Pleroma.Uploaders.S3], bucket: "test_bucket", bucket_namespace: "family" ) diff --git a/test/pleroma/user/backup_test.exs b/test/pleroma/user/backup_test.exs index 1aab25ba6..b16152876 100644 --- a/test/pleroma/user/backup_test.exs +++ b/test/pleroma/user/backup_test.exs @@ -23,7 +23,7 @@ defmodule Pleroma.User.BackupTest do end test "it requries enabled email" do - Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false) + clear_config([Pleroma.Emails.Mailer, :enabled], false) user = insert(:user) assert {:error, "Backups require enabled email"} == Backup.create(user) end @@ -53,7 +53,7 @@ test "it return an error if the export limit is over" do end test "it process a backup record" do - Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local) + clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local) %{id: user_id} = user = insert(:user) assert {:ok, %Oban.Job{args: %{"backup_id" => backup_id} = args}} = Backup.create(user) @@ -76,8 +76,8 @@ test "it process a backup record" do end test "it removes outdated backups after creating a fresh one" do - Pleroma.Config.put([Backup, :limit_days], -1) - Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local) + clear_config([Backup, :limit_days], -1) + clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local) user = insert(:user) assert {:ok, job1} = Backup.create(user) diff --git a/test/pleroma/user/welcome_chat_message_test.exs b/test/pleroma/user/welcome_chat_message_test.exs index 06b044a32..42a45fa19 100644 --- a/test/pleroma/user/welcome_chat_message_test.exs +++ b/test/pleroma/user/welcome_chat_message_test.exs @@ -5,7 +5,6 @@ defmodule Pleroma.User.WelcomeChatMessageTest do use Pleroma.DataCase - alias Pleroma.Config alias Pleroma.User.WelcomeChatMessage import Pleroma.Factory @@ -17,10 +16,10 @@ test "send a chat welcome message" do welcome_user = insert(:user, name: "mewmew") user = insert(:user) - Config.put([:welcome, :chat_message, :enabled], true) - Config.put([:welcome, :chat_message, :sender_nickname], welcome_user.nickname) + clear_config([:welcome, :chat_message, :enabled], true) + clear_config([:welcome, :chat_message, :sender_nickname], welcome_user.nickname) - Config.put( + clear_config( [:welcome, :chat_message, :message], "Hello, welcome to Blob/Cat!" ) diff --git a/test/pleroma/user/welcome_email_test.exs b/test/pleroma/user/welcome_email_test.exs index fbfc0b45e..c3d383a7f 100644 --- a/test/pleroma/user/welcome_email_test.exs +++ b/test/pleroma/user/welcome_email_test.exs @@ -18,15 +18,15 @@ defmodule Pleroma.User.WelcomeEmailTest do test "send a welcome email" do user = insert(:user, name: "Jimm") - Config.put([:welcome, :email, :enabled], true) - Config.put([:welcome, :email, :sender], "welcome@pleroma.app") + clear_config([:welcome, :email, :enabled], true) + clear_config([:welcome, :email, :sender], "welcome@pleroma.app") - Config.put( + clear_config( [:welcome, :email, :subject], "Hello, welcome to pleroma: <%= instance_name %>" ) - Config.put( + clear_config( [:welcome, :email, :html], "

Hello <%= user.name %>.

Welcome to <%= instance_name %>

" ) @@ -44,7 +44,7 @@ test "send a welcome email" do html_body: "

Hello #{user.name}.

Welcome to #{instance_name}

" ) - Config.put([:welcome, :email, :sender], {"Pleroma App", "welcome@pleroma.app"}) + clear_config([:welcome, :email, :sender], {"Pleroma App", "welcome@pleroma.app"}) {:ok, _job} = WelcomeEmail.send_email(user) diff --git a/test/pleroma/user/welcome_message_test.exs b/test/pleroma/user/welcome_message_test.exs index cf43a0fa4..28afde943 100644 --- a/test/pleroma/user/welcome_message_test.exs +++ b/test/pleroma/user/welcome_message_test.exs @@ -5,7 +5,6 @@ defmodule Pleroma.User.WelcomeMessageTest do use Pleroma.DataCase - alias Pleroma.Config alias Pleroma.User.WelcomeMessage import Pleroma.Factory @@ -17,10 +16,10 @@ test "send a direct welcome message" do welcome_user = insert(:user) user = insert(:user, name: "Jimm") - Config.put([:welcome, :direct_message, :enabled], true) - Config.put([:welcome, :direct_message, :sender_nickname], welcome_user.nickname) + clear_config([:welcome, :direct_message, :enabled], true) + clear_config([:welcome, :direct_message, :sender_nickname], welcome_user.nickname) - Config.put( + clear_config( [:welcome, :direct_message, :message], "Hello. Welcome to Pleroma" ) diff --git a/test/pleroma/user_search_test.exs b/test/pleroma/user_search_test.exs index 78f042e55..69167bb0c 100644 --- a/test/pleroma/user_search_test.exs +++ b/test/pleroma/user_search_test.exs @@ -18,7 +18,7 @@ defmodule Pleroma.UserSearchTest do setup do: clear_config([:instance, :limit_to_local_content]) test "returns a resolved user as the first result" do - Pleroma.Config.put([:instance, :limit_to_local_content], false) + clear_config([:instance, :limit_to_local_content], false) user = insert(:user, %{nickname: "no_relation", ap_id: "https://lain.com/users/lain"}) _user = insert(:user, %{nickname: "com_user"}) @@ -199,7 +199,7 @@ test "find only local users for unauthenticated users" do end test "find only local users for authenticated users when `limit_to_local_content` is `:all`" do - Pleroma.Config.put([:instance, :limit_to_local_content], :all) + clear_config([:instance, :limit_to_local_content], :all) %{id: id} = insert(:user, %{name: "lain"}) insert(:user, %{name: "ebn", nickname: "lain@mastodon.social", local: false}) @@ -209,7 +209,7 @@ test "find only local users for authenticated users when `limit_to_local_content end test "find all users for unauthenticated users when `limit_to_local_content` is `false`" do - Pleroma.Config.put([:instance, :limit_to_local_content], false) + clear_config([:instance, :limit_to_local_content], false) u1 = insert(:user, %{name: "lain"}) u2 = insert(:user, %{name: "ebn", nickname: "lain@mastodon.social", local: false}) diff --git a/test/pleroma/user_test.exs b/test/pleroma/user_test.exs index 90fef34bd..ae6fc4c0d 100644 --- a/test/pleroma/user_test.exs +++ b/test/pleroma/user_test.exs @@ -311,7 +311,7 @@ test "local users do not automatically follow local locked accounts" do setup do: clear_config([:instance, :external_user_synchronization]) test "unfollow with syncronizes external user" do - Pleroma.Config.put([:instance, :external_user_synchronization], true) + clear_config([:instance, :external_user_synchronization], true) followed = insert(:user, @@ -396,7 +396,7 @@ test "it autofollows accounts that are set for it" do user = insert(:user) remote_user = insert(:user, %{local: false}) - Pleroma.Config.put([:instance, :autofollowed_nicknames], [ + clear_config([:instance, :autofollowed_nicknames], [ user.nickname, remote_user.nickname ]) @@ -413,7 +413,7 @@ test "it adds automatic followers for new registered accounts" do user1 = insert(:user) user2 = insert(:user) - Pleroma.Config.put([:instance, :autofollowing_nicknames], [ + clear_config([:instance, :autofollowing_nicknames], [ user1.nickname, user2.nickname ]) @@ -428,9 +428,9 @@ test "it adds automatic followers for new registered accounts" do test "it sends a welcome message if it is set" do welcome_user = insert(:user) - Pleroma.Config.put([:welcome, :direct_message, :enabled], true) - Pleroma.Config.put([:welcome, :direct_message, :sender_nickname], welcome_user.nickname) - Pleroma.Config.put([:welcome, :direct_message, :message], "Hello, this is a direct message") + clear_config([:welcome, :direct_message, :enabled], true) + clear_config([:welcome, :direct_message, :sender_nickname], welcome_user.nickname) + clear_config([:welcome, :direct_message, :message], "Hello, this is a direct message") cng = User.register_changeset(%User{}, @full_user_data) {:ok, registered_user} = User.register(cng) @@ -444,9 +444,9 @@ test "it sends a welcome message if it is set" do test "it sends a welcome chat message if it is set" do welcome_user = insert(:user) - Pleroma.Config.put([:welcome, :chat_message, :enabled], true) - Pleroma.Config.put([:welcome, :chat_message, :sender_nickname], welcome_user.nickname) - Pleroma.Config.put([:welcome, :chat_message, :message], "Hello, this is a chat message") + clear_config([:welcome, :chat_message, :enabled], true) + clear_config([:welcome, :chat_message, :sender_nickname], welcome_user.nickname) + clear_config([:welcome, :chat_message, :message], "Hello, this is a chat message") cng = User.register_changeset(%User{}, @full_user_data) {:ok, registered_user} = User.register(cng) @@ -480,12 +480,12 @@ test "it sends a welcome chat message if it is set" do ) test "it sends a welcome chat message when Simple policy applied to local instance" do - Pleroma.Config.put([:mrf_simple, :media_nsfw], ["localhost"]) + clear_config([:mrf_simple, :media_nsfw], ["localhost"]) welcome_user = insert(:user) - Pleroma.Config.put([:welcome, :chat_message, :enabled], true) - Pleroma.Config.put([:welcome, :chat_message, :sender_nickname], welcome_user.nickname) - Pleroma.Config.put([:welcome, :chat_message, :message], "Hello, this is a chat message") + clear_config([:welcome, :chat_message, :enabled], true) + clear_config([:welcome, :chat_message, :sender_nickname], welcome_user.nickname) + clear_config([:welcome, :chat_message, :message], "Hello, this is a chat message") cng = User.register_changeset(%User{}, @full_user_data) {:ok, registered_user} = User.register(cng) @@ -499,10 +499,10 @@ test "it sends a welcome chat message when Simple policy applied to local instan test "it sends a welcome email message if it is set" do welcome_user = insert(:user) - Pleroma.Config.put([:welcome, :email, :enabled], true) - Pleroma.Config.put([:welcome, :email, :sender], welcome_user.email) + clear_config([:welcome, :email, :enabled], true) + clear_config([:welcome, :email, :sender], welcome_user.email) - Pleroma.Config.put( + clear_config( [:welcome, :email, :subject], "Hello, welcome to cool site: <%= instance_name %>" ) @@ -522,7 +522,7 @@ test "it sends a welcome email message if it is set" do end test "it sends a confirm email" do - Pleroma.Config.put([:instance, :account_activation_required], true) + clear_config([:instance, :account_activation_required], true) cng = User.register_changeset(%User{}, @full_user_data) {:ok, registered_user} = User.register(cng) @@ -552,7 +552,7 @@ test "sends a pending approval email" do end test "it requires an email, name, nickname and password, bio is optional when account_activation_required is enabled" do - Pleroma.Config.put([:instance, :account_activation_required], true) + clear_config([:instance, :account_activation_required], true) @full_user_data |> Map.keys() @@ -565,7 +565,7 @@ test "it requires an email, name, nickname and password, bio is optional when ac end test "it requires an name, nickname and password, bio and email are optional when account_activation_required is disabled" do - Pleroma.Config.put([:instance, :account_activation_required], false) + clear_config([:instance, :account_activation_required], false) @full_user_data |> Map.keys() @@ -1712,13 +1712,13 @@ test "User.delete() plugs any possible zombie objects" do setup do: clear_config([:instance, :account_activation_required]) test "return confirmation_pending for unconfirm user" do - Pleroma.Config.put([:instance, :account_activation_required], true) + clear_config([:instance, :account_activation_required], true) user = insert(:user, is_confirmed: false) assert User.account_status(user) == :confirmation_pending end test "return active for confirmed user" do - Pleroma.Config.put([:instance, :account_activation_required], true) + clear_config([:instance, :account_activation_required], true) user = insert(:user, is_confirmed: true) assert User.account_status(user) == :active end @@ -1797,7 +1797,7 @@ test "returns true when the account is itself" do end test "returns false when the account is unconfirmed and confirmation is required" do - Pleroma.Config.put([:instance, :account_activation_required], true) + clear_config([:instance, :account_activation_required], true) user = insert(:user, local: true, is_confirmed: false) other_user = insert(:user, local: true) @@ -1806,7 +1806,7 @@ test "returns false when the account is unconfirmed and confirmation is required end test "returns true when the account is unconfirmed and confirmation is required but the account is remote" do - Pleroma.Config.put([:instance, :account_activation_required], true) + clear_config([:instance, :account_activation_required], true) user = insert(:user, local: false, is_confirmed: false) other_user = insert(:user, local: true) @@ -1815,7 +1815,7 @@ test "returns true when the account is unconfirmed and confirmation is required end test "returns true when the account is unconfirmed and being viewed by a privileged account (confirmation required)" do - Pleroma.Config.put([:instance, :account_activation_required], true) + clear_config([:instance, :account_activation_required], true) user = insert(:user, local: true, is_confirmed: false) other_user = insert(:user, local: true, is_admin: true) @@ -2072,7 +2072,7 @@ test "performs update cache if user updated" do setup do: clear_config([:instance, :external_user_synchronization]) test "updates the counters normally on following/getting a follow when disabled" do - Pleroma.Config.put([:instance, :external_user_synchronization], false) + clear_config([:instance, :external_user_synchronization], false) user = insert(:user) other_user = @@ -2093,7 +2093,7 @@ test "updates the counters normally on following/getting a follow when disabled" end test "syncronizes the counters with the remote instance for the followed when enabled" do - Pleroma.Config.put([:instance, :external_user_synchronization], false) + clear_config([:instance, :external_user_synchronization], false) user = insert(:user) @@ -2108,14 +2108,14 @@ test "syncronizes the counters with the remote instance for the followed when en assert other_user.following_count == 0 assert other_user.follower_count == 0 - Pleroma.Config.put([:instance, :external_user_synchronization], true) + clear_config([:instance, :external_user_synchronization], true) {:ok, _user, other_user} = User.follow(user, other_user) assert other_user.follower_count == 437 end test "syncronizes the counters with the remote instance for the follower when enabled" do - Pleroma.Config.put([:instance, :external_user_synchronization], false) + clear_config([:instance, :external_user_synchronization], false) user = insert(:user) @@ -2130,7 +2130,7 @@ test "syncronizes the counters with the remote instance for the follower when en assert other_user.following_count == 0 assert other_user.follower_count == 0 - Pleroma.Config.put([:instance, :external_user_synchronization], true) + clear_config([:instance, :external_user_synchronization], true) {:ok, other_user, _user} = User.follow(other_user, user) assert other_user.following_count == 152 @@ -2177,43 +2177,43 @@ test "changes email", %{user: user} do test "allows getting remote users by id no matter what :limit_to_local_content is set to", %{ remote_user: remote_user } do - Pleroma.Config.put([:instance, :limit_to_local_content], false) + clear_config([:instance, :limit_to_local_content], false) assert %User{} = User.get_cached_by_nickname_or_id(remote_user.id) - Pleroma.Config.put([:instance, :limit_to_local_content], true) + clear_config([:instance, :limit_to_local_content], true) assert %User{} = User.get_cached_by_nickname_or_id(remote_user.id) - Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated) + clear_config([:instance, :limit_to_local_content], :unauthenticated) assert %User{} = User.get_cached_by_nickname_or_id(remote_user.id) end test "disallows getting remote users by nickname without authentication when :limit_to_local_content is set to :unauthenticated", %{remote_user: remote_user} do - Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated) + clear_config([:instance, :limit_to_local_content], :unauthenticated) assert nil == User.get_cached_by_nickname_or_id(remote_user.nickname) end test "allows getting remote users by nickname with authentication when :limit_to_local_content is set to :unauthenticated", %{remote_user: remote_user, local_user: local_user} do - Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated) + clear_config([:instance, :limit_to_local_content], :unauthenticated) assert %User{} = User.get_cached_by_nickname_or_id(remote_user.nickname, for: local_user) end test "disallows getting remote users by nickname when :limit_to_local_content is set to true", %{remote_user: remote_user} do - Pleroma.Config.put([:instance, :limit_to_local_content], true) + clear_config([:instance, :limit_to_local_content], true) assert nil == User.get_cached_by_nickname_or_id(remote_user.nickname) end test "allows getting local users by nickname no matter what :limit_to_local_content is set to", %{local_user: local_user} do - Pleroma.Config.put([:instance, :limit_to_local_content], false) + clear_config([:instance, :limit_to_local_content], false) assert %User{} = User.get_cached_by_nickname_or_id(local_user.nickname) - Pleroma.Config.put([:instance, :limit_to_local_content], true) + clear_config([:instance, :limit_to_local_content], true) assert %User{} = User.get_cached_by_nickname_or_id(local_user.nickname) - Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated) + clear_config([:instance, :limit_to_local_content], :unauthenticated) assert %User{} = User.get_cached_by_nickname_or_id(local_user.nickname) end end @@ -2248,4 +2248,43 @@ test "get_host/1" do user = insert(:user, ap_id: "https://lain.com/users/lain", nickname: "lain") assert User.get_host(user) == "lain.com" end + + test "update_last_active_at/1" do + user = insert(:user) + assert is_nil(user.last_active_at) + + test_started_at = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second) + + assert {:ok, user} = User.update_last_active_at(user) + + assert user.last_active_at >= test_started_at + assert user.last_active_at <= NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) + + last_active_at = + NaiveDateTime.utc_now() + |> NaiveDateTime.add(-:timer.hours(24), :millisecond) + |> NaiveDateTime.truncate(:second) + + assert {:ok, user} = + user + |> cast(%{last_active_at: last_active_at}, [:last_active_at]) + |> User.update_and_set_cache() + + assert user.last_active_at == last_active_at + assert {:ok, user} = User.update_last_active_at(user) + assert user.last_active_at >= test_started_at + assert user.last_active_at <= NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) + end + + test "active_user_count/1" do + insert(:user) + insert(:user, %{local: false}) + insert(:user, %{last_active_at: Timex.shift(NaiveDateTime.utc_now(), weeks: -5)}) + insert(:user, %{last_active_at: Timex.shift(NaiveDateTime.utc_now(), weeks: -3)}) + insert(:user, %{last_active_at: NaiveDateTime.utc_now()}) + + assert User.active_user_count() == 2 + assert User.active_user_count(6) == 3 + assert User.active_user_count(1) == 1 + end end diff --git a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs index e0cd28303..f7417de31 100644 --- a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs @@ -7,7 +7,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do use Oban.Testing, repo: Pleroma.Repo alias Pleroma.Activity - alias Pleroma.Config alias Pleroma.Delivery alias Pleroma.Instances alias Pleroma.Object @@ -46,7 +45,7 @@ test "with the relay active, it returns the relay user", %{conn: conn} do end test "with the relay disabled, it returns 404", %{conn: conn} do - Config.put([:instance, :allow_relay], false) + clear_config([:instance, :allow_relay], false) conn |> get(activity_pub_path(conn, :relay)) @@ -54,7 +53,7 @@ test "with the relay disabled, it returns 404", %{conn: conn} do end test "on non-federating instance, it returns 404", %{conn: conn} do - Config.put([:instance, :federating], false) + clear_config([:instance, :federating], false) user = insert(:user) conn @@ -75,7 +74,7 @@ test "it returns the internal fetch user", %{conn: conn} do end test "on non-federating instance, it returns 404", %{conn: conn} do - Config.put([:instance, :federating], false) + clear_config([:instance, :federating], false) user = insert(:user) conn @@ -493,7 +492,7 @@ test "it clears `unreachable` federation status of the sender", %{conn: conn} do end test "accept follow activity", %{conn: conn} do - Pleroma.Config.put([:instance, :federating], true) + clear_config([:instance, :federating], true) relay = Relay.get_actor() assert {:ok, %Activity{} = activity} = Relay.follow("https://relay.mastodon.host/actor") @@ -539,7 +538,7 @@ test "without valid signature, " <> conn = put_req_header(conn, "content-type", "application/activity+json") - Config.put([:instance, :federating], false) + clear_config([:instance, :federating], false) conn |> post("/inbox", data) @@ -549,7 +548,7 @@ test "without valid signature, " <> |> post("/inbox", non_create_data) |> json_response(403) - Config.put([:instance, :federating], true) + clear_config([:instance, :federating], true) ret_conn = post(conn, "/inbox", data) assert "ok" == json_response(ret_conn, 200) @@ -1246,7 +1245,7 @@ test "it doesn't spreads faulty attributedTo or actor fields", %{ end test "Character limitation", %{conn: conn, activity: activity} do - Pleroma.Config.put([:instance, :limit], 5) + clear_config([:instance, :limit], 5) user = insert(:user) result = @@ -1275,7 +1274,7 @@ test "it returns relay followers", %{conn: conn} do end test "on non-federating instance, it returns 404", %{conn: conn} do - Config.put([:instance, :federating], false) + clear_config([:instance, :federating], false) user = insert(:user) conn @@ -1296,7 +1295,7 @@ test "it returns relay following", %{conn: conn} do end test "on non-federating instance, it returns 404", %{conn: conn} do - Config.put([:instance, :federating], false) + clear_config([:instance, :federating], false) user = insert(:user) conn diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs index 24576b31a..f4023856c 100644 --- a/test/pleroma/web/activity_pub/activity_pub_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_test.exs @@ -1079,15 +1079,15 @@ test "sets a description if given", %{test_file: file} do test "it sets the default description depending on the configuration", %{test_file: file} do clear_config([Pleroma.Upload, :default_description]) - Pleroma.Config.put([Pleroma.Upload, :default_description], nil) + clear_config([Pleroma.Upload, :default_description], nil) {:ok, %Object{} = object} = ActivityPub.upload(file) assert object.data["name"] == "" - Pleroma.Config.put([Pleroma.Upload, :default_description], :filename) + clear_config([Pleroma.Upload, :default_description], :filename) {:ok, %Object{} = object} = ActivityPub.upload(file) assert object.data["name"] == "an_image.jpg" - Pleroma.Config.put([Pleroma.Upload, :default_description], "unnamed attachment") + clear_config([Pleroma.Upload, :default_description], "unnamed attachment") {:ok, %Object{} = object} = ActivityPub.upload(file) assert object.data["name"] == "unnamed attachment" end diff --git a/test/pleroma/web/activity_pub/mrf/hellthread_policy_test.exs b/test/pleroma/web/activity_pub/mrf/hellthread_policy_test.exs index 2cd3e0329..439672479 100644 --- a/test/pleroma/web/activity_pub/mrf/hellthread_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/hellthread_policy_test.exs @@ -34,7 +34,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicyTest do setup do: clear_config(:mrf_hellthread) test "doesn't die on chat messages" do - Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 2, reject_threshold: 0}) + clear_config([:mrf_hellthread], %{delist_threshold: 2, reject_threshold: 0}) user = insert(:user) other_user = insert(:user) @@ -48,7 +48,7 @@ test "doesn't die on chat messages" do test "rejects the message if the recipient count is above reject_threshold", %{ message: message } do - Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 2}) + clear_config([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 2}) assert {:reject, "[HellthreadPolicy] 3 recipients is over the limit of 2"} == filter(message) @@ -57,7 +57,7 @@ test "rejects the message if the recipient count is above reject_threshold", %{ test "does not reject the message if the recipient count is below reject_threshold", %{ message: message } do - Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 3}) + clear_config([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 3}) assert {:ok, ^message} = filter(message) end @@ -68,7 +68,7 @@ test "delists the message if the recipient count is above delist_threshold", %{ user: user, message: message } do - Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 2, reject_threshold: 0}) + clear_config([:mrf_hellthread], %{delist_threshold: 2, reject_threshold: 0}) {:ok, message} = filter(message) assert user.follower_address in message["to"] @@ -78,14 +78,14 @@ test "delists the message if the recipient count is above delist_threshold", %{ test "does not delist the message if the recipient count is below delist_threshold", %{ message: message } do - Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 4, reject_threshold: 0}) + clear_config([:mrf_hellthread], %{delist_threshold: 4, reject_threshold: 0}) assert {:ok, ^message} = filter(message) end end test "excludes follower collection and public URI from threshold count", %{message: message} do - Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 3}) + clear_config([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 3}) assert {:ok, ^message} = filter(message) end diff --git a/test/pleroma/web/activity_pub/mrf/keyword_policy_test.exs b/test/pleroma/web/activity_pub/mrf/keyword_policy_test.exs index b44e6c60f..8af4c5efa 100644 --- a/test/pleroma/web/activity_pub/mrf/keyword_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/keyword_policy_test.exs @@ -10,12 +10,12 @@ defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicyTest do setup do: clear_config(:mrf_keyword) setup do - Pleroma.Config.put([:mrf_keyword], %{reject: [], federated_timeline_removal: [], replace: []}) + clear_config([:mrf_keyword], %{reject: [], federated_timeline_removal: [], replace: []}) end describe "rejecting based on keywords" do test "rejects if string matches in content" do - Pleroma.Config.put([:mrf_keyword, :reject], ["pun"]) + clear_config([:mrf_keyword, :reject], ["pun"]) message = %{ "type" => "Create", @@ -30,7 +30,7 @@ test "rejects if string matches in content" do end test "rejects if string matches in summary" do - Pleroma.Config.put([:mrf_keyword, :reject], ["pun"]) + clear_config([:mrf_keyword, :reject], ["pun"]) message = %{ "type" => "Create", @@ -45,7 +45,7 @@ test "rejects if string matches in summary" do end test "rejects if regex matches in content" do - Pleroma.Config.put([:mrf_keyword, :reject], [~r/comp[lL][aA][iI][nN]er/]) + clear_config([:mrf_keyword, :reject], [~r/comp[lL][aA][iI][nN]er/]) assert true == Enum.all?(["complainer", "compLainer", "compLAiNer", "compLAINer"], fn content -> @@ -63,7 +63,7 @@ test "rejects if regex matches in content" do end test "rejects if regex matches in summary" do - Pleroma.Config.put([:mrf_keyword, :reject], [~r/comp[lL][aA][iI][nN]er/]) + clear_config([:mrf_keyword, :reject], [~r/comp[lL][aA][iI][nN]er/]) assert true == Enum.all?(["complainer", "compLainer", "compLAiNer", "compLAINer"], fn content -> @@ -83,7 +83,7 @@ test "rejects if regex matches in summary" do describe "delisting from ftl based on keywords" do test "delists if string matches in content" do - Pleroma.Config.put([:mrf_keyword, :federated_timeline_removal], ["pun"]) + clear_config([:mrf_keyword, :federated_timeline_removal], ["pun"]) message = %{ "to" => ["https://www.w3.org/ns/activitystreams#Public"], @@ -100,7 +100,7 @@ test "delists if string matches in content" do end test "delists if string matches in summary" do - Pleroma.Config.put([:mrf_keyword, :federated_timeline_removal], ["pun"]) + clear_config([:mrf_keyword, :federated_timeline_removal], ["pun"]) message = %{ "to" => ["https://www.w3.org/ns/activitystreams#Public"], @@ -117,7 +117,7 @@ test "delists if string matches in summary" do end test "delists if regex matches in content" do - Pleroma.Config.put([:mrf_keyword, :federated_timeline_removal], [~r/comp[lL][aA][iI][nN]er/]) + clear_config([:mrf_keyword, :federated_timeline_removal], [~r/comp[lL][aA][iI][nN]er/]) assert true == Enum.all?(["complainer", "compLainer", "compLAiNer", "compLAINer"], fn content -> @@ -138,7 +138,7 @@ test "delists if regex matches in content" do end test "delists if regex matches in summary" do - Pleroma.Config.put([:mrf_keyword, :federated_timeline_removal], [~r/comp[lL][aA][iI][nN]er/]) + clear_config([:mrf_keyword, :federated_timeline_removal], [~r/comp[lL][aA][iI][nN]er/]) assert true == Enum.all?(["complainer", "compLainer", "compLAiNer", "compLAINer"], fn content -> @@ -161,7 +161,7 @@ test "delists if regex matches in summary" do describe "replacing keywords" do test "replaces keyword if string matches in content" do - Pleroma.Config.put([:mrf_keyword, :replace], [{"opensource", "free software"}]) + clear_config([:mrf_keyword, :replace], [{"opensource", "free software"}]) message = %{ "type" => "Create", @@ -174,7 +174,7 @@ test "replaces keyword if string matches in content" do end test "replaces keyword if string matches in summary" do - Pleroma.Config.put([:mrf_keyword, :replace], [{"opensource", "free software"}]) + clear_config([:mrf_keyword, :replace], [{"opensource", "free software"}]) message = %{ "type" => "Create", @@ -187,7 +187,7 @@ test "replaces keyword if string matches in summary" do end test "replaces keyword if regex matches in content" do - Pleroma.Config.put([:mrf_keyword, :replace], [ + clear_config([:mrf_keyword, :replace], [ {~r/open(-|\s)?source\s?(software)?/, "free software"} ]) @@ -205,7 +205,7 @@ test "replaces keyword if regex matches in content" do end test "replaces keyword if regex matches in summary" do - Pleroma.Config.put([:mrf_keyword, :replace], [ + clear_config([:mrf_keyword, :replace], [ {~r/open(-|\s)?source\s?(software)?/, "free software"} ]) diff --git a/test/pleroma/web/activity_pub/mrf/mention_policy_test.exs b/test/pleroma/web/activity_pub/mrf/mention_policy_test.exs index b1d0f587c..80ddcacbe 100644 --- a/test/pleroma/web/activity_pub/mrf/mention_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/mention_policy_test.exs @@ -23,7 +23,7 @@ test "pass filter if allow list is empty" do describe "allow" do test "empty" do - Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]}) + clear_config([:mrf_mention], %{actors: ["https://example.com/blocked"]}) message = %{ "type" => "Create" @@ -33,7 +33,7 @@ test "empty" do end test "to" do - Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]}) + clear_config([:mrf_mention], %{actors: ["https://example.com/blocked"]}) message = %{ "type" => "Create", @@ -44,7 +44,7 @@ test "to" do end test "cc" do - Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]}) + clear_config([:mrf_mention], %{actors: ["https://example.com/blocked"]}) message = %{ "type" => "Create", @@ -55,7 +55,7 @@ test "cc" do end test "both" do - Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]}) + clear_config([:mrf_mention], %{actors: ["https://example.com/blocked"]}) message = %{ "type" => "Create", @@ -69,7 +69,7 @@ test "both" do describe "deny" do test "to" do - Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]}) + clear_config([:mrf_mention], %{actors: ["https://example.com/blocked"]}) message = %{ "type" => "Create", @@ -81,7 +81,7 @@ test "to" do end test "cc" do - Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]}) + clear_config([:mrf_mention], %{actors: ["https://example.com/blocked"]}) message = %{ "type" => "Create", diff --git a/test/pleroma/web/activity_pub/mrf/object_age_policy_test.exs b/test/pleroma/web/activity_pub/mrf/object_age_policy_test.exs index 9178ca2b1..137aafd39 100644 --- a/test/pleroma/web/activity_pub/mrf/object_age_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/object_age_policy_test.exs @@ -4,7 +4,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do use Pleroma.DataCase - alias Pleroma.Config alias Pleroma.User alias Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy alias Pleroma.Web.ActivityPub.Visibility @@ -39,7 +38,7 @@ defp get_new_message do describe "with reject action" do test "works with objects with empty to or cc fields" do - Config.put([:mrf_object_age, :actions], [:reject]) + clear_config([:mrf_object_age, :actions], [:reject]) data = get_old_message() @@ -50,7 +49,7 @@ test "works with objects with empty to or cc fields" do end test "it rejects an old post" do - Config.put([:mrf_object_age, :actions], [:reject]) + clear_config([:mrf_object_age, :actions], [:reject]) data = get_old_message() @@ -58,7 +57,7 @@ test "it rejects an old post" do end test "it allows a new post" do - Config.put([:mrf_object_age, :actions], [:reject]) + clear_config([:mrf_object_age, :actions], [:reject]) data = get_new_message() @@ -68,7 +67,7 @@ test "it allows a new post" do describe "with delist action" do test "works with objects with empty to or cc fields" do - Config.put([:mrf_object_age, :actions], [:delist]) + clear_config([:mrf_object_age, :actions], [:delist]) data = get_old_message() @@ -83,7 +82,7 @@ test "works with objects with empty to or cc fields" do end test "it delists an old post" do - Config.put([:mrf_object_age, :actions], [:delist]) + clear_config([:mrf_object_age, :actions], [:delist]) data = get_old_message() @@ -95,7 +94,7 @@ test "it delists an old post" do end test "it allows a new post" do - Config.put([:mrf_object_age, :actions], [:delist]) + clear_config([:mrf_object_age, :actions], [:delist]) data = get_new_message() @@ -107,7 +106,7 @@ test "it allows a new post" do describe "with strip_followers action" do test "works with objects with empty to or cc fields" do - Config.put([:mrf_object_age, :actions], [:strip_followers]) + clear_config([:mrf_object_age, :actions], [:strip_followers]) data = get_old_message() @@ -123,7 +122,7 @@ test "works with objects with empty to or cc fields" do end test "it strips followers collections from an old post" do - Config.put([:mrf_object_age, :actions], [:strip_followers]) + clear_config([:mrf_object_age, :actions], [:strip_followers]) data = get_old_message() @@ -136,7 +135,7 @@ test "it strips followers collections from an old post" do end test "it allows a new post" do - Config.put([:mrf_object_age, :actions], [:strip_followers]) + clear_config([:mrf_object_age, :actions], [:strip_followers]) data = get_new_message() diff --git a/test/pleroma/web/activity_pub/mrf/reject_non_public_test.exs b/test/pleroma/web/activity_pub/mrf/reject_non_public_test.exs index 8e14b21ef..63c68d798 100644 --- a/test/pleroma/web/activity_pub/mrf/reject_non_public_test.exs +++ b/test/pleroma/web/activity_pub/mrf/reject_non_public_test.exs @@ -49,7 +49,7 @@ test "it's allowed when addrer of message in the follower addresses of user and "type" => "Create" } - Pleroma.Config.put([:mrf_rejectnonpublic, :allow_followersonly], true) + clear_config([:mrf_rejectnonpublic, :allow_followersonly], true) assert {:ok, _message} = RejectNonPublic.filter(message) end @@ -63,7 +63,7 @@ test "it's rejected when addrer of message in the follower addresses of user and "type" => "Create" } - Pleroma.Config.put([:mrf_rejectnonpublic, :allow_followersonly], false) + clear_config([:mrf_rejectnonpublic, :allow_followersonly], false) assert {:reject, _} = RejectNonPublic.filter(message) end end @@ -79,7 +79,7 @@ test "it's allows when direct messages are allow" do "type" => "Create" } - Pleroma.Config.put([:mrf_rejectnonpublic, :allow_direct], true) + clear_config([:mrf_rejectnonpublic, :allow_direct], true) assert {:ok, _message} = RejectNonPublic.filter(message) end @@ -93,7 +93,7 @@ test "it's reject when direct messages aren't allow" do "type" => "Create" } - Pleroma.Config.put([:mrf_rejectnonpublic, :allow_direct], false) + clear_config([:mrf_rejectnonpublic, :allow_direct], false) assert {:reject, _} = RejectNonPublic.filter(message) end end diff --git a/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs b/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs index 60a20a80e..f48e5b39b 100644 --- a/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs @@ -5,7 +5,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do use Pleroma.DataCase import Pleroma.Factory - alias Pleroma.Config alias Pleroma.Web.ActivityPub.MRF.SimplePolicy alias Pleroma.Web.CommonAPI @@ -25,7 +24,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do describe "when :media_removal" do test "is empty" do - Config.put([:mrf_simple, :media_removal], []) + clear_config([:mrf_simple, :media_removal], []) media_message = build_media_message() local_message = build_local_message() @@ -34,7 +33,7 @@ test "is empty" do end test "has a matching host" do - Config.put([:mrf_simple, :media_removal], ["remote.instance"]) + clear_config([:mrf_simple, :media_removal], ["remote.instance"]) media_message = build_media_message() local_message = build_local_message() @@ -47,7 +46,7 @@ test "has a matching host" do end test "match with wildcard domain" do - Config.put([:mrf_simple, :media_removal], ["*.remote.instance"]) + clear_config([:mrf_simple, :media_removal], ["*.remote.instance"]) media_message = build_media_message() local_message = build_local_message() @@ -62,7 +61,7 @@ test "match with wildcard domain" do describe "when :media_nsfw" do test "is empty" do - Config.put([:mrf_simple, :media_nsfw], []) + clear_config([:mrf_simple, :media_nsfw], []) media_message = build_media_message() local_message = build_local_message() @@ -71,7 +70,7 @@ test "is empty" do end test "has a matching host" do - Config.put([:mrf_simple, :media_nsfw], ["remote.instance"]) + clear_config([:mrf_simple, :media_nsfw], ["remote.instance"]) media_message = build_media_message() local_message = build_local_message() @@ -85,7 +84,7 @@ test "has a matching host" do end test "match with wildcard domain" do - Config.put([:mrf_simple, :media_nsfw], ["*.remote.instance"]) + clear_config([:mrf_simple, :media_nsfw], ["*.remote.instance"]) media_message = build_media_message() local_message = build_local_message() @@ -113,7 +112,7 @@ defp build_media_message do describe "when :report_removal" do test "is empty" do - Config.put([:mrf_simple, :report_removal], []) + clear_config([:mrf_simple, :report_removal], []) report_message = build_report_message() local_message = build_local_message() @@ -122,7 +121,7 @@ test "is empty" do end test "has a matching host" do - Config.put([:mrf_simple, :report_removal], ["remote.instance"]) + clear_config([:mrf_simple, :report_removal], ["remote.instance"]) report_message = build_report_message() local_message = build_local_message() @@ -131,7 +130,7 @@ test "has a matching host" do end test "match with wildcard domain" do - Config.put([:mrf_simple, :report_removal], ["*.remote.instance"]) + clear_config([:mrf_simple, :report_removal], ["*.remote.instance"]) report_message = build_report_message() local_message = build_local_message() @@ -149,7 +148,7 @@ defp build_report_message do describe "when :federated_timeline_removal" do test "is empty" do - Config.put([:mrf_simple, :federated_timeline_removal], []) + clear_config([:mrf_simple, :federated_timeline_removal], []) {_, ftl_message} = build_ftl_actor_and_message() local_message = build_local_message() @@ -166,7 +165,7 @@ test "has a matching host" do |> URI.parse() |> Map.fetch!(:host) - Config.put([:mrf_simple, :federated_timeline_removal], [ftl_message_actor_host]) + clear_config([:mrf_simple, :federated_timeline_removal], [ftl_message_actor_host]) local_message = build_local_message() assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message) @@ -187,7 +186,7 @@ test "match with wildcard domain" do |> URI.parse() |> Map.fetch!(:host) - Config.put([:mrf_simple, :federated_timeline_removal], ["*." <> ftl_message_actor_host]) + clear_config([:mrf_simple, :federated_timeline_removal], ["*." <> ftl_message_actor_host]) local_message = build_local_message() assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message) @@ -210,7 +209,7 @@ test "has a matching host but only as:Public in to" do ftl_message = Map.put(ftl_message, "cc", []) - Config.put([:mrf_simple, :federated_timeline_removal], [ftl_message_actor_host]) + clear_config([:mrf_simple, :federated_timeline_removal], [ftl_message_actor_host]) assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message) refute "https://www.w3.org/ns/activitystreams#Public" in ftl_message["to"] @@ -231,7 +230,7 @@ defp build_ftl_actor_and_message do describe "when :reject" do test "is empty" do - Config.put([:mrf_simple, :reject], []) + clear_config([:mrf_simple, :reject], []) remote_message = build_remote_message() @@ -239,7 +238,7 @@ test "is empty" do end test "activity has a matching host" do - Config.put([:mrf_simple, :reject], ["remote.instance"]) + clear_config([:mrf_simple, :reject], ["remote.instance"]) remote_message = build_remote_message() @@ -247,7 +246,7 @@ test "activity has a matching host" do end test "activity matches with wildcard domain" do - Config.put([:mrf_simple, :reject], ["*.remote.instance"]) + clear_config([:mrf_simple, :reject], ["*.remote.instance"]) remote_message = build_remote_message() @@ -255,7 +254,7 @@ test "activity matches with wildcard domain" do end test "actor has a matching host" do - Config.put([:mrf_simple, :reject], ["remote.instance"]) + clear_config([:mrf_simple, :reject], ["remote.instance"]) remote_user = build_remote_user() @@ -265,7 +264,7 @@ test "actor has a matching host" do describe "when :followers_only" do test "is empty" do - Config.put([:mrf_simple, :followers_only], []) + clear_config([:mrf_simple, :followers_only], []) {_, ftl_message} = build_ftl_actor_and_message() local_message = build_local_message() @@ -305,7 +304,7 @@ test "has a matching host" do |> URI.parse() |> Map.fetch!(:host) - Config.put([:mrf_simple, :followers_only], [actor_domain]) + clear_config([:mrf_simple, :followers_only], [actor_domain]) assert {:ok, new_activity} = SimplePolicy.filter(activity) assert actor.follower_address in new_activity["cc"] @@ -323,7 +322,7 @@ test "has a matching host" do describe "when :accept" do test "is empty" do - Config.put([:mrf_simple, :accept], []) + clear_config([:mrf_simple, :accept], []) local_message = build_local_message() remote_message = build_remote_message() @@ -333,7 +332,7 @@ test "is empty" do end test "is not empty but activity doesn't have a matching host" do - Config.put([:mrf_simple, :accept], ["non.matching.remote"]) + clear_config([:mrf_simple, :accept], ["non.matching.remote"]) local_message = build_local_message() remote_message = build_remote_message() @@ -343,7 +342,7 @@ test "is not empty but activity doesn't have a matching host" do end test "activity has a matching host" do - Config.put([:mrf_simple, :accept], ["remote.instance"]) + clear_config([:mrf_simple, :accept], ["remote.instance"]) local_message = build_local_message() remote_message = build_remote_message() @@ -353,7 +352,7 @@ test "activity has a matching host" do end test "activity matches with wildcard domain" do - Config.put([:mrf_simple, :accept], ["*.remote.instance"]) + clear_config([:mrf_simple, :accept], ["*.remote.instance"]) local_message = build_local_message() remote_message = build_remote_message() @@ -363,7 +362,7 @@ test "activity matches with wildcard domain" do end test "actor has a matching host" do - Config.put([:mrf_simple, :accept], ["remote.instance"]) + clear_config([:mrf_simple, :accept], ["remote.instance"]) remote_user = build_remote_user() @@ -373,7 +372,7 @@ test "actor has a matching host" do describe "when :avatar_removal" do test "is empty" do - Config.put([:mrf_simple, :avatar_removal], []) + clear_config([:mrf_simple, :avatar_removal], []) remote_user = build_remote_user() @@ -381,7 +380,7 @@ test "is empty" do end test "is not empty but it doesn't have a matching host" do - Config.put([:mrf_simple, :avatar_removal], ["non.matching.remote"]) + clear_config([:mrf_simple, :avatar_removal], ["non.matching.remote"]) remote_user = build_remote_user() @@ -389,7 +388,7 @@ test "is not empty but it doesn't have a matching host" do end test "has a matching host" do - Config.put([:mrf_simple, :avatar_removal], ["remote.instance"]) + clear_config([:mrf_simple, :avatar_removal], ["remote.instance"]) remote_user = build_remote_user() {:ok, filtered} = SimplePolicy.filter(remote_user) @@ -398,7 +397,7 @@ test "has a matching host" do end test "match with wildcard domain" do - Config.put([:mrf_simple, :avatar_removal], ["*.remote.instance"]) + clear_config([:mrf_simple, :avatar_removal], ["*.remote.instance"]) remote_user = build_remote_user() {:ok, filtered} = SimplePolicy.filter(remote_user) @@ -409,7 +408,7 @@ test "match with wildcard domain" do describe "when :banner_removal" do test "is empty" do - Config.put([:mrf_simple, :banner_removal], []) + clear_config([:mrf_simple, :banner_removal], []) remote_user = build_remote_user() @@ -417,7 +416,7 @@ test "is empty" do end test "is not empty but it doesn't have a matching host" do - Config.put([:mrf_simple, :banner_removal], ["non.matching.remote"]) + clear_config([:mrf_simple, :banner_removal], ["non.matching.remote"]) remote_user = build_remote_user() @@ -425,7 +424,7 @@ test "is not empty but it doesn't have a matching host" do end test "has a matching host" do - Config.put([:mrf_simple, :banner_removal], ["remote.instance"]) + clear_config([:mrf_simple, :banner_removal], ["remote.instance"]) remote_user = build_remote_user() {:ok, filtered} = SimplePolicy.filter(remote_user) @@ -434,7 +433,7 @@ test "has a matching host" do end test "match with wildcard domain" do - Config.put([:mrf_simple, :banner_removal], ["*.remote.instance"]) + clear_config([:mrf_simple, :banner_removal], ["*.remote.instance"]) remote_user = build_remote_user() {:ok, filtered} = SimplePolicy.filter(remote_user) @@ -444,10 +443,10 @@ test "match with wildcard domain" do end describe "when :reject_deletes is empty" do - setup do: Config.put([:mrf_simple, :reject_deletes], []) + setup do: clear_config([:mrf_simple, :reject_deletes], []) test "it accepts deletions even from rejected servers" do - Config.put([:mrf_simple, :reject], ["remote.instance"]) + clear_config([:mrf_simple, :reject], ["remote.instance"]) deletion_message = build_remote_deletion_message() @@ -455,7 +454,7 @@ test "it accepts deletions even from rejected servers" do end test "it accepts deletions even from non-whitelisted servers" do - Config.put([:mrf_simple, :accept], ["non.matching.remote"]) + clear_config([:mrf_simple, :accept], ["non.matching.remote"]) deletion_message = build_remote_deletion_message() @@ -464,10 +463,10 @@ test "it accepts deletions even from non-whitelisted servers" do end describe "when :reject_deletes is not empty but it doesn't have a matching host" do - setup do: Config.put([:mrf_simple, :reject_deletes], ["non.matching.remote"]) + setup do: clear_config([:mrf_simple, :reject_deletes], ["non.matching.remote"]) test "it accepts deletions even from rejected servers" do - Config.put([:mrf_simple, :reject], ["remote.instance"]) + clear_config([:mrf_simple, :reject], ["remote.instance"]) deletion_message = build_remote_deletion_message() @@ -475,7 +474,7 @@ test "it accepts deletions even from rejected servers" do end test "it accepts deletions even from non-whitelisted servers" do - Config.put([:mrf_simple, :accept], ["non.matching.remote"]) + clear_config([:mrf_simple, :accept], ["non.matching.remote"]) deletion_message = build_remote_deletion_message() @@ -484,7 +483,7 @@ test "it accepts deletions even from non-whitelisted servers" do end describe "when :reject_deletes has a matching host" do - setup do: Config.put([:mrf_simple, :reject_deletes], ["remote.instance"]) + setup do: clear_config([:mrf_simple, :reject_deletes], ["remote.instance"]) test "it rejects the deletion" do deletion_message = build_remote_deletion_message() @@ -494,7 +493,7 @@ test "it rejects the deletion" do end describe "when :reject_deletes match with wildcard domain" do - setup do: Config.put([:mrf_simple, :reject_deletes], ["*.remote.instance"]) + setup do: clear_config([:mrf_simple, :reject_deletes], ["*.remote.instance"]) test "it rejects the deletion" do deletion_message = build_remote_deletion_message() diff --git a/test/pleroma/web/activity_pub/mrf/subchain_policy_test.exs b/test/pleroma/web/activity_pub/mrf/subchain_policy_test.exs index b3427c6fd..4f5cc466c 100644 --- a/test/pleroma/web/activity_pub/mrf/subchain_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/subchain_policy_test.exs @@ -16,7 +16,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SubchainPolicyTest do setup do: clear_config([:mrf_subchain, :match_actor]) test "it matches and processes subchains when the actor matches a configured target" do - Pleroma.Config.put([:mrf_subchain, :match_actor], %{ + clear_config([:mrf_subchain, :match_actor], %{ ~r/^https:\/\/banned.com/s => [DropPolicy] }) @@ -24,7 +24,7 @@ test "it matches and processes subchains when the actor matches a configured tar end test "it doesn't match and process subchains when the actor doesn't match a configured target" do - Pleroma.Config.put([:mrf_subchain, :match_actor], %{ + clear_config([:mrf_subchain, :match_actor], %{ ~r/^https:\/\/borked.com/s => [DropPolicy] }) diff --git a/test/pleroma/web/activity_pub/mrf/user_allow_list_policy_test.exs b/test/pleroma/web/activity_pub/mrf/user_allow_list_policy_test.exs index 0e852731e..f0432ea42 100644 --- a/test/pleroma/web/activity_pub/mrf/user_allow_list_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/user_allow_list_policy_test.exs @@ -17,14 +17,14 @@ test "pass filter if allow list is empty" do test "pass filter if allow list isn't empty and user in allow list" do actor = insert(:user) - Pleroma.Config.put([:mrf_user_allowlist], %{"localhost" => [actor.ap_id, "test-ap-id"]}) + clear_config([:mrf_user_allowlist], %{"localhost" => [actor.ap_id, "test-ap-id"]}) message = %{"actor" => actor.ap_id} assert UserAllowListPolicy.filter(message) == {:ok, message} end test "rejected if allow list isn't empty and user not in allow list" do actor = insert(:user) - Pleroma.Config.put([:mrf_user_allowlist], %{"localhost" => ["test-ap-id"]}) + clear_config([:mrf_user_allowlist], %{"localhost" => ["test-ap-id"]}) message = %{"actor" => actor.ap_id} assert {:reject, _} = UserAllowListPolicy.filter(message) end diff --git a/test/pleroma/web/activity_pub/mrf/vocabulary_policy_test.exs b/test/pleroma/web/activity_pub/mrf/vocabulary_policy_test.exs index d368d70b7..87d1d79b5 100644 --- a/test/pleroma/web/activity_pub/mrf/vocabulary_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/vocabulary_policy_test.exs @@ -11,7 +11,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicyTest do setup do: clear_config([:mrf_vocabulary, :accept]) test "it accepts based on parent activity type" do - Pleroma.Config.put([:mrf_vocabulary, :accept], ["Like"]) + clear_config([:mrf_vocabulary, :accept], ["Like"]) message = %{ "type" => "Like", @@ -22,7 +22,7 @@ test "it accepts based on parent activity type" do end test "it accepts based on child object type" do - Pleroma.Config.put([:mrf_vocabulary, :accept], ["Create", "Note"]) + clear_config([:mrf_vocabulary, :accept], ["Create", "Note"]) message = %{ "type" => "Create", @@ -36,7 +36,7 @@ test "it accepts based on child object type" do end test "it does not accept disallowed child objects" do - Pleroma.Config.put([:mrf_vocabulary, :accept], ["Create", "Note"]) + clear_config([:mrf_vocabulary, :accept], ["Create", "Note"]) message = %{ "type" => "Create", @@ -50,7 +50,7 @@ test "it does not accept disallowed child objects" do end test "it does not accept disallowed parent types" do - Pleroma.Config.put([:mrf_vocabulary, :accept], ["Announce", "Note"]) + clear_config([:mrf_vocabulary, :accept], ["Announce", "Note"]) message = %{ "type" => "Create", @@ -68,7 +68,7 @@ test "it does not accept disallowed parent types" do setup do: clear_config([:mrf_vocabulary, :reject]) test "it rejects based on parent activity type" do - Pleroma.Config.put([:mrf_vocabulary, :reject], ["Like"]) + clear_config([:mrf_vocabulary, :reject], ["Like"]) message = %{ "type" => "Like", @@ -79,7 +79,7 @@ test "it rejects based on parent activity type" do end test "it rejects based on child object type" do - Pleroma.Config.put([:mrf_vocabulary, :reject], ["Note"]) + clear_config([:mrf_vocabulary, :reject], ["Note"]) message = %{ "type" => "Create", @@ -93,7 +93,7 @@ test "it rejects based on child object type" do end test "it passes through objects that aren't disallowed" do - Pleroma.Config.put([:mrf_vocabulary, :reject], ["Like"]) + clear_config([:mrf_vocabulary, :reject], ["Like"]) message = %{ "type" => "Announce", diff --git a/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs b/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs index 782f6c652..320854187 100644 --- a/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs +++ b/test/pleroma/web/activity_pub/object_validators/chat_validation_test.exs @@ -149,7 +149,7 @@ test "does not validate if the message has no content", %{ test "does not validate if the message is longer than the remote_limit", %{ valid_chat_message: valid_chat_message } do - Pleroma.Config.put([:instance, :remote_limit], 2) + clear_config([:instance, :remote_limit], 2) refute match?({:ok, _object, _meta}, ObjectValidator.validate(valid_chat_message, [])) end diff --git a/test/pleroma/web/activity_pub/transmogrifier/follow_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/follow_handling_test.exs index 67d441b85..604444a4c 100644 --- a/test/pleroma/web/activity_pub/transmogrifier/follow_handling_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier/follow_handling_test.exs @@ -133,7 +133,7 @@ test "it works for follow requests when you are already followed, creating a new end test "it rejects incoming follow requests from blocked users when deny_follow_blocked is enabled" do - Pleroma.Config.put([:user, :deny_follow_blocked], true) + clear_config([:user, :deny_follow_blocked], true) user = insert(:user) {:ok, target} = User.get_or_fetch("http://mastodon.example.org/users/admin") diff --git a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs index be99ad93d..31586abc9 100644 --- a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs @@ -415,7 +415,7 @@ test "schedules background fetching of `replies` items if max thread depth limit data: data, items: items } do - Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 10) + clear_config([:instance, :federation_incoming_replies_max_depth], 10) {:ok, _activity} = Transmogrifier.handle_incoming(data) @@ -427,7 +427,7 @@ test "schedules background fetching of `replies` items if max thread depth limit test "does NOT schedule background fetching of `replies` beyond max thread depth limit allows", %{data: data} do - Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 0) + clear_config([:instance, :federation_incoming_replies_max_depth], 0) {:ok, _activity} = Transmogrifier.handle_incoming(data) @@ -464,7 +464,7 @@ test "schedules background fetching of `replies` items if max thread depth limit federation_output: federation_output, replies_uris: replies_uris } do - Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 1) + clear_config([:instance, :federation_incoming_replies_max_depth], 1) {:ok, _activity} = Transmogrifier.handle_incoming(federation_output) @@ -476,7 +476,7 @@ test "schedules background fetching of `replies` items if max thread depth limit test "does NOT schedule background fetching of `replies` beyond max thread depth limit allows", %{federation_output: federation_output} do - Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 0) + clear_config([:instance, :federation_incoming_replies_max_depth], 0) {:ok, _activity} = Transmogrifier.handle_incoming(federation_output) @@ -551,7 +551,7 @@ test "returns not modified object when hasn't containts inReplyTo field", %{data end test "returns object with inReplyTo when denied incoming reply", %{data: data} do - Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 0) + clear_config([:instance, :federation_incoming_replies_max_depth], 0) object_with_reply = Map.put(data["object"], "inReplyTo", "https://shitposter.club/notice/2827873") @@ -585,7 +585,7 @@ test "returns modified object when allowed incoming reply", %{data: data} do "https://mstdn.io/users/mayuutann/statuses/99568293732299394" ) - Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 5) + clear_config([:instance, :federation_incoming_replies_max_depth], 5) modified_object = Transmogrifier.fix_in_reply_to(object_with_reply) assert modified_object["inReplyTo"] == diff --git a/test/pleroma/web/admin_api/controllers/config_controller_test.exs b/test/pleroma/web/admin_api/controllers/config_controller_test.exs index 75ca892aa..77688c7a3 100644 --- a/test/pleroma/web/admin_api/controllers/config_controller_test.exs +++ b/test/pleroma/web/admin_api/controllers/config_controller_test.exs @@ -8,7 +8,6 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do import ExUnit.CaptureLog import Pleroma.Factory - alias Pleroma.Config alias Pleroma.ConfigDB setup do @@ -27,7 +26,7 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do setup do: clear_config(:configurable_from_database, true) test "when configuration from database is off", %{conn: conn} do - Config.put(:configurable_from_database, false) + clear_config(:configurable_from_database, false) conn = get(conn, "/api/pleroma/admin/config") assert json_response_and_validate_schema(conn, 400) == @@ -410,8 +409,7 @@ test "saving config with partial update", %{conn: conn} do end test "saving config which need pleroma reboot", %{conn: conn} do - chat = Config.get(:chat) - on_exit(fn -> Config.put(:chat, chat) end) + clear_config([:chat, :enabled], true) assert conn |> put_req_header("content-type", "application/json") @@ -456,8 +454,7 @@ test "saving config which need pleroma reboot", %{conn: conn} do end test "update setting which need reboot, don't change reboot flag until reboot", %{conn: conn} do - chat = Config.get(:chat) - on_exit(fn -> Config.put(:chat, chat) end) + clear_config([:chat, :enabled], true) assert conn |> put_req_header("content-type", "application/json") diff --git a/test/pleroma/web/admin_api/controllers/invite_controller_test.exs b/test/pleroma/web/admin_api/controllers/invite_controller_test.exs index 0f3ca44bc..6366061c8 100644 --- a/test/pleroma/web/admin_api/controllers/invite_controller_test.exs +++ b/test/pleroma/web/admin_api/controllers/invite_controller_test.exs @@ -7,7 +7,6 @@ defmodule Pleroma.Web.AdminAPI.InviteControllerTest do import Pleroma.Factory - alias Pleroma.Config alias Pleroma.Repo alias Pleroma.UserInviteToken @@ -119,8 +118,8 @@ test "email with +", %{conn: conn, admin: admin} do setup do: clear_config([:instance, :invites_enabled]) test "it returns 500 if `invites_enabled` is not enabled", %{conn: conn} do - Config.put([:instance, :registrations_open], false) - Config.put([:instance, :invites_enabled], false) + clear_config([:instance, :registrations_open], false) + clear_config([:instance, :invites_enabled], false) conn = conn @@ -138,8 +137,8 @@ test "it returns 500 if `invites_enabled` is not enabled", %{conn: conn} do end test "it returns 500 if `registrations_open` is enabled", %{conn: conn} do - Config.put([:instance, :registrations_open], true) - Config.put([:instance, :invites_enabled], true) + clear_config([:instance, :registrations_open], true) + clear_config([:instance, :invites_enabled], true) conn = conn diff --git a/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs b/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs index db935ad12..5d872901e 100644 --- a/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs +++ b/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs @@ -21,9 +21,9 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do |> assign(:user, admin) |> assign(:token, token) - Config.put([:media_proxy, :enabled], true) - Config.put([:media_proxy, :invalidation, :enabled], true) - Config.put([:media_proxy, :invalidation, :provider], MediaProxy.Invalidation.Script) + clear_config([:media_proxy, :enabled], true) + clear_config([:media_proxy, :invalidation, :enabled], true) + clear_config([:media_proxy, :invalidation, :provider], MediaProxy.Invalidation.Script) {:ok, %{admin: admin, token: token, conn: conn}} end diff --git a/test/pleroma/web/chat_channel_test.exs b/test/pleroma/web/chat_channel_test.exs index e8c3d965e..29999701c 100644 --- a/test/pleroma/web/chat_channel_test.exs +++ b/test/pleroma/web/chat_channel_test.exs @@ -33,7 +33,7 @@ test "it ignores messages of length zero", %{socket: socket} do end test "it ignores messages above a certain length", %{socket: socket} do - Pleroma.Config.put([:instance, :chat_limit], 2) + clear_config([:instance, :chat_limit], 2) push(socket, "new_msg", %{"text" => "123"}) refute_broadcast("new_msg", %{text: "123"}) end diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs index c996766ea..adfe58def 100644 --- a/test/pleroma/web/common_api_test.exs +++ b/test/pleroma/web/common_api_test.exs @@ -234,7 +234,7 @@ test "it posts a chat message" do end test "it reject messages over the local limit" do - Pleroma.Config.put([:instance, :chat_limit], 2) + clear_config([:instance, :chat_limit], 2) author = insert(:user) recipient = insert(:user) @@ -475,7 +475,7 @@ test "with the safe_dm_mention option set, it does not mention people beyond the jafnhar = insert(:user) tridi = insert(:user) - Pleroma.Config.put([:instance, :safe_dm_mentions], true) + clear_config([:instance, :safe_dm_mentions], true) {:ok, activity} = CommonAPI.post(har, %{ @@ -642,7 +642,7 @@ test "it returns error when status is empty and no attachments" do end test "it validates character limits are correctly enforced" do - Pleroma.Config.put([:instance, :limit], 5) + clear_config([:instance, :limit], 5) user = insert(:user) @@ -793,7 +793,7 @@ test "favoriting a status twice returns ok, but without the like activity" do describe "pinned statuses" do setup do - Pleroma.Config.put([:instance, :max_pinned_statuses], 1) + clear_config([:instance, :max_pinned_statuses], 1) user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{status: "HI!!!"}) diff --git a/test/pleroma/web/federator_test.exs b/test/pleroma/web/federator_test.exs index 1bff8d99c..532ee6d30 100644 --- a/test/pleroma/web/federator_test.exs +++ b/test/pleroma/web/federator_test.exs @@ -56,7 +56,7 @@ test "with relays deactivated, it does not publish to the relay", %{ activity: activity, relay_mock: relay_mock } do - Pleroma.Config.put([:instance, :allow_relay], false) + clear_config([:instance, :allow_relay], false) with_mocks([relay_mock]) do Federator.publish(activity) @@ -155,9 +155,9 @@ test "rejects incoming AP docs with incorrect origin" do end test "it does not crash if MRF rejects the post" do - Pleroma.Config.put([:mrf_keyword, :reject], ["lain"]) + clear_config([:mrf_keyword, :reject], ["lain"]) - Pleroma.Config.put( + clear_config( [:mrf, :policies], Pleroma.Web.ActivityPub.MRF.KeywordPolicy ) diff --git a/test/pleroma/web/feed/tag_controller_test.exs b/test/pleroma/web/feed/tag_controller_test.exs index aeec89b06..5c9201de1 100644 --- a/test/pleroma/web/feed/tag_controller_test.exs +++ b/test/pleroma/web/feed/tag_controller_test.exs @@ -8,7 +8,6 @@ defmodule Pleroma.Web.Feed.TagControllerTest do import Pleroma.Factory import SweetXml - alias Pleroma.Config alias Pleroma.Object alias Pleroma.Web.CommonAPI alias Pleroma.Web.Feed.FeedView @@ -16,7 +15,7 @@ defmodule Pleroma.Web.Feed.TagControllerTest do setup do: clear_config([:feed]) test "gets a feed (ATOM)", %{conn: conn} do - Config.put( + clear_config( [:feed, :post_title], %{max_length: 25, omission: "..."} ) @@ -83,7 +82,7 @@ test "gets a feed (ATOM)", %{conn: conn} do end test "gets a feed (RSS)", %{conn: conn} do - Config.put( + clear_config( [:feed, :post_title], %{max_length: 25, omission: "..."} ) diff --git a/test/pleroma/web/feed/user_controller_test.exs b/test/pleroma/web/feed/user_controller_test.exs index 66667783d..408653d92 100644 --- a/test/pleroma/web/feed/user_controller_test.exs +++ b/test/pleroma/web/feed/user_controller_test.exs @@ -8,7 +8,6 @@ defmodule Pleroma.Web.Feed.UserControllerTest do import Pleroma.Factory import SweetXml - alias Pleroma.Config alias Pleroma.Object alias Pleroma.User alias Pleroma.Web.CommonAPI @@ -20,7 +19,7 @@ defmodule Pleroma.Web.Feed.UserControllerTest do setup do: clear_config([:feed]) setup do - Config.put( + clear_config( [:feed, :post_title], %{max_length: 15, omission: "..."} ) @@ -236,7 +235,7 @@ test "with non-html / non-json format, it returns error when user is not found", setup do: clear_config([:instance, :public]) test "returns 404 for user feed", %{conn: conn} do - Config.put([:instance, :public], false) + clear_config([:instance, :public], false) user = insert(:user) {:ok, _} = CommonAPI.post(user, %{status: "test"}) 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 e5020feca..a327c0d1d 100644 --- a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs @@ -1103,7 +1103,7 @@ test "registers and logs in without :account_activation_required / :account_appr assert %{"error" => "{\"email\":[\"Invalid email\"]}"} = json_response_and_validate_schema(conn, 400) - Pleroma.Config.put([User, :email_blacklist], []) + clear_config([User, :email_blacklist], []) conn = build_conn() diff --git a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs index 0d4eebb73..b99856659 100644 --- a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs @@ -47,6 +47,7 @@ test "get instance information", %{conn: conn} do assert result["pleroma"]["metadata"]["federation"] assert result["pleroma"]["metadata"]["fields_limits"] assert result["pleroma"]["vapid_public_key"] + assert result["pleroma"]["stats"]["mau"] == 0 assert email == from_config_email assert thumbnail == from_config_thumbnail diff --git a/test/pleroma/web/mastodon_api/controllers/scheduled_activity_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/scheduled_activity_controller_test.exs index a5aa72f6f..b28e3df56 100644 --- a/test/pleroma/web/mastodon_api/controllers/scheduled_activity_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/scheduled_activity_controller_test.exs @@ -55,7 +55,7 @@ test "shows a scheduled activity" do end test "updates a scheduled activity" do - Pleroma.Config.put([ScheduledActivity, :enabled], true) + clear_config([ScheduledActivity, :enabled], true) %{user: user, conn: conn} = oauth_access(["write:statuses"]) scheduled_at = Timex.shift(NaiveDateTime.utc_now(), minutes: 60) @@ -103,7 +103,7 @@ test "updates a scheduled activity" do end test "deletes a scheduled activity" do - Pleroma.Config.put([ScheduledActivity, :enabled], true) + clear_config([ScheduledActivity, :enabled], true) %{user: user, conn: conn} = oauth_access(["write:statuses"]) scheduled_at = Timex.shift(NaiveDateTime.utc_now(), minutes: 60) diff --git a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs index bfb44374e..3c73eb514 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -7,7 +7,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do use Oban.Testing, repo: Pleroma.Repo alias Pleroma.Activity - alias Pleroma.Config alias Pleroma.Conversation.Participation alias Pleroma.Object alias Pleroma.Repo @@ -29,7 +28,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do setup do: oauth_access(["write:statuses"]) test "posting a status does not increment reblog_count when relaying", %{conn: conn} do - Config.put([:instance, :federating], true) + clear_config([:instance, :federating], true) Config.get([:instance, :allow_relay], true) response = @@ -151,8 +150,8 @@ test "it fails to create a status if `expires_in` is less or equal than an hour" end test "Get MRF reason when posting a status is rejected by one", %{conn: conn} do - Config.put([:mrf_keyword, :reject], ["GNO"]) - Config.put([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.KeywordPolicy]) + clear_config([:mrf_keyword, :reject], ["GNO"]) + clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.KeywordPolicy]) assert %{"error" => "[KeywordPolicy] Matches with rejected keyword"} = conn @@ -264,6 +263,7 @@ test "posting a fake status", %{conn: conn} do fake_conn = conn + |> assign(:user, refresh_record(conn.assigns.user)) |> put_req_header("content-type", "application/json") |> post("/api/v1/statuses", %{ "status" => @@ -1204,7 +1204,7 @@ test "on pin removes deletion job, on unpin reschedule deletion" do describe "cards" do setup do - Config.put([:rich_media, :enabled], true) + clear_config([:rich_media, :enabled], true) oauth_access(["read:statuses"]) end diff --git a/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs index 664375fef..cc409451c 100644 --- a/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/timeline_controller_test.exs @@ -90,6 +90,65 @@ test "muted emotions", %{user: user, conn: conn} do } ] = result end + + test "filtering", %{conn: conn, user: user} do + local_user = insert(:user) + {:ok, user, local_user} = User.follow(user, local_user) + {:ok, local_activity} = CommonAPI.post(local_user, %{status: "Status"}) + with_media = create_with_media_activity(local_user) + + remote_user = insert(:user, local: false) + {:ok, _user, remote_user} = User.follow(user, remote_user) + remote_activity = create_remote_activity(remote_user) + + without_filter_ids = + conn + |> get("/api/v1/timelines/home") + |> json_response_and_validate_schema(200) + |> Enum.map(& &1["id"]) + + assert local_activity.id in without_filter_ids + assert remote_activity.id in without_filter_ids + assert with_media.id in without_filter_ids + + only_local_ids = + conn + |> get("/api/v1/timelines/home?local=true") + |> json_response_and_validate_schema(200) + |> Enum.map(& &1["id"]) + + assert local_activity.id in only_local_ids + refute remote_activity.id in only_local_ids + assert with_media.id in only_local_ids + + only_local_media_ids = + conn + |> get("/api/v1/timelines/home?local=true&only_media=true") + |> json_response_and_validate_schema(200) + |> Enum.map(& &1["id"]) + + refute local_activity.id in only_local_media_ids + refute remote_activity.id in only_local_media_ids + assert with_media.id in only_local_media_ids + + remote_ids = + conn + |> get("/api/v1/timelines/home?remote=true") + |> json_response_and_validate_schema(200) + |> Enum.map(& &1["id"]) + + refute local_activity.id in remote_ids + assert remote_activity.id in remote_ids + refute with_media.id in remote_ids + + assert conn + |> get("/api/v1/timelines/home?remote=true&only_media=true") + |> json_response_and_validate_schema(200) == [] + + assert conn + |> get("/api/v1/timelines/home?remote=true&local=true") + |> json_response_and_validate_schema(200) == [] + end end describe "public" do @@ -98,27 +157,80 @@ test "the public timeline", %{conn: conn} do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{status: "test"}) + with_media = create_with_media_activity(user) - _activity = insert(:note_activity, local: false) + remote = insert(:note_activity, local: false) - conn = get(conn, "/api/v1/timelines/public?local=False") + assert conn + |> get("/api/v1/timelines/public?local=False") + |> json_response_and_validate_schema(:ok) + |> length == 3 - assert length(json_response_and_validate_schema(conn, :ok)) == 2 + local_ids = + conn + |> get("/api/v1/timelines/public?local=True") + |> json_response_and_validate_schema(:ok) + |> Enum.map(& &1["id"]) - conn = get(build_conn(), "/api/v1/timelines/public?local=True") + assert activity.id in local_ids + assert with_media.id in local_ids + refute remote.id in local_ids - assert [%{"content" => "test"}] = json_response_and_validate_schema(conn, :ok) + local_ids = + conn + |> get("/api/v1/timelines/public?local=True") + |> json_response_and_validate_schema(:ok) + |> Enum.map(& &1["id"]) - conn = get(build_conn(), "/api/v1/timelines/public?local=1") + assert activity.id in local_ids + assert with_media.id in local_ids + refute remote.id in local_ids - assert [%{"content" => "test"}] = json_response_and_validate_schema(conn, :ok) + local_ids = + conn + |> get("/api/v1/timelines/public?local=True&only_media=true") + |> json_response_and_validate_schema(:ok) + |> Enum.map(& &1["id"]) + + refute activity.id in local_ids + assert with_media.id in local_ids + refute remote.id in local_ids + + local_ids = + conn + |> get("/api/v1/timelines/public?local=1") + |> json_response_and_validate_schema(:ok) + |> Enum.map(& &1["id"]) + + assert activity.id in local_ids + assert with_media.id in local_ids + refute remote.id in local_ids + + remote_id = remote.id + + assert [%{"id" => ^remote_id}] = + conn + |> get("/api/v1/timelines/public?remote=true") + |> json_response_and_validate_schema(:ok) + + with_media_id = with_media.id + + assert [%{"id" => ^with_media_id}] = + conn + |> get("/api/v1/timelines/public?only_media=true") + |> json_response_and_validate_schema(:ok) + + assert conn + |> get("/api/v1/timelines/public?remote=true&only_media=true") + |> json_response_and_validate_schema(:ok) == [] # does not contain repeats {:ok, _} = CommonAPI.repeat(activity.id, user) - conn = get(build_conn(), "/api/v1/timelines/public?local=true") - - assert [_] = json_response_and_validate_schema(conn, :ok) + assert [_, _] = + conn + |> get("/api/v1/timelines/public?local=true") + |> json_response_and_validate_schema(:ok) end test "the public timeline includes only public statuses for an authenticated user" do @@ -544,6 +656,77 @@ test "muted emotions", %{user: user, conn: conn} do } ] = result end + + test "filtering", %{user: user, conn: conn} do + {:ok, list} = Pleroma.List.create("name", user) + + local_user = insert(:user) + {:ok, local_activity} = CommonAPI.post(local_user, %{status: "Marisa is stupid."}) + with_media = create_with_media_activity(local_user) + {:ok, list} = Pleroma.List.follow(list, local_user) + + remote_user = insert(:user, local: false) + remote_activity = create_remote_activity(remote_user) + {:ok, list} = Pleroma.List.follow(list, remote_user) + + all_ids = + conn + |> get("/api/v1/timelines/list/#{list.id}") + |> json_response_and_validate_schema(200) + |> Enum.map(& &1["id"]) + + assert local_activity.id in all_ids + assert with_media.id in all_ids + assert remote_activity.id in all_ids + + only_local_ids = + conn + |> get("/api/v1/timelines/list/#{list.id}?local=true") + |> json_response_and_validate_schema(200) + |> Enum.map(& &1["id"]) + + assert local_activity.id in only_local_ids + assert with_media.id in only_local_ids + refute remote_activity.id in only_local_ids + + only_local_media_ids = + conn + |> get("/api/v1/timelines/list/#{list.id}?local=true&only_media=true") + |> json_response_and_validate_schema(200) + |> Enum.map(& &1["id"]) + + refute local_activity.id in only_local_media_ids + assert with_media.id in only_local_media_ids + refute remote_activity.id in only_local_media_ids + + remote_ids = + conn + |> get("/api/v1/timelines/list/#{list.id}?remote=true") + |> json_response_and_validate_schema(200) + |> Enum.map(& &1["id"]) + + refute local_activity.id in remote_ids + refute with_media.id in remote_ids + assert remote_activity.id in remote_ids + + assert conn + |> get("/api/v1/timelines/list/#{list.id}?remote=true&only_media=true") + |> json_response_and_validate_schema(200) == [] + + only_media_ids = + conn + |> get("/api/v1/timelines/list/#{list.id}?only_media=true") + |> json_response_and_validate_schema(200) + |> Enum.map(& &1["id"]) + + refute local_activity.id in only_media_ids + assert with_media.id in only_media_ids + refute remote_activity.id in only_media_ids + + assert conn + |> get("/api/v1/timelines/list/#{list.id}?only_media=true&local=true&remote=true") + |> json_response_and_validate_schema(200) == [] + end end describe "hashtag" do @@ -554,19 +737,85 @@ test "hashtag timeline", %{conn: conn} do following = insert(:user) {:ok, activity} = CommonAPI.post(following, %{status: "test #2hu"}) + with_media = create_with_media_activity(following) - nconn = get(conn, "/api/v1/timelines/tag/2hu") + remote = insert(:user, local: false) + remote_activity = create_remote_activity(remote) - assert [%{"id" => id}] = json_response_and_validate_schema(nconn, :ok) + all_ids = + conn + |> get("/api/v1/timelines/tag/2hu") + |> json_response_and_validate_schema(:ok) + |> Enum.map(& &1["id"]) - assert id == to_string(activity.id) + assert activity.id in all_ids + assert with_media.id in all_ids + assert remote_activity.id in all_ids # works for different capitalization too - nconn = get(conn, "/api/v1/timelines/tag/2HU") + all_ids = + conn + |> get("/api/v1/timelines/tag/2HU") + |> json_response_and_validate_schema(:ok) + |> Enum.map(& &1["id"]) - assert [%{"id" => id}] = json_response_and_validate_schema(nconn, :ok) + assert activity.id in all_ids + assert with_media.id in all_ids + assert remote_activity.id in all_ids - assert id == to_string(activity.id) + local_ids = + conn + |> get("/api/v1/timelines/tag/2hu?local=true") + |> json_response_and_validate_schema(:ok) + |> Enum.map(& &1["id"]) + + assert activity.id in local_ids + assert with_media.id in local_ids + refute remote_activity.id in local_ids + + remote_ids = + conn + |> get("/api/v1/timelines/tag/2hu?remote=true") + |> json_response_and_validate_schema(:ok) + |> Enum.map(& &1["id"]) + + refute activity.id in remote_ids + refute with_media.id in remote_ids + assert remote_activity.id in remote_ids + + media_ids = + conn + |> get("/api/v1/timelines/tag/2hu?only_media=true") + |> json_response_and_validate_schema(:ok) + |> Enum.map(& &1["id"]) + + refute activity.id in media_ids + assert with_media.id in media_ids + refute remote_activity.id in media_ids + + media_local_ids = + conn + |> get("/api/v1/timelines/tag/2hu?only_media=true&local=true") + |> json_response_and_validate_schema(:ok) + |> Enum.map(& &1["id"]) + + refute activity.id in media_local_ids + assert with_media.id in media_local_ids + refute remote_activity.id in media_local_ids + + ids = + conn + |> get("/api/v1/timelines/tag/2hu?only_media=true&local=true&remote=true") + |> json_response_and_validate_schema(:ok) + |> Enum.map(& &1["id"]) + + refute activity.id in ids + refute with_media.id in ids + refute remote_activity.id in ids + + assert conn + |> get("/api/v1/timelines/tag/2hu?only_media=true&remote=true") + |> json_response_and_validate_schema(:ok) == [] end test "multi-hashtag timeline", %{conn: conn} do @@ -726,4 +975,37 @@ test "with `%{local: true, federated: false}`, forbids unauthenticated access to ensure_authenticated_access(base_uri) end end + + defp create_remote_activity(user) do + obj = + insert(:note, %{ + data: %{ + "to" => [ + "https://www.w3.org/ns/activitystreams#Public", + User.ap_followers(user) + ] + }, + user: user + }) + + insert(:note_activity, %{ + note: obj, + recipients: [ + "https://www.w3.org/ns/activitystreams#Public", + User.ap_followers(user) + ], + user: user, + local: false + }) + end + + defp create_with_media_activity(user) do + obj = insert(:attachment_note, user: user) + + insert(:note_activity, %{ + note: obj, + recipients: ["https://www.w3.org/ns/activitystreams#Public", User.ap_followers(user)], + user: user + }) + end end diff --git a/test/pleroma/web/mastodon_api/masto_fe_controller_test.exs b/test/pleroma/web/mastodon_api/masto_fe_controller_test.exs index a8ad025c9..ea66c708f 100644 --- a/test/pleroma/web/mastodon_api/masto_fe_controller_test.exs +++ b/test/pleroma/web/mastodon_api/masto_fe_controller_test.exs @@ -5,7 +5,6 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEControllerTest do use Pleroma.Web.ConnCase - alias Pleroma.Config alias Pleroma.User import Pleroma.Factory @@ -55,7 +54,7 @@ test "redirects not logged-in users to the login page on private instances", %{ conn: conn, path: path } do - Config.put([:instance, :public], false) + clear_config([:instance, :public], false) conn = get(conn, path) 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 6de5dc859..999bde474 100644 --- a/test/pleroma/web/mastodon_api/views/account_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs @@ -5,7 +5,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do use Pleroma.DataCase - alias Pleroma.Config alias Pleroma.User alias Pleroma.UserRelationship alias Pleroma.Web.CommonAPI @@ -556,7 +555,7 @@ test "uses mediaproxy urls when it's enabled (regardless of media preview proxy ) with media_preview_enabled <- [false, true] do - Config.put([:media_preview_proxy, :enabled], media_preview_enabled) + clear_config([:media_preview_proxy, :enabled], media_preview_enabled) AccountView.render("show.json", %{user: user, skip_visibility_check: true}) |> Enum.all?(fn diff --git a/test/pleroma/web/media_proxy/invalidation_test.exs b/test/pleroma/web/media_proxy/invalidation_test.exs index 8fb026847..c77b8c94a 100644 --- a/test/pleroma/web/media_proxy/invalidation_test.exs +++ b/test/pleroma/web/media_proxy/invalidation_test.exs @@ -5,7 +5,6 @@ defmodule Pleroma.Web.MediaProxy.InvalidationTest do use Pleroma.DataCase - alias Pleroma.Config alias Pleroma.Web.MediaProxy.Invalidation import ExUnit.CaptureLog @@ -16,11 +15,11 @@ defmodule Pleroma.Web.MediaProxy.InvalidationTest do describe "Invalidation.Http" do test "perform request to clear cache" do - Config.put([:media_proxy, :enabled], false) - Config.put([:media_proxy, :invalidation, :enabled], true) - Config.put([:media_proxy, :invalidation, :provider], Invalidation.Http) + clear_config([:media_proxy, :enabled], false) + clear_config([:media_proxy, :invalidation, :enabled], true) + clear_config([:media_proxy, :invalidation, :provider], Invalidation.Http) - Config.put([Invalidation.Http], method: :purge, headers: [{"x-refresh", 1}]) + clear_config([Invalidation.Http], method: :purge, headers: [{"x-refresh", 1}]) image_url = "http://example.com/media/example.jpg" Pleroma.Web.MediaProxy.put_in_banned_urls(image_url) @@ -43,10 +42,10 @@ test "perform request to clear cache" do describe "Invalidation.Script" do test "run script to clear cache" do - Config.put([:media_proxy, :enabled], false) - Config.put([:media_proxy, :invalidation, :enabled], true) - Config.put([:media_proxy, :invalidation, :provider], Invalidation.Script) - Config.put([Invalidation.Script], script_path: "purge-nginx") + clear_config([:media_proxy, :enabled], false) + clear_config([:media_proxy, :invalidation, :enabled], true) + clear_config([:media_proxy, :invalidation, :provider], Invalidation.Script) + clear_config([Invalidation.Script], script_path: "purge-nginx") image_url = "http://example.com/media/example.jpg" Pleroma.Web.MediaProxy.put_in_banned_urls(image_url) diff --git a/test/pleroma/web/media_proxy/media_proxy_controller_test.exs b/test/pleroma/web/media_proxy/media_proxy_controller_test.exs index 56a94e09a..2a449e56d 100644 --- a/test/pleroma/web/media_proxy/media_proxy_controller_test.exs +++ b/test/pleroma/web/media_proxy/media_proxy_controller_test.exs @@ -33,7 +33,7 @@ test "it returns 404 when disabled", %{conn: conn} do end test "it returns 403 for invalid signature", %{conn: conn, url: url} do - Pleroma.Config.put([Pleroma.Web.Endpoint, :secret_key_base], "000") + clear_config([Pleroma.Web.Endpoint, :secret_key_base], "000") %{path: path} = URI.parse(url) assert %Conn{ @@ -128,7 +128,7 @@ test "returns 404 when disabled", %{conn: conn} do end test "it returns 403 for invalid signature", %{conn: conn, url: url} do - Pleroma.Config.put([Pleroma.Web.Endpoint, :secret_key_base], "000") + clear_config([Pleroma.Web.Endpoint, :secret_key_base], "000") %{path: path} = URI.parse(url) assert %Conn{ diff --git a/test/pleroma/web/metadata/providers/open_graph_test.exs b/test/pleroma/web/metadata/providers/open_graph_test.exs index e0f615785..fc44b3cbd 100644 --- a/test/pleroma/web/metadata/providers/open_graph_test.exs +++ b/test/pleroma/web/metadata/providers/open_graph_test.exs @@ -66,7 +66,7 @@ test "it renders all supported types of attachments and skips unknown types" do end test "it does not render attachments if post is nsfw" do - Pleroma.Config.put([Pleroma.Web.Metadata, :unfurl_nsfw], false) + clear_config([Pleroma.Web.Metadata, :unfurl_nsfw], false) user = insert(:user, avatar: %{"url" => [%{"href" => "https://pleroma.gov/tenshi.png"}]}) note = diff --git a/test/pleroma/web/metadata/providers/twitter_card_test.exs b/test/pleroma/web/metadata/providers/twitter_card_test.exs index 3c70a1562..a35e44356 100644 --- a/test/pleroma/web/metadata/providers/twitter_card_test.exs +++ b/test/pleroma/web/metadata/providers/twitter_card_test.exs @@ -54,7 +54,7 @@ test "it uses summary twittercard if post has no attachment" do end test "it renders avatar not attachment if post is nsfw and unfurl_nsfw is disabled" do - Pleroma.Config.put([Pleroma.Web.Metadata, :unfurl_nsfw], false) + clear_config([Pleroma.Web.Metadata, :unfurl_nsfw], false) user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994") {:ok, activity} = CommonAPI.post(user, %{status: "HI"}) diff --git a/test/pleroma/web/node_info_test.exs b/test/pleroma/web/node_info_test.exs index 888b62791..ee6fdaae8 100644 --- a/test/pleroma/web/node_info_test.exs +++ b/test/pleroma/web/node_info_test.exs @@ -7,8 +7,6 @@ defmodule Pleroma.Web.NodeInfoTest do import Pleroma.Factory - alias Pleroma.Config - setup do: clear_config([:mrf_simple]) setup do: clear_config(:instance) @@ -93,7 +91,7 @@ test "it returns the safe_dm_mentions feature if enabled", %{conn: conn} do assert "safe_dm_mentions" in response["metadata"]["features"] - Config.put([:instance, :safe_dm_mentions], false) + clear_config([:instance, :safe_dm_mentions], false) response = conn @@ -107,7 +105,7 @@ test "it returns the safe_dm_mentions feature if enabled", %{conn: conn} do setup do: clear_config([:instance, :federating]) test "it shows if federation is enabled/disabled", %{conn: conn} do - Config.put([:instance, :federating], true) + clear_config([:instance, :federating], true) response = conn @@ -116,7 +114,7 @@ test "it shows if federation is enabled/disabled", %{conn: conn} do assert response["metadata"]["federation"]["enabled"] == true - Config.put([:instance, :federating], false) + clear_config([:instance, :federating], false) response = conn diff --git a/test/pleroma/web/o_auth/o_auth_controller_test.exs b/test/pleroma/web/o_auth/o_auth_controller_test.exs index 9c7c57d48..312500feb 100644 --- a/test/pleroma/web/o_auth/o_auth_controller_test.exs +++ b/test/pleroma/web/o_auth/o_auth_controller_test.exs @@ -923,7 +923,7 @@ test "rejects token exchange with invalid client credentials" do end test "rejects token exchange for valid credentials belonging to unconfirmed user and confirmation is required" do - Pleroma.Config.put([:instance, :account_activation_required], true) + clear_config([:instance, :account_activation_required], true) password = "testpassword" {:ok, user} = @@ -1007,7 +1007,7 @@ test "rejects token exchange for user with password_reset_pending set to true" d end test "rejects token exchange for user with confirmation_pending set to true" do - Pleroma.Config.put([:instance, :account_activation_required], true) + clear_config([:instance, :account_activation_required], true) password = "testpassword" user = @@ -1086,7 +1086,7 @@ test "rejects an invalid authorization code" do setup do: clear_config([:oauth2, :issue_new_refresh_token]) test "issues a new access token with keep fresh token" do - Pleroma.Config.put([:oauth2, :issue_new_refresh_token], true) + clear_config([:oauth2, :issue_new_refresh_token], true) user = insert(:user) app = insert(:oauth_app, scopes: ["read", "write"]) @@ -1125,7 +1125,7 @@ test "issues a new access token with keep fresh token" do end test "issues a new access token with new fresh token" do - Pleroma.Config.put([:oauth2, :issue_new_refresh_token], false) + clear_config([:oauth2, :issue_new_refresh_token], false) user = insert(:user) app = insert(:oauth_app, scopes: ["read", "write"]) diff --git a/test/pleroma/web/pleroma_api/controllers/conversation_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/conversation_controller_test.exs index 98a23aaaa..54f2c5a58 100644 --- a/test/pleroma/web/pleroma_api/controllers/conversation_controller_test.exs +++ b/test/pleroma/web/pleroma_api/controllers/conversation_controller_test.exs @@ -104,7 +104,7 @@ test "PATCH /api/v1/pleroma/conversations/:id" do [participation] = Participation.for_user(user) participation = Repo.preload(participation, :recipients) - assert user in participation.recipients + assert refresh_record(user) in participation.recipients assert other_user in participation.recipients end diff --git a/test/pleroma/web/pleroma_api/controllers/emoji_pack_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/emoji_pack_controller_test.exs index 5c2473955..cd9fc391d 100644 --- a/test/pleroma/web/pleroma_api/controllers/emoji_pack_controller_test.exs +++ b/test/pleroma/web/pleroma_api/controllers/emoji_pack_controller_test.exs @@ -31,7 +31,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiPackControllerTest do end test "GET /api/pleroma/emoji/packs when :public: false", %{conn: conn} do - Config.put([:instance, :public], false) + clear_config([:instance, :public], false) conn |> get("/api/pleroma/emoji/packs") |> json_response_and_validate_schema(200) end diff --git a/test/pleroma/web/plugs/admin_secret_authentication_plug_test.exs b/test/pleroma/web/plugs/admin_secret_authentication_plug_test.exs index 665c1962e..79561afb7 100644 --- a/test/pleroma/web/plugs/admin_secret_authentication_plug_test.exs +++ b/test/pleroma/web/plugs/admin_secret_authentication_plug_test.exs @@ -35,7 +35,7 @@ test "does nothing if a user is assigned", %{conn: conn} do end test "with `admin_token` query parameter", %{conn: conn} do - Pleroma.Config.put(:admin_token, "password123") + clear_config(:admin_token, "password123") conn = %{conn | params: %{"admin_token" => "wrong_password"}} @@ -54,7 +54,7 @@ test "with `admin_token` query parameter", %{conn: conn} do end test "with `x-admin-token` HTTP header", %{conn: conn} do - Pleroma.Config.put(:admin_token, "☕️") + clear_config(:admin_token, "☕️") conn = conn diff --git a/test/pleroma/web/plugs/ensure_public_or_authenticated_plug_test.exs b/test/pleroma/web/plugs/ensure_public_or_authenticated_plug_test.exs index 33d0f64e9..75c3b5784 100644 --- a/test/pleroma/web/plugs/ensure_public_or_authenticated_plug_test.exs +++ b/test/pleroma/web/plugs/ensure_public_or_authenticated_plug_test.exs @@ -5,14 +5,13 @@ defmodule Pleroma.Web.Plugs.EnsurePublicOrAuthenticatedPlugTest do use Pleroma.Web.ConnCase - alias Pleroma.Config alias Pleroma.User alias Pleroma.Web.Plugs.EnsurePublicOrAuthenticatedPlug setup do: clear_config([:instance, :public]) test "it halts if not public and no user is assigned", %{conn: conn} do - Config.put([:instance, :public], false) + clear_config([:instance, :public], false) conn = conn @@ -23,7 +22,7 @@ test "it halts if not public and no user is assigned", %{conn: conn} do end test "it continues if public", %{conn: conn} do - Config.put([:instance, :public], true) + clear_config([:instance, :public], true) ret_conn = conn @@ -33,7 +32,7 @@ test "it continues if public", %{conn: conn} do end test "it continues if a user is assigned, even if not public", %{conn: conn} do - Config.put([:instance, :public], false) + clear_config([:instance, :public], false) conn = conn diff --git a/test/pleroma/web/plugs/federating_plug_test.exs b/test/pleroma/web/plugs/federating_plug_test.exs index 9c3426862..01ecd2a1e 100644 --- a/test/pleroma/web/plugs/federating_plug_test.exs +++ b/test/pleroma/web/plugs/federating_plug_test.exs @@ -8,7 +8,7 @@ defmodule Pleroma.Web.Plugs.FederatingPlugTest do setup do: clear_config([:instance, :federating]) test "returns and halt the conn when federating is disabled" do - Pleroma.Config.put([:instance, :federating], false) + clear_config([:instance, :federating], false) conn = build_conn() @@ -19,7 +19,7 @@ test "returns and halt the conn when federating is disabled" do end test "does nothing when federating is enabled" do - Pleroma.Config.put([:instance, :federating], true) + clear_config([:instance, :federating], true) conn = build_conn() diff --git a/test/pleroma/web/plugs/http_signature_plug_test.exs b/test/pleroma/web/plugs/http_signature_plug_test.exs index bb3257dc9..56ef6b06f 100644 --- a/test/pleroma/web/plugs/http_signature_plug_test.exs +++ b/test/pleroma/web/plugs/http_signature_plug_test.exs @@ -32,11 +32,7 @@ test "it call HTTPSignatures to check validity if the actor sighed it" do describe "requires a signature when `authorized_fetch_mode` is enabled" do setup do - Pleroma.Config.put([:activitypub, :authorized_fetch_mode], true) - - on_exit(fn -> - Pleroma.Config.put([:activitypub, :authorized_fetch_mode], false) - end) + clear_config([:activitypub, :authorized_fetch_mode], true) params = %{"actor" => "http://mastodon.example.org/users/admin"} conn = build_conn(:get, "/doesntmattter", params) |> put_format("activity+json") diff --git a/test/pleroma/web/plugs/o_auth_scopes_plug_test.exs b/test/pleroma/web/plugs/o_auth_scopes_plug_test.exs index 1703830ce..7241b0afd 100644 --- a/test/pleroma/web/plugs/o_auth_scopes_plug_test.exs +++ b/test/pleroma/web/plugs/o_auth_scopes_plug_test.exs @@ -181,7 +181,7 @@ test "with :admin option, prefixes all requested scopes with `admin:` " <> "and [optionally] keeps only prefixed scopes, " <> "depending on `[:auth, :enforce_oauth_admin_scope_usage]` setting", %{f: f} do - Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], false) + clear_config([:auth, :enforce_oauth_admin_scope_usage], false) assert f.(["read"], %{admin: true}) == ["admin:read", "read"] @@ -192,7 +192,7 @@ test "with :admin option, prefixes all requested scopes with `admin:` " <> "write" ] - Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], true) + clear_config([:auth, :enforce_oauth_admin_scope_usage], true) assert f.(["read:accounts"], %{admin: true}) == ["admin:read:accounts"] diff --git a/test/pleroma/web/plugs/rate_limiter_test.exs b/test/pleroma/web/plugs/rate_limiter_test.exs index 3cac10b0e..d007e3f26 100644 --- a/test/pleroma/web/plugs/rate_limiter_test.exs +++ b/test/pleroma/web/plugs/rate_limiter_test.exs @@ -6,7 +6,6 @@ defmodule Pleroma.Web.Plugs.RateLimiterTest do use Pleroma.Web.ConnCase alias Phoenix.ConnTest - alias Pleroma.Config alias Pleroma.Web.Plugs.RateLimiter alias Plug.Conn @@ -22,8 +21,8 @@ defmodule Pleroma.Web.Plugs.RateLimiterTest do setup do: clear_config([Pleroma.Web.Plugs.RemoteIp, :enabled]) test "config is required for plug to work" do - Config.put([:rate_limit, @limiter_name], {1, 1}) - Config.put([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) + clear_config([:rate_limit, @limiter_name], {1, 1}) + clear_config([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) assert %{limits: {1, 1}, name: :test_init, opts: [name: :test_init]} == [name: @limiter_name] @@ -54,8 +53,8 @@ test "it restricts based on config values" do scale = 80 limit = 5 - Config.put([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) - Config.put([:rate_limit, limiter_name], {scale, limit}) + clear_config([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) + clear_config([:rate_limit, limiter_name], {scale, limit}) plug_opts = RateLimiter.init(name: limiter_name) conn = build_conn(:get, "/") @@ -86,8 +85,8 @@ test "it restricts based on config values" do test "`bucket_name` option overrides default bucket name" do limiter_name = :test_bucket_name - Config.put([:rate_limit, limiter_name], {1000, 5}) - Config.put([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) + clear_config([:rate_limit, limiter_name], {1000, 5}) + clear_config([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) base_bucket_name = "#{limiter_name}:group1" plug_opts = RateLimiter.init(name: limiter_name, bucket_name: base_bucket_name) @@ -101,8 +100,8 @@ test "`bucket_name` option overrides default bucket name" do test "`params` option allows different queries to be tracked independently" do limiter_name = :test_params - Config.put([:rate_limit, limiter_name], {1000, 5}) - Config.put([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) + clear_config([:rate_limit, limiter_name], {1000, 5}) + clear_config([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) plug_opts = RateLimiter.init(name: limiter_name, params: ["id"]) @@ -117,8 +116,8 @@ test "`params` option allows different queries to be tracked independently" do test "it supports combination of options modifying bucket name" do limiter_name = :test_options_combo - Config.put([:rate_limit, limiter_name], {1000, 5}) - Config.put([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) + clear_config([:rate_limit, limiter_name], {1000, 5}) + clear_config([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) base_bucket_name = "#{limiter_name}:group1" @@ -140,8 +139,8 @@ test "it supports combination of options modifying bucket name" do describe "unauthenticated users" do test "are restricted based on remote IP" do limiter_name = :test_unauthenticated - Config.put([:rate_limit, limiter_name], [{1000, 5}, {1, 10}]) - Config.put([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) + clear_config([:rate_limit, limiter_name], [{1000, 5}, {1, 10}]) + clear_config([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) plug_opts = RateLimiter.init(name: limiter_name) @@ -180,8 +179,8 @@ test "can have limits separate from unauthenticated connections" do scale = 50 limit = 5 - Config.put([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) - Config.put([:rate_limit, limiter_name], [{1000, 1}, {scale, limit}]) + clear_config([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) + clear_config([:rate_limit, limiter_name], [{1000, 1}, {scale, limit}]) plug_opts = RateLimiter.init(name: limiter_name) @@ -202,8 +201,8 @@ test "can have limits separate from unauthenticated connections" do test "different users are counted independently" do limiter_name = :test_authenticated2 - Config.put([:rate_limit, limiter_name], [{1, 10}, {1000, 5}]) - Config.put([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) + clear_config([:rate_limit, limiter_name], [{1, 10}, {1000, 5}]) + clear_config([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) plug_opts = RateLimiter.init(name: limiter_name) @@ -232,8 +231,8 @@ test "different users are counted independently" do test "doesn't crash due to a race condition when multiple requests are made at the same time and the bucket is not yet initialized" do limiter_name = :test_race_condition - Pleroma.Config.put([:rate_limit, limiter_name], {1000, 5}) - Pleroma.Config.put([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) + clear_config([:rate_limit, limiter_name], {1000, 5}) + clear_config([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8}) opts = RateLimiter.init(name: limiter_name) diff --git a/test/pleroma/web/plugs/remote_ip_test.exs b/test/pleroma/web/plugs/remote_ip_test.exs index b7fc24db0..4d98de2bd 100644 --- a/test/pleroma/web/plugs/remote_ip_test.exs +++ b/test/pleroma/web/plugs/remote_ip_test.exs @@ -26,7 +26,7 @@ defmodule Pleroma.Web.Plugs.RemoteIpTest do ) test "disabled" do - Pleroma.Config.put(RemoteIp, enabled: false) + clear_config(RemoteIp, enabled: false) %{remote_ip: remote_ip} = conn(:get, "/") @@ -48,7 +48,7 @@ test "enabled" do end test "custom headers" do - Pleroma.Config.put(RemoteIp, enabled: true, headers: ["cf-connecting-ip"]) + clear_config(RemoteIp, enabled: true, headers: ["cf-connecting-ip"]) conn = conn(:get, "/") @@ -73,7 +73,7 @@ test "custom proxies" do refute conn.remote_ip == {1, 1, 1, 1} - Pleroma.Config.put([RemoteIp, :proxies], ["173.245.48.0/20"]) + clear_config([RemoteIp, :proxies], ["173.245.48.0/20"]) conn = conn(:get, "/") @@ -84,7 +84,7 @@ test "custom proxies" do end test "proxies set without CIDR format" do - Pleroma.Config.put([RemoteIp, :proxies], ["173.245.48.1"]) + clear_config([RemoteIp, :proxies], ["173.245.48.1"]) conn = conn(:get, "/") @@ -95,8 +95,8 @@ test "proxies set without CIDR format" do end test "proxies set `nonsensical` CIDR" do - Pleroma.Config.put([RemoteIp, :reserved], ["127.0.0.0/8"]) - Pleroma.Config.put([RemoteIp, :proxies], ["10.0.0.3/24"]) + clear_config([RemoteIp, :reserved], ["127.0.0.0/8"]) + clear_config([RemoteIp, :proxies], ["10.0.0.3/24"]) conn = conn(:get, "/") diff --git a/test/pleroma/web/plugs/user_enabled_plug_test.exs b/test/pleroma/web/plugs/user_enabled_plug_test.exs index 71822305b..999c6c49c 100644 --- a/test/pleroma/web/plugs/user_enabled_plug_test.exs +++ b/test/pleroma/web/plugs/user_enabled_plug_test.exs @@ -20,7 +20,7 @@ test "doesn't do anything if the user isn't set", %{conn: conn} do test "with a user that's not confirmed and a config requiring confirmation, it removes that user", %{conn: conn} do - Pleroma.Config.put([:instance, :account_activation_required], true) + clear_config([:instance, :account_activation_required], true) user = insert(:user, is_confirmed: false) diff --git a/test/pleroma/web/plugs/user_tracking_plug_test.exs b/test/pleroma/web/plugs/user_tracking_plug_test.exs new file mode 100644 index 000000000..8e9d59b99 --- /dev/null +++ b/test/pleroma/web/plugs/user_tracking_plug_test.exs @@ -0,0 +1,58 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2021 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.Plugs.UserTrackingPlugTest do + use Pleroma.Web.ConnCase, async: true + + import Pleroma.Factory + + alias Pleroma.Web.Plugs.UserTrackingPlug + + test "updates last_active_at for a new user", %{conn: conn} do + user = insert(:user) + + assert is_nil(user.last_active_at) + + test_started_at = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second) + + %{assigns: %{user: user}} = + conn + |> assign(:user, user) + |> UserTrackingPlug.call(%{}) + + assert user.last_active_at >= test_started_at + assert user.last_active_at <= NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) + end + + test "doesn't update last_active_at if it was updated recently", %{conn: conn} do + last_active_at = + NaiveDateTime.utc_now() + |> NaiveDateTime.add(-:timer.hours(1), :millisecond) + |> NaiveDateTime.truncate(:second) + + user = insert(:user, %{last_active_at: last_active_at}) + + %{assigns: %{user: user}} = + conn + |> assign(:user, user) + |> UserTrackingPlug.call(%{}) + + assert user.last_active_at == last_active_at + end + + test "skips updating last_active_at if user ID is nil", %{conn: conn} do + %{assigns: %{user: user}} = + conn + |> assign(:user, %Pleroma.User{}) + |> UserTrackingPlug.call(%{}) + + assert is_nil(user.last_active_at) + end + + test "does nothing if user is not present", %{conn: conn} do + %{assigns: assigns} = UserTrackingPlug.call(conn, %{}) + + refute Map.has_key?(assigns, :user) + end +end diff --git a/test/pleroma/web/rich_media/helpers_test.exs b/test/pleroma/web/rich_media/helpers_test.exs index efa4c91e4..689854fb6 100644 --- a/test/pleroma/web/rich_media/helpers_test.exs +++ b/test/pleroma/web/rich_media/helpers_test.exs @@ -5,7 +5,6 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do use Pleroma.DataCase - alias Pleroma.Config alias Pleroma.Web.CommonAPI alias Pleroma.Web.RichMedia.Helpers @@ -29,7 +28,7 @@ test "refuses to crawl incomplete URLs" do content_type: "text/markdown" }) - Config.put([:rich_media, :enabled], true) + clear_config([:rich_media, :enabled], true) assert %{} == Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity) end @@ -43,7 +42,7 @@ test "refuses to crawl malformed URLs" do content_type: "text/markdown" }) - Config.put([:rich_media, :enabled], true) + clear_config([:rich_media, :enabled], true) assert %{} == Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity) end @@ -57,7 +56,7 @@ test "crawls valid, complete URLs" do content_type: "text/markdown" }) - Config.put([:rich_media, :enabled], true) + clear_config([:rich_media, :enabled], true) assert %{page_url: "https://example.com/ogp", rich_media: _} = Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity) @@ -74,7 +73,7 @@ test "refuses to crawl URLs of private network from posts" do {:ok, activity4} = CommonAPI.post(user, %{status: "https://192.168.10.40/notice/9kCP7V"}) {:ok, activity5} = CommonAPI.post(user, %{status: "https://pleroma.local/notice/9kCP7V"}) - Config.put([:rich_media, :enabled], true) + clear_config([:rich_media, :enabled], true) assert %{} = Helpers.fetch_data_for_activity(activity) assert %{} = Helpers.fetch_data_for_activity(activity2) diff --git a/test/pleroma/web/streamer_test.exs b/test/pleroma/web/streamer_test.exs index 0402e59ea..cef2b7629 100644 --- a/test/pleroma/web/streamer_test.exs +++ b/test/pleroma/web/streamer_test.exs @@ -510,7 +510,7 @@ test "handles deletions" do describe "thread_containment/2" do test "it filters to user if recipients invalid and thread containment is enabled" do - Pleroma.Config.put([:instance, :skip_thread_containment], false) + clear_config([:instance, :skip_thread_containment], false) author = insert(:user) %{user: user, token: oauth_token} = oauth_access(["read"]) User.follow(user, author, :follow_accept) @@ -531,7 +531,7 @@ test "it filters to user if recipients invalid and thread containment is enabled end test "it sends message if recipients invalid and thread containment is disabled" do - Pleroma.Config.put([:instance, :skip_thread_containment], true) + clear_config([:instance, :skip_thread_containment], true) author = insert(:user) %{user: user, token: oauth_token} = oauth_access(["read"]) User.follow(user, author, :follow_accept) @@ -553,7 +553,7 @@ test "it sends message if recipients invalid and thread containment is disabled" end test "it sends message if recipients invalid and thread containment is enabled but user's thread containment is disabled" do - Pleroma.Config.put([:instance, :skip_thread_containment], false) + clear_config([:instance, :skip_thread_containment], false) author = insert(:user) user = insert(:user, skip_thread_containment: true) %{token: oauth_token} = oauth_access(["read"], user: user) diff --git a/test/pleroma/web/twitter_api/remote_follow_controller_test.exs b/test/pleroma/web/twitter_api/remote_follow_controller_test.exs index f9d9e0525..f389c272b 100644 --- a/test/pleroma/web/twitter_api/remote_follow_controller_test.exs +++ b/test/pleroma/web/twitter_api/remote_follow_controller_test.exs @@ -154,7 +154,7 @@ test "returns error when user is deactivated", %{conn: conn} do end test "returns error when user is blocked", %{conn: conn} do - Pleroma.Config.put([:user, :deny_follow_blocked], true) + clear_config([:user, :deny_follow_blocked], true) user = insert(:user) user2 = insert(:user) @@ -365,7 +365,7 @@ test "returns error when password invalid", %{conn: conn} do end test "returns error when user is blocked", %{conn: conn} do - Pleroma.Config.put([:user, :deny_follow_blocked], true) + clear_config([:user, :deny_follow_blocked], true) user = insert(:user) user2 = insert(:user) {:ok, _user_block} = Pleroma.User.block(user2, user) diff --git a/test/pleroma/web/twitter_api/twitter_api_test.exs b/test/pleroma/web/twitter_api/twitter_api_test.exs index 129ffdf4d..85629be04 100644 --- a/test/pleroma/web/twitter_api/twitter_api_test.exs +++ b/test/pleroma/web/twitter_api/twitter_api_test.exs @@ -46,12 +46,7 @@ test "it registers a new user with empty string in bio and returns the user" do end test "it sends confirmation email if :account_activation_required is specified in instance config" do - setting = Pleroma.Config.get([:instance, :account_activation_required]) - - unless setting do - Pleroma.Config.put([:instance, :account_activation_required], true) - on_exit(fn -> Pleroma.Config.put([:instance, :account_activation_required], setting) end) - end + clear_config([:instance, :account_activation_required], true) data = %{ :username => "lain", diff --git a/test/pleroma/web/twitter_api/util_controller_test.exs b/test/pleroma/web/twitter_api/util_controller_test.exs index 283c61678..bdbc478c3 100644 --- a/test/pleroma/web/twitter_api/util_controller_test.exs +++ b/test/pleroma/web/twitter_api/util_controller_test.exs @@ -6,7 +6,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do use Pleroma.Web.ConnCase use Oban.Testing, repo: Pleroma.Repo - alias Pleroma.Config alias Pleroma.Tests.ObanHelpers alias Pleroma.User @@ -66,7 +65,7 @@ test "returns everything in :pleroma, :frontend_configurations", %{conn: conn} d } ] - Config.put(:frontend_configurations, config) + clear_config(:frontend_configurations, config) response = conn @@ -99,7 +98,7 @@ test "returns json with custom emoji with tags", %{conn: conn} do setup do: clear_config([:instance, :healthcheck]) test "returns 503 when healthcheck disabled", %{conn: conn} do - Config.put([:instance, :healthcheck], false) + clear_config([:instance, :healthcheck], false) response = conn @@ -110,7 +109,7 @@ test "returns 503 when healthcheck disabled", %{conn: conn} do end test "returns 200 when healthcheck enabled and all ok", %{conn: conn} do - Config.put([:instance, :healthcheck], true) + clear_config([:instance, :healthcheck], true) with_mock Pleroma.Healthcheck, system_info: fn -> %Pleroma.Healthcheck{healthy: true} end do @@ -130,7 +129,7 @@ test "returns 200 when healthcheck enabled and all ok", %{conn: conn} do end test "returns 503 when healthcheck enabled and health is false", %{conn: conn} do - Config.put([:instance, :healthcheck], true) + clear_config([:instance, :healthcheck], true) with_mock Pleroma.Healthcheck, system_info: fn -> %Pleroma.Healthcheck{healthy: false} end do diff --git a/test/pleroma/workers/cron/digest_emails_worker_test.exs b/test/pleroma/workers/cron/digest_emails_worker_test.exs index 79614212a..b3ca6235b 100644 --- a/test/pleroma/workers/cron/digest_emails_worker_test.exs +++ b/test/pleroma/workers/cron/digest_emails_worker_test.exs @@ -14,7 +14,7 @@ defmodule Pleroma.Workers.Cron.DigestEmailsWorkerTest do setup do: clear_config([:email_notifications, :digest]) setup do - Pleroma.Config.put([:email_notifications, :digest], %{ + clear_config([:email_notifications, :digest], %{ active: true, inactivity_threshold: 7, interval: 7 diff --git a/test/pleroma/workers/scheduled_activity_worker_test.exs b/test/pleroma/workers/scheduled_activity_worker_test.exs index 6786e639d..6e11642d5 100644 --- a/test/pleroma/workers/scheduled_activity_worker_test.exs +++ b/test/pleroma/workers/scheduled_activity_worker_test.exs @@ -14,7 +14,7 @@ defmodule Pleroma.Workers.ScheduledActivityWorkerTest do setup do: clear_config([ScheduledActivity, :enabled]) test "creates a status from the scheduled activity" do - Pleroma.Config.put([ScheduledActivity, :enabled], true) + clear_config([ScheduledActivity, :enabled], true) user = insert(:user) naive_datetime = @@ -40,7 +40,7 @@ test "creates a status from the scheduled activity" do end test "adds log message if ScheduledActivity isn't find" do - Pleroma.Config.put([ScheduledActivity, :enabled], true) + clear_config([ScheduledActivity, :enabled], true) assert capture_log([level: :error], fn -> ScheduledActivityWorker.perform(%Oban.Job{args: %{"activity_id" => 42}}) diff --git a/test/support/factory.ex b/test/support/factory.ex index bf9592064..436e19409 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -104,6 +104,37 @@ def note_factory(attrs \\ %{}) do } end + def attachment_note_factory(attrs \\ %{}) do + user = attrs[:user] || insert(:user) + {length, attrs} = Map.pop(attrs, :length, 1) + + data = %{ + "attachment" => + Stream.repeatedly(fn -> attachment_data(user.ap_id, attrs[:href]) end) + |> Enum.take(length) + } + + build(:note, Map.put(attrs, :data, data)) + end + + defp attachment_data(ap_id, href) do + href = href || sequence(:href, &"#{Pleroma.Web.Endpoint.url()}/media/#{&1}.jpg") + + %{ + "url" => [ + %{ + "href" => href, + "type" => "Link", + "mediaType" => "image/jpeg" + } + ], + "name" => "some name", + "type" => "Document", + "actor" => ap_id, + "mediaType" => "image/jpeg" + } + end + def audio_factory(attrs \\ %{}) do text = sequence(:text, &"lain radio episode #{&1}")