summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--config/benchmark.exs2
-rw-r--r--config/config.exs2
-rw-r--r--config/description.exs2
-rw-r--r--config/dev.exs2
-rw-r--r--config/dokku.exs2
-rw-r--r--config/prod.exs2
-rw-r--r--config/test.exs2
-rw-r--r--lib/pleroma/web/activity_pub/views/user_view.ex3
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex11
-rw-r--r--lib/pleroma/web/router.ex10
-rw-r--r--test/fixtures/config/temp.exported_from_db.secret.exs2
-rw-r--r--test/fixtures/config/temp.secret.exs2
-rw-r--r--test/mix/tasks/pleroma/config_test.exs9
-rw-r--r--test/pleroma/web/activity_pub/activity_pub_controller_test.exs2
-rw-r--r--test/pleroma/web/mastodon_api/views/account_view_test.exs17
16 files changed, 48 insertions, 24 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 898f8adb5..eacba0208 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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.
diff --git a/config/benchmark.exs b/config/benchmark.exs
index 5567ff26e..a4d048f1b 100644
--- a/config/benchmark.exs
+++ b/config/benchmark.exs
@@ -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.
diff --git a/config/config.exs b/config/config.exs
index 4381068ac..d333c618e 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -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]
diff --git a/config/description.exs b/config/description.exs
index bb1f43305..f00c53d28 100644
--- a/config/description.exs
+++ b/config/description.exs
@@ -1,4 +1,4 @@
-use Mix.Config
+import Config
websocket_config = [
path: "/websocket",
diff --git a/config/dev.exs b/config/dev.exs
index 4faaeff5b..cfe3cce47 100644
--- a/config/dev.exs
+++ b/config/dev.exs
@@ -1,4 +1,4 @@
-use Mix.Config
+import Config
# For development, we disable any cache and enable
# debugging and code reloading.
diff --git a/config/dokku.exs b/config/dokku.exs
index 9ea0ec450..1cc396c3d 100644
--- a/config/dokku.exs
+++ b/config/dokku.exs
@@ -1,4 +1,4 @@
-use Mix.Config
+import Config
config :pleroma, Pleroma.Web.Endpoint,
http: [
diff --git a/config/prod.exs b/config/prod.exs
index 0e151000b..968f596e0 100644
--- a/config/prod.exs
+++ b/config/prod.exs
@@ -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,
diff --git a/config/test.exs b/config/test.exs
index 87396a88d..c531b1290 100644
--- a/config/test.exs
+++ b/config/test.exs
@@ -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.
diff --git a/lib/pleroma/web/activity_pub/views/user_view.ex b/lib/pleroma/web/activity_pub/views/user_view.ex
index 462f3b4a7..344da19d3 100644
--- a/lib/pleroma/web/activity_pub/views/user_view.ex
+++ b/lib/pleroma/web/activity_pub/views/user_view.ex
@@ -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
diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex
index ac25aefdd..9e9de33f6 100644
--- a/lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/account_view.ex
@@ -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
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 3a6c1f2cf..f5a582a7e 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -769,11 +769,11 @@ defmodule Pleroma.Web.Router do
get("/embed/:id", EmbedController, :show)
end
- scope "/proxy/", Pleroma.Web.MediaProxy do
- get("/preview/:sig/:url", MediaProxyController, :preview)
- get("/preview/:sig/:url/:filename", MediaProxyController, :preview)
- get("/:sig/:url", MediaProxyController, :remote)
- get("/:sig/:url/:filename", MediaProxyController, :remote)
+ scope "/proxy/", Pleroma.Web do
+ get("/preview/:sig/:url", MediaProxy.MediaProxyController, :preview)
+ get("/preview/:sig/:url/:filename", MediaProxy.MediaProxyController, :preview)
+ get("/:sig/:url", MediaProxy.MediaProxyController, :remote)
+ get("/:sig/:url/:filename", MediaProxy.MediaProxyController, :remote)
end
if Pleroma.Config.get(:env) == :dev do
diff --git a/test/fixtures/config/temp.exported_from_db.secret.exs b/test/fixtures/config/temp.exported_from_db.secret.exs
index 64bee7f32..dda5d0fa6 100644
--- a/test/fixtures/config/temp.exported_from_db.secret.exs
+++ b/test/fixtures/config/temp.exported_from_db.secret.exs
@@ -1,4 +1,4 @@
-use Mix.Config
+import Config
config :pleroma, exported_config_merged: true
diff --git a/test/fixtures/config/temp.secret.exs b/test/fixtures/config/temp.secret.exs
index 4b3af39ec..9c5c88d98 100644
--- a/test/fixtures/config/temp.secret.exs
+++ b/test/fixtures/config/temp.secret.exs
@@ -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]
diff --git a/test/mix/tasks/pleroma/config_test.exs b/test/mix/tasks/pleroma/config_test.exs
index 3ed1e94b8..2b8252db7 100644
--- a/test/mix/tasks/pleroma/config_test.exs
+++ b/test/mix/tasks/pleroma/config_test.exs
@@ -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
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 cea4b3a97..c1e13c7cb 100644
--- a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs
+++ b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs
@@ -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)
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 5373a17c3..3fa17a6ca 100644
--- a/test/pleroma/web/mastodon_api/views/account_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs
@@ -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