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.
- 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.
- 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.
<details>

View File

@ -1,4 +1,3 @@
firefox, /emoji/Firefox.gif, Gif,Fun
blank, /emoji/blank.png, Fun
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]
@version Mix.Project.config()[:version]
@repository Mix.Project.config()[:source_url]
@env Mix.env()
@mix_env Mix.env()
def name, do: @name
def version, do: @version
@ -92,15 +92,15 @@ def start(_type, _args) do
Pleroma.Web.Plugs.RateLimiter.Supervisor
] ++
cachex_children() ++
http_children(adapter, @env) ++
http_children(adapter, @mix_env) ++
[
Pleroma.Stats,
Pleroma.JobQueueMonitor,
{Majic.Pool, [name: Pleroma.MajicPool, pool_size: Config.get([:majic_pool, :size], 2)]},
{Oban, Config.get(Oban)}
] ++
task_children(@env) ++
dont_run_in_test(@env) ++
task_children(@mix_env) ++
dont_run_in_test(@mix_env) ++
chat_child(chat_enabled?()) ++
[
Pleroma.Web.Endpoint,
@ -145,7 +145,7 @@ def load_custom_modules do
raise "Invalid custom modules"
{:ok, modules, _warnings} ->
if @env != :test do
if @mix_env != :test do
Enum.each(modules, fn mod ->
Logger.info("Custom module loaded: #{inspect(mod)}")
end)

View File

@ -15,6 +15,8 @@ defmodule Pleroma.Emoji.Loader do
require Logger
@mix_env Mix.env()
@type pattern :: Regex.t() | module() | String.t()
@type patterns :: pattern() | [pattern()]
@type group_patterns :: keyword(patterns())
@ -77,10 +79,19 @@ def load do
# it should run even if there are no emoji packs
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 =
(load_from_file("config/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.map(emojis ++ emojis_txt, &prepare_emoji/1)

View File

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

View File

@ -406,7 +406,7 @@ defp configurable_from_database do
if Config.get(:configurable_from_database) do
:ok
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

View File

@ -122,7 +122,7 @@ defp configurable_from_database do
if Config.get(:configurable_from_database) do
:ok
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

View File

@ -73,12 +73,8 @@ def notice(%{assigns: %{format: format}} = conn, %{"id" => id}) do
%User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
cond do
format in ["json", "activity+json"] ->
if activity.local do
%{data: %{"id" => redirect_url}} = Object.normalize(activity, fetch: false)
redirect(conn, external: redirect_url)
else
{:error, :not_found}
end
activity.data["type"] == "Create" ->
%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 @@ test "when configuration from database is off", %{conn: conn} do
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
@ -170,7 +170,7 @@ test "POST /api/pleroma/admin/config with configdb disabled", %{conn: conn} do
|> post("/api/pleroma/admin/config", %{"configs" => []})
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
describe "POST /api/pleroma/admin/config" do

View File

@ -144,13 +144,19 @@ test "redirects to a proper object URL when json requested and the object is loc
assert redirect_url == expected_redirect_url
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)
expected_redirect_url = Object.normalize(note_activity, fetch: false).data["id"]
redirect_url =
conn
|> put_req_header("accept", "application/activity+json")
|> get("/notice/#{note_activity.id}")
|> response(404)
|> redirected_to()
assert redirect_url == expected_redirect_url
end
test "500s when actor not found", %{conn: conn} do