Merge branch 'develop' into fix/reports-from-admins

This commit is contained in:
Mark Felder 2021-02-04 12:37:20 -06:00
commit d047372291
11 changed files with 39 additions and 23 deletions

View File

@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Deprecated `Pleroma.Uploaders.S3, :public_endpoint`. Now `Pleroma.Upload, :base_url` is the standard configuration key for all uploaders. - 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 - 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. - Improve OAuth 2.0 provider support. A missing `fqn` field was added to the response, but does not expose the user's email address.
- Provide redirect of external posts from `/notice/:id` to their original URL
- Admins no longer receive notifications for reports if they are the actor making the report. - Admins no longer receive notifications for reports if they are the actor making the report.
<details> <details>

View File

@ -1,4 +1,3 @@
firefox, /emoji/Firefox.gif, Gif,Fun firefox, /emoji/Firefox.gif, Gif,Fun
blank, /emoji/blank.png, Fun blank, /emoji/blank.png, Fun
dinosaur, /emoji/dino walking.gif, Gif dinosaur, /emoji/dino walking.gif, Gif
external_emoji, https://example.com/emoji.png

View File

@ -14,7 +14,7 @@ defmodule Pleroma.Application do
@name Mix.Project.config()[:name] @name Mix.Project.config()[:name]
@version Mix.Project.config()[:version] @version Mix.Project.config()[:version]
@repository Mix.Project.config()[:source_url] @repository Mix.Project.config()[:source_url]
@env Mix.env() @mix_env Mix.env()
def name, do: @name def name, do: @name
def version, do: @version def version, do: @version
@ -92,15 +92,15 @@ defmodule Pleroma.Application do
Pleroma.Web.Plugs.RateLimiter.Supervisor Pleroma.Web.Plugs.RateLimiter.Supervisor
] ++ ] ++
cachex_children() ++ cachex_children() ++
http_children(adapter, @env) ++ http_children(adapter, @mix_env) ++
[ [
Pleroma.Stats, Pleroma.Stats,
Pleroma.JobQueueMonitor, Pleroma.JobQueueMonitor,
{Majic.Pool, [name: Pleroma.MajicPool, pool_size: Config.get([:majic_pool, :size], 2)]}, {Majic.Pool, [name: Pleroma.MajicPool, pool_size: Config.get([:majic_pool, :size], 2)]},
{Oban, Config.get(Oban)} {Oban, Config.get(Oban)}
] ++ ] ++
task_children(@env) ++ task_children(@mix_env) ++
dont_run_in_test(@env) ++ dont_run_in_test(@mix_env) ++
chat_child(chat_enabled?()) ++ chat_child(chat_enabled?()) ++
[ [
Pleroma.Web.Endpoint, Pleroma.Web.Endpoint,
@ -145,7 +145,7 @@ defmodule Pleroma.Application do
raise "Invalid custom modules" raise "Invalid custom modules"
{:ok, modules, _warnings} -> {:ok, modules, _warnings} ->
if @env != :test do if @mix_env != :test do
Enum.each(modules, fn mod -> Enum.each(modules, fn mod ->
Logger.info("Custom module loaded: #{inspect(mod)}") Logger.info("Custom module loaded: #{inspect(mod)}")
end) end)

View File

@ -15,6 +15,8 @@ defmodule Pleroma.Emoji.Loader do
require Logger require Logger
@mix_env Mix.env()
@type pattern :: Regex.t() | module() | String.t() @type pattern :: Regex.t() | module() | String.t()
@type patterns :: pattern() | [pattern()] @type patterns :: pattern() | [pattern()]
@type group_patterns :: keyword(patterns()) @type group_patterns :: keyword(patterns())
@ -77,10 +79,19 @@ defmodule Pleroma.Emoji.Loader do
# it should run even if there are no emoji packs # it should run even if there are no emoji packs
shortcode_globs = Config.get([:emoji, :shortcode_globs], []) shortcode_globs = Config.get([:emoji, :shortcode_globs], [])
# for testing emoji.txt entries we do not want exposed in normal operation
test_emoji =
if @mix_env == :test do
load_from_file("test/config/emoji.txt", emoji_groups)
else
[]
end
emojis_txt = emojis_txt =
(load_from_file("config/emoji.txt", emoji_groups) ++ (load_from_file("config/emoji.txt", emoji_groups) ++
load_from_file("config/custom_emoji.txt", emoji_groups) ++ load_from_file("config/custom_emoji.txt", emoji_groups) ++
load_from_globs(shortcode_globs, emoji_groups)) load_from_globs(shortcode_globs, emoji_groups) ++
test_emoji)
|> Enum.reject(fn value -> value == nil end) |> Enum.reject(fn value -> value == nil end)
Enum.map(emojis ++ emojis_txt, &prepare_emoji/1) Enum.map(emojis ++ emojis_txt, &prepare_emoji/1)

View File

@ -5,6 +5,8 @@
defmodule Pleroma.Uploaders.Uploader do defmodule Pleroma.Uploaders.Uploader do
import Pleroma.Web.Gettext import Pleroma.Web.Gettext
@mix_env Mix.env()
@moduledoc """ @moduledoc """
Defines the contract to put and get an uploaded file to any backend. Defines the contract to put and get an uploaded file to any backend.
""" """
@ -74,7 +76,7 @@ defmodule Pleroma.Uploaders.Uploader do
end end
defp callback_timeout do defp callback_timeout do
case Mix.env() do case @mix_env do
:test -> 1_000 :test -> 1_000
_ -> 30_000 _ -> 30_000
end end

View File

@ -406,7 +406,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
if Config.get(:configurable_from_database) do if Config.get(:configurable_from_database) do
:ok :ok
else else
{:error, "To use this endpoint you need to enable configuration from database."} {:error, "You must enable configurable_from_database in your config file."}
end end
end end

View File

@ -122,7 +122,7 @@ defmodule Pleroma.Web.AdminAPI.ConfigController do
if Config.get(:configurable_from_database) do if Config.get(:configurable_from_database) do
:ok :ok
else else
{:error, "To use this endpoint you need to enable configuration from database."} {:error, "You must enable configurable_from_database in your config file."}
end end
end end

View File

@ -73,12 +73,8 @@ defmodule Pleroma.Web.OStatus.OStatusController do
%User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
cond do cond do
format in ["json", "activity+json"] -> format in ["json", "activity+json"] ->
if activity.local do
%{data: %{"id" => redirect_url}} = Object.normalize(activity, fetch: false) %{data: %{"id" => redirect_url}} = Object.normalize(activity, fetch: false)
redirect(conn, external: redirect_url) redirect(conn, external: redirect_url)
else
{:error, :not_found}
end
activity.data["type"] == "Create" -> activity.data["type"] == "Create" ->
%Object{} = object = Object.normalize(activity, fetch: false) %Object{} = object = Object.normalize(activity, fetch: false)

1
test/config/emoji.txt Normal file
View File

@ -0,0 +1 @@
external_emoji, https://example.com/emoji.png

View File

@ -31,7 +31,7 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
assert json_response_and_validate_schema(conn, 400) == assert json_response_and_validate_schema(conn, 400) ==
%{ %{
"error" => "To use this endpoint you need to enable configuration from database." "error" => "You must enable configurable_from_database in your config file."
} }
end end
@ -170,7 +170,7 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|> post("/api/pleroma/admin/config", %{"configs" => []}) |> post("/api/pleroma/admin/config", %{"configs" => []})
assert json_response_and_validate_schema(conn, 400) == assert json_response_and_validate_schema(conn, 400) ==
%{"error" => "To use this endpoint you need to enable configuration from database."} %{"error" => "You must enable configurable_from_database in your config file."}
end end
describe "POST /api/pleroma/admin/config" do describe "POST /api/pleroma/admin/config" do

View File

@ -144,13 +144,19 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
assert redirect_url == expected_redirect_url assert redirect_url == expected_redirect_url
end end
test "returns a 404 on remote notice when json requested", %{conn: conn} do test "redirects to a proper object URL when json requested and the object is remote", %{
conn: conn
} do
note_activity = insert(:note_activity, local: false) note_activity = insert(:note_activity, local: false)
expected_redirect_url = Object.normalize(note_activity, fetch: false).data["id"]
redirect_url =
conn conn
|> put_req_header("accept", "application/activity+json") |> put_req_header("accept", "application/activity+json")
|> get("/notice/#{note_activity.id}") |> get("/notice/#{note_activity.id}")
|> response(404) |> redirected_to()
assert redirect_url == expected_redirect_url
end end
test "500s when actor not found", %{conn: conn} do test "500s when actor not found", %{conn: conn} do