Merge branch 'cycles-router-mediaproxy' into 'develop'
authorfeld <feld@feld.me>
Fri, 28 May 2021 18:22:27 +0000 (18:22 +0000)
committerfeld <feld@feld.me>
Fri, 28 May 2021 18:22:27 +0000 (18:22 +0000)
Recompilation speedup: don't make MediaProxy be a compile-dep of Router

See merge request pleroma/pleroma!3418

15 files changed:
CHANGELOG.md
config/benchmark.exs
config/config.exs
config/description.exs
config/dev.exs
config/dokku.exs
config/prod.exs
config/test.exs
lib/pleroma/web/activity_pub/views/user_view.ex
lib/pleroma/web/mastodon_api/views/account_view.ex
test/fixtures/config/temp.exported_from_db.secret.exs
test/fixtures/config/temp.secret.exs
test/mix/tasks/pleroma/config_test.exs
test/pleroma/web/activity_pub/activity_pub_controller_test.exs
test/pleroma/web/mastodon_api/views/account_view_test.exs

index 898f8adb5e986311aae4874c80474384fc3ec373..eacba02085fd12c17c3aa06ba4b144b7ca966a3d 100644 (file)
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 
 - The `application` metadata returned with statuses is no longer hardcoded. Apps that want to display these details will now have valid data for new posts after this change.
 - HTTPSecurityPlug now sends a response header to opt out of Google's FLoC (Federated Learning of Cohorts) targeted advertising.
+- Email address is now returned if requesting user is the owner of the user account so it can be exposed in client and FE user settings UIs.
 
 ### Added
 
@@ -17,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Return OAuth token `id` (primary key) in POST `/oauth/token`.
 - `AnalyzeMetadata` upload filter for extracting attachment dimensions and generating blurhashes.
 - Attachment dimensions and blurhashes are federated when available.
+- Pinned posts federation
 
 ### Fixed
 - Don't crash so hard when email settings are invalid.
index 5567ff26e4694fea7e699b8efccc544c1ff110e3..a4d048f1bb0a91dc89daeb5812a73ffe456f23b7 100644 (file)
@@ -1,4 +1,4 @@
-use Mix.Config
+import Config
 
 # We don't run a server during test. If one is required,
 # you can enable the server option below.
index 4381068ac34afa3fa488672f5716a777bbc7b427..d333c618ecb28c6b7604ac9bbe86c80c87859417 100644 (file)
@@ -41,7 +41,7 @@
 #
 # This configuration file is loaded before any dependency and
 # is restricted to this project.
-use Mix.Config
+import Config
 
 # General application configuration
 config :pleroma, ecto_repos: [Pleroma.Repo]
index bb1f4330565b0ea8e64480dab4585ff44113d502..f00c53d287cc32f457fb6e9023f325ec312059d9 100644 (file)
@@ -1,4 +1,4 @@
-use Mix.Config
+import Config
 
 websocket_config = [
   path: "/websocket",
index 4faaeff5bfbf7881f72468a3a33d44b4f8a6abf9..cfe3cce471915c740e4d66ef191076f393a11edd 100644 (file)
@@ -1,4 +1,4 @@
-use Mix.Config
+import Config
 
 # For development, we disable any cache and enable
 # debugging and code reloading.
index 9ea0ec450161529855eed3e7dc44b0117b30cfbd..1cc396c3df0fe73bccbd1235518e92a08f9a6321 100644 (file)
@@ -1,4 +1,4 @@
-use Mix.Config
+import Config
 
 config :pleroma, Pleroma.Web.Endpoint,
   http: [
index 0e151000b9215cd1e8840b8d321cd65260f623ee..968f596e00bc804bb71e06e112b2487f8939700f 100644 (file)
@@ -1,4 +1,4 @@
-use Mix.Config
+import Config
 
 # For production, we often load configuration from external
 # sources, such as your system environment. For this reason,
index 87396a88dbfe98e0764db7817c54476eb9c48ddb..c531b1290f381ad0c627129e3022a337d5784a92 100644 (file)
@@ -1,4 +1,4 @@
-use Mix.Config
+import Config
 
 # We don't run a server during test. If one is required,
 # you can enable the server option below.
index 462f3b4a79981993db74d2e6b6355631a51e1edd..344da19d3a24f6b2c2ee887b45d8be612a7acbf2 100644 (file)
@@ -261,7 +261,8 @@ defmodule Pleroma.Web.ActivityPub.UserView do
     %{
       "id" => featured_address,
       "type" => "OrderedCollection",
-      "orderedItems" => objects
+      "orderedItems" => objects,
+      "totalItems" => length(objects)
     }
     |> Map.merge(Utils.make_json_ld_header())
   end
index ac25aefdd6653850c4843e585aada9898d2b87e5..9e9de33f6167c615158440da34d0f6b3dd877a98 100644 (file)
@@ -292,6 +292,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
     |> maybe_put_allow_following_move(user, opts[:for])
     |> maybe_put_unread_conversation_count(user, opts[:for])
     |> maybe_put_unread_notification_count(user, opts[:for])
+    |> maybe_put_email_address(user, opts[:for])
   end
 
   defp username_from_nickname(string) when is_binary(string) do
@@ -403,6 +404,16 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
 
   defp maybe_put_unread_notification_count(data, _, _), do: data
 
+  defp maybe_put_email_address(data, %User{id: user_id}, %User{id: user_id} = user) do
+    Kernel.put_in(
+      data,
+      [:pleroma, :email],
+      user.email
+    )
+  end
+
+  defp maybe_put_email_address(data, _, _), do: data
+
   defp image_url(%{"url" => [%{"href" => href} | _]}), do: href
   defp image_url(_), do: nil
 end
index 64bee7f32d7c7fc9e8f540c3fc6cda83abdbf49e..dda5d0fa6207f4fdfa90aa985c542438ae854a6d 100644 (file)
@@ -1,4 +1,4 @@
-use Mix.Config
+import Config
 
 config :pleroma, exported_config_merged: true
 
index 4b3af39ecec6bcca251df26a488a616017245b55..9c5c88d98890f2745d0b9afd975979b51b21333d 100644 (file)
@@ -2,7 +2,7 @@
 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
-use Mix.Config
+import Config
 
 config :pleroma, :first_setting, key: "value", key2: [Pleroma.Repo]
 
index 3ed1e94b8ad4f0f9b27b10bd7ab259ee04a28875..2b8252db7e926cedc0b41e54fbf7144bcb59871e 100644 (file)
@@ -188,15 +188,8 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
       assert File.exists?(temp_file)
       {:ok, file} = File.read(temp_file)
 
-      header =
-        if Code.ensure_loaded?(Config.Reader) do
-          "import Config"
-        else
-          "use Mix.Config"
-        end
-
       assert file ==
-               "#{header}\n\nconfig :pleroma, :instance,\n  name: \"Pleroma\",\n  email: \"example@example.com\",\n  notify_email: \"noreply@example.com\",\n  description: \"A Pleroma instance, an alternative fediverse server\",\n  limit: 5000,\n  chat_limit: 5000,\n  remote_limit: 100_000,\n  upload_limit: 16_000_000,\n  avatar_upload_limit: 2_000_000,\n  background_upload_limit: 4_000_000,\n  banner_upload_limit: 4_000_000,\n  poll_limits: %{\n    max_expiration: 31_536_000,\n    max_option_chars: 200,\n    max_options: 20,\n    min_expiration: 0\n  },\n  registrations_open: true,\n  federating: true,\n  federation_incoming_replies_max_depth: 100,\n  federation_reachability_timeout_days: 7,\n  federation_publisher_modules: [Pleroma.Web.ActivityPub.Publisher],\n  allow_relay: true,\n  public: true,\n  quarantined_instances: [],\n  managed_config: true,\n  static_dir: \"instance/static/\",\n  allowed_post_formats: [\"text/plain\", \"text/html\", \"text/markdown\", \"text/bbcode\"],\n  autofollowed_nicknames: [],\n  max_pinned_statuses: 1,\n  attachment_links: false,\n  max_report_comment_size: 1000,\n  safe_dm_mentions: false,\n  healthcheck: false,\n  remote_post_retention_days: 90,\n  skip_thread_containment: true,\n  limit_to_local_content: :unauthenticated,\n  user_bio_length: 5000,\n  user_name_length: 100,\n  max_account_fields: 10,\n  max_remote_account_fields: 20,\n  account_field_name_length: 512,\n  account_field_value_length: 2048,\n  external_user_synchronization: true,\n  extended_nickname_format: true,\n  multi_factor_authentication: [\n    totp: [digits: 6, period: 30],\n    backup_codes: [number: 2, length: 6]\n  ]\n"
+               "import Config\n\nconfig :pleroma, :instance,\n  name: \"Pleroma\",\n  email: \"example@example.com\",\n  notify_email: \"noreply@example.com\",\n  description: \"A Pleroma instance, an alternative fediverse server\",\n  limit: 5000,\n  chat_limit: 5000,\n  remote_limit: 100_000,\n  upload_limit: 16_000_000,\n  avatar_upload_limit: 2_000_000,\n  background_upload_limit: 4_000_000,\n  banner_upload_limit: 4_000_000,\n  poll_limits: %{\n    max_expiration: 31_536_000,\n    max_option_chars: 200,\n    max_options: 20,\n    min_expiration: 0\n  },\n  registrations_open: true,\n  federating: true,\n  federation_incoming_replies_max_depth: 100,\n  federation_reachability_timeout_days: 7,\n  federation_publisher_modules: [Pleroma.Web.ActivityPub.Publisher],\n  allow_relay: true,\n  public: true,\n  quarantined_instances: [],\n  managed_config: true,\n  static_dir: \"instance/static/\",\n  allowed_post_formats: [\"text/plain\", \"text/html\", \"text/markdown\", \"text/bbcode\"],\n  autofollowed_nicknames: [],\n  max_pinned_statuses: 1,\n  attachment_links: false,\n  max_report_comment_size: 1000,\n  safe_dm_mentions: false,\n  healthcheck: false,\n  remote_post_retention_days: 90,\n  skip_thread_containment: true,\n  limit_to_local_content: :unauthenticated,\n  user_bio_length: 5000,\n  user_name_length: 100,\n  max_account_fields: 10,\n  max_remote_account_fields: 20,\n  account_field_name_length: 512,\n  account_field_value_length: 2048,\n  external_user_synchronization: true,\n  extended_nickname_format: true,\n  multi_factor_authentication: [\n    totp: [digits: 6, period: 30],\n    backup_codes: [number: 2, length: 6]\n  ]\n"
     end
   end
 
index cea4b3a975250d9115e6ab72fac1938aac0620ba..c1e13c7cbed2e6653263deb9fb1b99ebb30741cb 100644 (file)
@@ -1966,7 +1966,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
     %{nickname: nickname, featured_address: featured_address, pinned_objects: pinned_objects} =
       refresh_record(user)
 
-    %{"id" => ^featured_address, "orderedItems" => items} =
+    %{"id" => ^featured_address, "orderedItems" => items, "totalItems" => 2} =
       conn
       |> get("/users/#{nickname}/collections/featured")
       |> json_response(200)
index 5373a17c38f84a0db34a20ef213e0812daadd7b3..3fa17a6caf91557b99b9aaf6f0dceea3392b43a6 100644 (file)
@@ -468,6 +468,23 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
                %{user: user, for: user}
              )[:pleroma][:unread_notifications_count] == 7
     end
+
+    test "shows email only to the account owner" do
+      user = insert(:user)
+      other_user = insert(:user)
+
+      user = User.get_cached_by_ap_id(user.ap_id)
+
+      assert AccountView.render(
+               "show.json",
+               %{user: user, for: other_user}
+             )[:pleroma][:email] == nil
+
+      assert AccountView.render(
+               "show.json",
+               %{user: user, for: user}
+             )[:pleroma][:email] == user.email
+    end
   end
 
   describe "follow requests counter" do