diff --git a/CHANGELOG.md b/CHANGELOG.md index 47c5078b8..f9a32f430 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Admin API: Reports now ordered by newest - Deprecated `Pleroma.Uploaders.S3, :public_endpoint`. Now `Pleroma.Upload, :base_url` is the standard configuration key for all uploaders. - Improved Apache webserver support: updated sample configuration, MediaProxy cache invalidation verified with the included sample script +- Improve OAuth 2.0 provider support. A missing `fqn` field was added to the response, but does not expose the user's email address. - Extracted object hashtags into separate table in order to improve hashtag timeline performance (via background migration in `Pleroma.Migrators.HashtagsTableMigrator`). ### Added @@ -49,7 +50,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Mastodon API: User and conversation mutes can now auto-expire if `expires_in` parameter was given while adding the mute. - Admin API: An endpoint to manage frontends. - Streaming API: Add follow relationships updates. -- WebPush: Introduce `pleroma:chat_mention` and `pleroma:emoji_reaction` notification types +- 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. ### Fixed @@ -59,6 +63,9 @@ 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 +- File extensions of some attachments were incorrectly changed. This feature has been disabled for now. +- Mix task pleroma.instance creates missing parent directories if the configuration or SQL output paths are changed.
API Changes diff --git a/docs/configuration/auth.md b/docs/configuration/auth.md new file mode 100644 index 000000000..c80f094e7 --- /dev/null +++ b/docs/configuration/auth.md @@ -0,0 +1 @@ +See `Authentication` section of [the configuration cheatsheet](../configuration/cheatsheet.md#authentication). diff --git a/docs/configuration/cheatsheet.md b/docs/configuration/cheatsheet.md index 9d4b07bf4..ad5768465 100644 --- a/docs/configuration/cheatsheet.md +++ b/docs/configuration/cheatsheet.md @@ -893,6 +893,22 @@ Pleroma account will be created with the same name as the LDAP user name. Note, if your LDAP server is an Active Directory server the correct value is commonly `uid: "cn"`, but if you use an OpenLDAP server the value may be `uid: "uid"`. +### :oauth2 (Pleroma as OAuth 2.0 provider settings) + +OAuth 2.0 provider settings: + +* `token_expires_in` - The lifetime in seconds of the access token. +* `issue_new_refresh_token` - Keeps old refresh token or generate new refresh token when to obtain an access token. +* `clean_expired_tokens` - Enable a background job to clean expired oauth tokens. Defaults to `false`. + +OAuth 2.0 provider and related endpoints: + +* `POST /api/v1/apps` creates client app basing on provided params. +* `GET/POST /oauth/authorize` renders/submits authorization form. +* `POST /oauth/token` creates/renews OAuth token. +* `POST /oauth/revoke` revokes provided OAuth token. +* `GET /api/v1/accounts/verify_credentials` (with proper `Authorization` header or `access_token` URI param) returns user info on requester (with `acct` field containing local nickname and `fqn` field containing fully-qualified nickname which could generally be used as email stub for OAuth software that demands email field in identity endpoint response, like Peertube). + ### OAuth consumer mode OAuth consumer mode allows sign in / sign up via external OAuth providers (e.g. Twitter, Facebook, Google, Microsoft, etc.). @@ -965,14 +981,6 @@ config :ueberauth, Ueberauth, ] ``` -### OAuth 2.0 provider - :oauth2 - -Configure OAuth 2 provider capabilities: - -* `token_expires_in` - The lifetime in seconds of the access token. -* `issue_new_refresh_token` - Keeps old refresh token or generate new refresh token when to obtain an access token. -* `clean_expired_tokens` - Enable a background job to clean expired oauth tokens. Defaults to `false`. - ## Link parsing ### :uri_schemes diff --git a/docs/development/API/differences_in_mastoapi_responses.md b/docs/development/API/differences_in_mastoapi_responses.md index 84430408b..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,23 @@ 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` +- `/api/v1/accounts/:id/followers` +- `/api/v1/accounts/:id/following` +- `/api/v1/mutes` + Has these additional fields under the `pleroma` object: - `ap_id`: nullable URL string, ActivityPub id of the user diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex index f272fdb7f..da27a99d0 100644 --- a/lib/mix/tasks/pleroma/instance.ex +++ b/lib/mix/tasks/pleroma/instance.ex @@ -242,6 +242,13 @@ def run(["gen" | rest]) do rum_enabled: rum_enabled ) + config_dir = Path.dirname(config_path) + psql_dir = Path.dirname(psql_path) + + [config_dir, psql_dir, static_dir, uploads_dir] + |> Enum.reject(&File.exists?/1) + |> Enum.map(&File.mkdir_p!/1) + shell_info("Writing config to #{config_path}.") File.write(config_path, result_config) @@ -275,10 +282,6 @@ defp write_robots_txt(static_dir, indexable, template_dir) do indexable: indexable ) - unless File.exists?(static_dir) do - File.mkdir_p!(static_dir) - end - robots_txt_path = Path.join(static_dir, "robots.txt") if File.exists?(robots_txt_path) do diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index e422b59f1..b69709db4 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, @@ -2030,6 +2031,15 @@ def local_nickname(nickname_or_mention) do |> hd() end + def full_nickname(%User{} = user) do + if String.contains?(user.nickname, "@") do + user.nickname + else + %{host: host} = URI.parse(user.ap_id) + user.nickname <> "@" <> host + end + end + def full_nickname(nickname_or_mention), do: String.trim_leading(nickname_or_mention, "@") @@ -2444,4 +2454,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 6cf4093fb..573b4243c 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -824,6 +824,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 @@ -1198,6 +1204,7 @@ def fetch_activities_query(recipients, opts \\ %{}) do |> restrict_replies(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 80acee2f7..3d451cd5a 100644 --- a/lib/pleroma/web/api_spec/operations/account_operation.ex +++ b/lib/pleroma/web/api_spec/operations/account_operation.ex @@ -99,7 +99,10 @@ def show_operation do summary: "Account", operationId: "AccountController.show", description: "View information about a profile.", - parameters: [%Reference{"$ref": "#/components/parameters/accountIdOrNickname"}], + parameters: [ + %Reference{"$ref": "#/components/parameters/accountIdOrNickname"}, + with_relationships_param() + ], responses: %{ 200 => Operation.response("Account", "application/json", Account), 401 => Operation.response("Error", "application/json", ApiError), @@ -130,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"), @@ -144,7 +147,7 @@ def statuses_operation do :with_muted, :query, BooleanLike, - "Include reactions from muted acccounts." + "Include reactions from muted accounts." ) ] ++ pagination_params(), responses: %{ @@ -347,7 +350,7 @@ def mutes_operation do operationId: "AccountController.mutes", description: "Accounts the user has muted.", security: [%{"oAuth" => ["follow", "read:mutes"]}], - parameters: pagination_params(), + parameters: [with_relationships_param() | pagination_params()], responses: %{ 200 => Operation.response("Accounts", "application/json", array_of_accounts()) } 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/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex index d277aeca5..7a1e99044 100644 --- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex @@ -269,10 +269,14 @@ def relationships(%{assigns: %{user: user}} = conn, %{id: id}) do def relationships(%{assigns: %{user: _user}} = conn, _), do: json(conn, []) @doc "GET /api/v1/accounts/:id" - def show(%{assigns: %{user: for_user}} = conn, %{id: nickname_or_id}) do + def show(%{assigns: %{user: for_user}} = conn, %{id: nickname_or_id} = params) do with %User{} = user <- User.get_cached_by_nickname_or_id(nickname_or_id, for: for_user), :visible <- User.visible_for(user, for_user) do - render(conn, "show.json", user: user, for: for_user) + render(conn, "show.json", + user: user, + for: for_user, + embed_relationships: embed_relationships?(params) + ) else error -> user_visibility_error(conn, error) end @@ -454,7 +458,12 @@ def mutes(%{assigns: %{user: user}} = conn, params) do conn |> add_link_headers(users) - |> render("index.json", users: users, for: user, as: :user) + |> render("index.json", + users: users, + for: user, + as: :user, + embed_relationships: embed_relationships?(params) + ) end @doc "GET /api/v1/blocks" diff --git a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex index 1fb954a9b..87effa00b 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/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 63417142f..ac25aefdd 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -262,7 +262,9 @@ defp do_render("show.json", %{user: user} = opts) do } }, - # Pleroma extension + # Pleroma extensions + # Note: it's insecure to output :email but fully-qualified nickname may serve as safe stub + fqn: User.full_nickname(user), pleroma: %{ ap_id: user.ap_id, also_known_as: user.also_known_as, 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..2105d7e9e 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 @@ -319,6 +320,8 @@ defmodule Pleroma.Web.Router do end scope "/oauth", Pleroma.Web.OAuth do + # Note: use /api/v1/accounts/verify_credentials for userinfo of signed-in user + get("/registration_details", OAuthController, :registration_details) post("/mfa/verify", MFAController, :verify, as: :mfa_verify) diff --git a/lib/pleroma/web/templates/embed/show.html.eex b/lib/pleroma/web/templates/embed/show.html.eex index 05a3f0ee3..092b52b70 100644 --- a/lib/pleroma/web/templates/embed/show.html.eex +++ b/lib/pleroma/web/templates/embed/show.html.eex @@ -6,7 +6,7 @@ <%= raw (@author.name |> Formatter.emojify(@author.emoji)) %> - <%= full_nickname(@author) %> + @<%= full_nickname(@author) %> diff --git a/lib/pleroma/web/views/embed_view.ex b/lib/pleroma/web/views/embed_view.ex index cb7600adb..81e196730 100644 --- a/lib/pleroma/web/views/embed_view.ex +++ b/lib/pleroma/web/views/embed_view.ex @@ -17,6 +17,8 @@ defmodule Pleroma.Web.EmbedView do use Phoenix.HTML + defdelegate full_nickname(user), to: User + @media_types ["image", "audio", "video"] defp fetch_media_type(%{"mediaType" => mediaType}) do @@ -30,11 +32,6 @@ defp open_content? do ) end - defp full_nickname(user) do - %{host: host} = URI.parse(user.ap_id) - "@" <> user.nickname <> "@" <> host - end - defp status_title(%Activity{object: %Object{data: %{"name" => name}}}) when is_binary(name), do: name 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/mix.exs b/mix.exs index 489bb5729..50d4b4080 100644 --- a/mix.exs +++ b/mix.exs @@ -194,7 +194,7 @@ defp deps do {:restarter, path: "./restarter"}, {:majic, git: "https://git.pleroma.social/pleroma/elixir-libraries/majic.git", - ref: "4c692e544b28d1f5e543fb8a44be090f8cd96f80"}, + ref: "289cda1b6d0d70ccb2ba508a2b0bd24638db2880"}, {:open_api_spex, git: "https://git.pleroma.social/pleroma/elixir-libraries/open_api_spex.git", ref: "f296ac0924ba3cf79c7a588c4c252889df4c2edd"}, diff --git a/mix.lock b/mix.lock index 840a82555..3e5631c72 100644 --- a/mix.lock +++ b/mix.lock @@ -66,7 +66,7 @@ "jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"}, "libring": {:hex, :libring, "1.4.0", "41246ba2f3fbc76b3971f6bce83119dfec1eee17e977a48d8a9cfaaf58c2a8d6", [:mix], [], "hexpm"}, "linkify": {:hex, :linkify, "0.4.1", "f881eb3429ae88010cf736e6fb3eed406c187bcdd544902ec937496636b7c7b3", [:mix], [], "hexpm", "ce98693f54ae9ace59f2f7a8aed3de2ef311381a8ce7794804bd75484c371dda"}, - "majic": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/majic.git", "4c692e544b28d1f5e543fb8a44be090f8cd96f80", [ref: "4c692e544b28d1f5e543fb8a44be090f8cd96f80"]}, + "majic": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/majic.git", "289cda1b6d0d70ccb2ba508a2b0bd24638db2880", [ref: "289cda1b6d0d70ccb2ba508a2b0bd24638db2880"]}, "makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"}, "makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"}, "meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm", "d34f013c156db51ad57cc556891b9720e6a1c1df5fe2e15af999c84d6cebeb1a"}, 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/pleroma/user_test.exs b/test/pleroma/user_test.exs index b4df22c2c..be39339f3 100644 --- a/test/pleroma/user_test.exs +++ b/test/pleroma/user_test.exs @@ -2232,6 +2232,36 @@ test "Notifications are updated", %{user: user} do end end + describe "local_nickname/1" do + test "returns nickname without host" do + assert User.local_nickname("@mentioned") == "mentioned" + assert User.local_nickname("a_local_nickname") == "a_local_nickname" + assert User.local_nickname("nickname@host.com") == "nickname" + end + end + + describe "full_nickname/1" do + test "returns fully qualified nickname for local and remote users" do + local_user = + insert(:user, nickname: "local_user", ap_id: "https://somehost.com/users/local_user") + + remote_user = insert(:user, nickname: "remote@host.com", local: false) + + assert User.full_nickname(local_user) == "local_user@somehost.com" + assert User.full_nickname(remote_user) == "remote@host.com" + end + + test "strips leading @ from mentions" do + assert User.full_nickname("@mentioned") == "mentioned" + assert User.full_nickname("@nickname@host.com") == "nickname@host.com" + end + + test "does not modify nicknames" do + assert User.full_nickname("nickname") == "nickname" + assert User.full_nickname("nickname@host.com") == "nickname@host.com" + end + end + test "avatar fallback" do user = insert(:user) assert User.avatar_url(user) =~ "/images/avi.png" @@ -2248,4 +2278,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 f7417de31..91a3109bb 100644 --- a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs @@ -1607,9 +1607,9 @@ test "POST /api/ap/upload_media", %{conn: conn} do desc = "Description of the image" image = %Plug.Upload{ - content_type: "bad/content-type", + content_type: "image/jpeg", path: Path.absname("test/fixtures/image.jpg"), - filename: "an_image.png" + filename: "an_image.jpg" } object = 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 b7a3edd4b..a327c0d1d 100644 --- a/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/account_controller_test.exs @@ -29,6 +29,45 @@ test "works by id" do |> json_response_and_validate_schema(404) end + test "relationship field" do + %{conn: conn, user: user} = oauth_access(["read"]) + + other_user = insert(:user) + + response = + conn + |> get("/api/v1/accounts/#{other_user.id}") + |> json_response_and_validate_schema(200) + + assert response["id"] == other_user.id + assert response["pleroma"]["relationship"] == %{} + + assert %{"pleroma" => %{"relationship" => %{"following" => false, "followed_by" => false}}} = + conn + |> get("/api/v1/accounts/#{other_user.id}?with_relationships=true") + |> json_response_and_validate_schema(200) + + {:ok, _, %{id: other_id}} = User.follow(user, other_user) + + assert %{ + "id" => ^other_id, + "pleroma" => %{"relationship" => %{"following" => true, "followed_by" => false}} + } = + conn + |> get("/api/v1/accounts/#{other_id}?with_relationships=true") + |> json_response_and_validate_schema(200) + + {:ok, _, _} = User.follow(other_user, user) + + assert %{ + "id" => ^other_id, + "pleroma" => %{"relationship" => %{"following" => true, "followed_by" => true}} + } = + conn + |> get("/api/v1/accounts/#{other_id}?with_relationships=true") + |> json_response_and_validate_schema(200) + end + test "works by nickname" do user = insert(:user) @@ -590,6 +629,45 @@ test "getting followers", %{user: user, conn: conn} do assert [%{"id" => ^user_id}] = json_response_and_validate_schema(conn, 200) end + test "following with relationship", %{conn: conn, user: user} do + other_user = insert(:user) + {:ok, %{id: id}, _} = User.follow(other_user, user) + + assert [ + %{ + "id" => ^id, + "pleroma" => %{ + "relationship" => %{ + "id" => ^id, + "following" => false, + "followed_by" => true + } + } + } + ] = + conn + |> get("/api/v1/accounts/#{user.id}/followers?with_relationships=true") + |> json_response_and_validate_schema(200) + + {:ok, _, _} = User.follow(user, other_user) + + assert [ + %{ + "id" => ^id, + "pleroma" => %{ + "relationship" => %{ + "id" => ^id, + "following" => true, + "followed_by" => true + } + } + } + ] = + conn + |> get("/api/v1/accounts/#{user.id}/followers?with_relationships=true") + |> json_response_and_validate_schema(200) + end + test "getting followers, hide_followers", %{user: user, conn: conn} do other_user = insert(:user, hide_followers: true) {:ok, _user, _other_user} = User.follow(user, other_user) @@ -660,6 +738,24 @@ test "getting following", %{user: user, conn: conn} do assert id == to_string(other_user.id) end + test "following with relationship", %{conn: conn, user: user} do + other_user = insert(:user) + {:ok, user, other_user} = User.follow(user, other_user) + + conn = get(conn, "/api/v1/accounts/#{user.id}/following?with_relationships=true") + + id = other_user.id + + assert [ + %{ + "id" => ^id, + "pleroma" => %{ + "relationship" => %{"id" => ^id, "following" => true, "followed_by" => false} + } + } + ] = json_response_and_validate_schema(conn, 200) + end + test "getting following, hide_follows, other user requesting" do user = insert(:user, hide_follows: true) other_user = insert(:user) @@ -1565,7 +1661,6 @@ test "getting a list of mutes" do result = conn - |> assign(:user, user) |> get("/api/v1/mutes") |> json_response_and_validate_schema(200) @@ -1573,7 +1668,6 @@ test "getting a list of mutes" do result = conn - |> assign(:user, user) |> get("/api/v1/mutes?limit=1") |> json_response_and_validate_schema(200) @@ -1581,7 +1675,6 @@ test "getting a list of mutes" do result = conn - |> assign(:user, user) |> get("/api/v1/mutes?since_id=#{id1}") |> json_response_and_validate_schema(200) @@ -1589,7 +1682,6 @@ test "getting a list of mutes" do result = conn - |> assign(:user, user) |> get("/api/v1/mutes?since_id=#{id1}&max_id=#{id3}") |> json_response_and_validate_schema(200) @@ -1597,13 +1689,45 @@ test "getting a list of mutes" do result = conn - |> assign(:user, user) |> get("/api/v1/mutes?since_id=#{id1}&limit=1") |> json_response_and_validate_schema(200) assert [%{"id" => ^id2}] = result end + test "list of mutes with with_relationships parameter" do + %{user: user, conn: conn} = oauth_access(["read:mutes"]) + %{id: id1} = other_user1 = insert(:user) + %{id: id2} = other_user2 = insert(:user) + %{id: id3} = other_user3 = insert(:user) + + {:ok, _, _} = User.follow(other_user1, user) + {:ok, _, _} = User.follow(other_user2, user) + {:ok, _, _} = User.follow(other_user3, user) + + {:ok, _} = User.mute(user, other_user1) + {:ok, _} = User.mute(user, other_user2) + {:ok, _} = User.mute(user, other_user3) + + assert [ + %{ + "id" => ^id1, + "pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}} + }, + %{ + "id" => ^id2, + "pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}} + }, + %{ + "id" => ^id3, + "pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}} + } + ] = + conn + |> get("/api/v1/mutes?with_relationships=true") + |> json_response_and_validate_schema(200) + end + test "getting a list of blocks" do %{user: user, conn: conn} = oauth_access(["read:blocks"]) %{id: id1} = other_user1 = insert(:user) 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/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs index a647cd57f..3c73eb514 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -263,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" => 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/views/account_view_test.exs b/test/pleroma/web/mastodon_api/views/account_view_test.exs index 999bde474..5373a17c3 100644 --- a/test/pleroma/web/mastodon_api/views/account_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs @@ -73,6 +73,7 @@ test "Represent a user account" do }, fields: [] }, + fqn: "shp@shitposter.club", pleroma: %{ ap_id: user.ap_id, also_known_as: ["https://shitposter.zone/users/shp"], @@ -172,6 +173,7 @@ test "Represent a Service(bot) account" do }, fields: [] }, + fqn: "shp@shitposter.club", pleroma: %{ ap_id: user.ap_id, also_known_as: [], 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/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/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}")