Merge remote-tracking branch 'pleroma/develop' into feature/disable-account
[akkoma] / lib / pleroma / web / oauth.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.OAuth do
6 def parse_scopes(scopes, _default) when is_list(scopes) do
7 Enum.filter(scopes, &(&1 not in [nil, ""]))
8 end
9
10 def parse_scopes(scopes, default) when is_binary(scopes) do
11 scopes
12 |> String.trim()
13 |> String.split(~r/[\s,]+/)
14 |> parse_scopes(default)
15 end
16
17 def parse_scopes(_, default) do
18 default
19 end
20 end