From: Egor Kislitsyn Date: Thu, 6 Dec 2018 13:15:16 +0000 (+0700) Subject: Merge branch 'develop' into feature/compat/push-subscriptions X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=4944498133d4a945650201226808b1f09d355014;p=akkoma Merge branch 'develop' into feature/compat/push-subscriptions # Conflicts: # lib/pleroma/application.ex # lib/pleroma/plugs/oauth_plug.ex --- 4944498133d4a945650201226808b1f09d355014 diff --cc lib/pleroma/application.ex index d0f23527f,cc68d9669..0b0ec0197 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@@ -63,21 -64,17 +64,18 @@@ defmodule Pleroma.Application d ], id: :cachex_idem ), - worker(Pleroma.Web.Federator, []), worker(Pleroma.Web.Federator.RetryQueue, []), - worker(Pleroma.Gopher.Server, []), + worker(Pleroma.Web.Federator, []), - worker(Pleroma.Stats, []) + worker(Pleroma.Stats, []), + worker(Pleroma.Web.Push, []) ] ++ - if @env == :test, - do: [], - else: - [worker(Pleroma.Web.Streamer, [])] ++ - if( - !chat_enabled(), - do: [], - else: [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])] - ) + streamer_child() ++ + chat_child() ++ + [ + # Start the endpoint when the application starts + supervisor(Pleroma.Web.Endpoint, []), + worker(Pleroma.Gopher.Server, []) + ] # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html # for other strategies and supported options diff --cc lib/pleroma/plugs/oauth_plug.ex index 651485e09,75f9209c2..8b99a74d1 --- a/lib/pleroma/plugs/oauth_plug.ex +++ b/lib/pleroma/plugs/oauth_plug.ex @@@ -11,19 -15,9 +15,11 @@@ defmodule Pleroma.Plugs.OAuthPlug d def call(%{assigns: %{user: %User{}}} = conn, _), do: conn def call(conn, _) do - token = - case get_req_header(conn, "authorization") do - ["Bearer " <> header] -> header - _ -> get_session(conn, :oauth_token) - end - - with token when not is_nil(token) <- token, - %Token{user_id: user_id} = token <- Repo.get_by(Token, token: token), - %User{} = user <- Repo.get(User, user_id), - false <- !!user.info["deactivated"] do + with {:ok, token} <- fetch_token(conn), + {:ok, user} <- fetch_user(token) do - assign(conn, :user, user) + conn + |> assign(:token, token) + |> assign(:user, user) else _ -> conn end