Merge branch 'chore/elixir-1.11' into 'develop'
Elixir 1.11 compatibility / Phoenix 1.5+ See merge request pleroma/pleroma!3059
This commit is contained in:
commit
d6907e6e0c
33 changed files with 89 additions and 83 deletions
|
|
@ -31,7 +31,12 @@ defmodule Phoenix.Transports.WebSocket.Raw do
|
|||
|
||||
case conn do
|
||||
%{halted: false} = conn ->
|
||||
case Transport.connect(endpoint, handler, transport, __MODULE__, nil, conn.params) do
|
||||
case handler.connect(%{
|
||||
endpoint: endpoint,
|
||||
transport: transport,
|
||||
options: [serializer: nil],
|
||||
params: conn.params
|
||||
}) do
|
||||
{:ok, socket} ->
|
||||
{:ok, conn, {__MODULE__, {socket, opts}}}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ defmodule Pleroma.Application do
|
|||
] ++
|
||||
task_children(@env) ++
|
||||
dont_run_in_test(@env) ++
|
||||
chat_child(@env, chat_enabled?()) ++
|
||||
chat_child(chat_enabled?()) ++
|
||||
[
|
||||
Pleroma.Web.Endpoint,
|
||||
Pleroma.Gopher.Server
|
||||
|
|
@ -151,7 +151,10 @@ defmodule Pleroma.Application do
|
|||
|
||||
Pleroma.Web.Endpoint.MetricsExporter.setup()
|
||||
Pleroma.Web.Endpoint.PipelineInstrumenter.setup()
|
||||
Pleroma.Web.Endpoint.Instrumenter.setup()
|
||||
|
||||
# Note: disabled until prometheus-phx is integrated into prometheus-phoenix:
|
||||
# Pleroma.Web.Endpoint.Instrumenter.setup()
|
||||
PrometheusPhx.setup()
|
||||
end
|
||||
|
||||
defp cachex_children do
|
||||
|
|
@ -202,11 +205,14 @@ defmodule Pleroma.Application do
|
|||
]
|
||||
end
|
||||
|
||||
defp chat_child(_env, true) do
|
||||
[Pleroma.Web.ChatChannel.ChatChannelState]
|
||||
defp chat_child(true) do
|
||||
[
|
||||
Pleroma.Web.ChatChannel.ChatChannelState,
|
||||
{Phoenix.PubSub, [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2]}
|
||||
]
|
||||
end
|
||||
|
||||
defp chat_child(_, _), do: []
|
||||
defp chat_child(_), do: []
|
||||
|
||||
defp task_children(:test) do
|
||||
[
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ defmodule Pleroma.Web do
|
|||
def channel do
|
||||
quote do
|
||||
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||
use Phoenix.Channel
|
||||
import Phoenix.Channel
|
||||
import Pleroma.Web.Gettext
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
|||
object =
|
||||
object
|
||||
|> Map.merge(Map.take(params, ["to", "cc"]))
|
||||
|> Map.put("attributedTo", user.ap_id())
|
||||
|> Map.put("attributedTo", user.ap_id)
|
||||
|> Transmogrifier.fix_object()
|
||||
|
||||
ActivityPub.create(%{
|
||||
|
|
@ -458,7 +458,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
|||
%{assigns: %{user: %User{nickname: nickname} = user}} = conn,
|
||||
%{"nickname" => nickname} = params
|
||||
) do
|
||||
actor = user.ap_id()
|
||||
actor = user.ap_id
|
||||
|
||||
params =
|
||||
params
|
||||
|
|
|
|||
|
|
@ -242,9 +242,7 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
|||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Publishes an activity to all relevant peers.
|
||||
"""
|
||||
# Publishes an activity to all relevant peers.
|
||||
def publish(%User{} = actor, %Activity{} = activity) do
|
||||
public = is_public?(activity)
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
|
|||
end
|
||||
|
||||
def render("index_notes.json", %{notes: notes}) when is_list(notes) do
|
||||
Enum.map(notes, &render(__MODULE__, "show_note.json", &1))
|
||||
Enum.map(notes, &render(__MODULE__, "show_note.json", Map.from_struct(&1)))
|
||||
end
|
||||
|
||||
def render("index_notes.json", _), do: []
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||
def format_input(text, format, options \\ [])
|
||||
|
||||
@doc """
|
||||
Formatting text to plain text.
|
||||
Formatting text to plain text, BBCode, HTML, or Markdown
|
||||
"""
|
||||
def format_input(text, "text/plain", options) do
|
||||
text
|
||||
|
|
@ -285,9 +285,6 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||
end).()
|
||||
end
|
||||
|
||||
@doc """
|
||||
Formatting text as BBCode.
|
||||
"""
|
||||
def format_input(text, "text/bbcode", options) do
|
||||
text
|
||||
|> String.replace(~r/\r/, "")
|
||||
|
|
@ -297,18 +294,12 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
|||
|> Formatter.linkify(options)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Formatting text to html.
|
||||
"""
|
||||
def format_input(text, "text/html", options) do
|
||||
text
|
||||
|> Formatter.html_escape("text/html")
|
||||
|> Formatter.linkify(options)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Formatting text to markdown.
|
||||
"""
|
||||
def format_input(text, "text/markdown", options) do
|
||||
text
|
||||
|> Formatter.mentions_escape(options)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ defmodule Pleroma.Web.Endpoint do
|
|||
|
||||
socket("/socket", Pleroma.Web.UserSocket)
|
||||
|
||||
plug(Plug.Telemetry, event_prefix: [:phoenix, :endpoint])
|
||||
|
||||
plug(Pleroma.Web.Plugs.SetLocalePlug)
|
||||
plug(CORSPlug)
|
||||
plug(Pleroma.Web.Plugs.HTTPSecurityPlug)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ defmodule Pleroma.Web.MastodonAPI.AuthController do
|
|||
redirect(conn, to: local_mastodon_root_path(conn))
|
||||
end
|
||||
|
||||
@doc "Local Mastodon FE login init action"
|
||||
# Local Mastodon FE login init action
|
||||
def login(conn, %{"code" => auth_token}) do
|
||||
with {:ok, app} <- get_or_make_app(),
|
||||
{:ok, auth} <- Authorization.get_by_token(app, auth_token),
|
||||
|
|
@ -35,7 +35,7 @@ defmodule Pleroma.Web.MastodonAPI.AuthController do
|
|||
end
|
||||
end
|
||||
|
||||
@doc "Local Mastodon FE callback action"
|
||||
# Local Mastodon FE callback action
|
||||
def login(conn, _) do
|
||||
with {:ok, app} <- get_or_make_app() do
|
||||
path =
|
||||
|
|
|
|||
|
|
@ -127,9 +127,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
|
||||
@doc """
|
||||
POST /api/v1/statuses
|
||||
|
||||
Creates a scheduled status when `scheduled_at` param is present and it's far enough
|
||||
"""
|
||||
# Creates a scheduled status when `scheduled_at` param is present and it's far enough
|
||||
def create(
|
||||
%{
|
||||
assigns: %{user: user},
|
||||
|
|
@ -160,11 +159,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
POST /api/v1/statuses
|
||||
|
||||
Creates a regular status
|
||||
"""
|
||||
# Creates a regular status
|
||||
def create(%{assigns: %{user: user}, body_params: %{status: _} = params} = conn, _) do
|
||||
params = Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id])
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ defmodule Pleroma.Web.MediaProxy.Invalidation.Http do
|
|||
{:ok, %{status: status} = env} when 400 <= status and status < 500 ->
|
||||
{:error, env}
|
||||
|
||||
{:error, error} = error ->
|
||||
{:error, _} = error ->
|
||||
error
|
||||
|
||||
_ ->
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@
|
|||
<body>
|
||||
<div class="container">
|
||||
<h1><%= Pleroma.Config.get([:instance, :name]) %></h1>
|
||||
<%= render @view_module, @view_template, assigns %>
|
||||
<%= @inner_content %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= render @view_module, @view_template, assigns %>
|
||||
<%= @inner_content %>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ video, audio {
|
|||
}
|
||||
</style>
|
||||
|
||||
<%= render @view_module, @view_template, assigns %>
|
||||
<%= @inner_content %>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<%= render @view_module, @view_template, assigns %>
|
||||
<%= @inner_content %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue