- use Pleroma.Web, :controller
-
- require Logger
-
- alias Pleroma.Plugs.OAuthScopesPlug
- @unauthenticated_access %{fallback: :proceed_unauthenticated, scopes: []}
-
- # Note: :index action handles attempt of unauthenticated access to private instance with redirect
- plug(
- OAuthScopesPlug,
- Map.merge(@unauthenticated_access, %{scopes: ["read"], skip_instance_privacy_check: true})
- when action == :index
- )
-
- plug(
- OAuthScopesPlug,
- %{scopes: ["read"]} when action in [:suggestions, :verify_app_credentials]
- )
-
- plug(OAuthScopesPlug, %{scopes: ["write:accounts"]} when action == :put_settings)
-
- plug(
- OAuthScopesPlug,
- %{@unauthenticated_access | scopes: ["read:statuses"]} when action == :get_poll
- )
-
- plug(OAuthScopesPlug, %{scopes: ["write:statuses"]} when action == :poll_vote)