Slight cleanup.
This commit is contained in:
parent
2a298d70f9
commit
2652d9e4ed
8 changed files with 55 additions and 41 deletions
|
|
@ -1,6 +1,9 @@
|
|||
defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
||||
use Pleroma.Web, :controller
|
||||
alias Pleroma.{Repo, App}
|
||||
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,
|
||||
|
|
@ -16,17 +19,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
end
|
||||
|
||||
def verify_credentials(%{assigns: %{user: user}} = conn, params) do
|
||||
account = %{
|
||||
id: user.id,
|
||||
username: user.nickname,
|
||||
acct: user.nickname,
|
||||
display_name: user.name,
|
||||
locked: false,
|
||||
created_at: user.inserted_at,
|
||||
note: user.bio,
|
||||
url: ""
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
json(conn, response)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
27
lib/pleroma/web/mastodon_api/views/user_view.ex
Normal file
27
lib/pleroma/web/mastodon_api/views/user_view.ex
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
defmodule Pleroma.Web.MastodonAPI.AccountView do
|
||||
use Pleroma.Web, :view
|
||||
alias Pleroma.User
|
||||
|
||||
def render("account.json", %{user: user}) do
|
||||
image = User.avatar_url(user)
|
||||
user_info = User.user_info(user)
|
||||
|
||||
%{
|
||||
id: user.id,
|
||||
username: user.nickname,
|
||||
acct: user.nickname,
|
||||
display_name: user.name,
|
||||
locked: false,
|
||||
created_at: user.inserted_at,
|
||||
followers_count: user_info.follower_count,
|
||||
following_count: user_info.following_count,
|
||||
statuses_count: user_info.note_count,
|
||||
note: user.bio,
|
||||
url: user.ap_id,
|
||||
avatar: image,
|
||||
avatar_static: image,
|
||||
header: "",
|
||||
header_static: ""
|
||||
}
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue