[#468] Added support for push OAuth scope (Mastodon 2.4+).

This commit is contained in:
Ivan Tashkinov 2019-02-20 17:27:41 +03:00
commit b574d97c2e
3 changed files with 20 additions and 2 deletions

View file

@ -1273,15 +1273,25 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
defp get_or_make_app() do
find_attrs = %{client_name: @local_mastodon_name, redirect_uris: "."}
scopes = ["read", "write", "follow", "push"]
with %App{} = app <- Repo.get_by(App, find_attrs) do
{:ok, app} =
if app.scopes == scopes do
{:ok, app}
else
app
|> Ecto.Changeset.change(%{scopes: scopes})
|> Repo.update()
end
{:ok, app}
else
_e ->
cs =
App.register_changeset(
%App{},
Map.put(find_attrs, :scopes, ["read", "write", "follow"])
Map.put(find_attrs, :scopes, scopes)
)
Repo.insert(cs)