akkoma/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

37 lines
942 B
Elixir
Raw Normal View History

defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
use Pleroma.Web, :controller
2017-09-07 06:58:10 +00:00
alias Pleroma.{Repo}
alias Pleroma.Web.OAuth.App
alias Pleroma.Web
alias Pleroma.Web.MastodonAPI.AccountView
def create_app(conn, params) do
with cs <- App.register_changeset(%App{}, params) |> IO.inspect,
{:ok, app} <- Repo.insert(cs) |> IO.inspect do
res = %{
id: app.id,
client_id: app.client_id,
client_secret: app.client_secret
}
json(conn, res)
end
end
def verify_credentials(%{assigns: %{user: user}} = conn, params) do
2017-09-07 06:58:10 +00:00
account = AccountView.render("account.json", %{user: user})
json(conn, account)
end
def masto_instance(conn, _params) do
response = %{
uri: Web.base_url,
title: Web.base_url,
description: "A Pleroma instance, an alternative fediverse server",
version: "Pleroma Dev"
}
2017-09-07 06:58:10 +00:00
json(conn, response)
end
end