defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
use Pleroma.Web, :controller
- alias Pleroma.{Repo, Activity, User, Notification}
+ alias Pleroma.{Repo, Activity, User, Notification, Stats}
alias Pleroma.Web
alias Pleroma.Web.MastodonAPI.{StatusView, AccountView, MastodonView}
alias Pleroma.Web.ActivityPub.ActivityPub
urls: %{
streaming_api: String.replace(Web.base_url, ["http","https"], "wss")
},
- stats: %{
- user_count: 1,
- status_count: 2,
- domain_count: 3
- },
+ stats: Stats.get_stats,
+ thumbnail: Web.base_url <> "/instance/thumbnail.jpeg",
max_toot_chars: Keyword.get(@instance, :limit)
}
json(conn, response)
end
+ def peers(conn, _params) do
+ json(conn, Stats.get_peers)
+ end
+
defp mastodonized_emoji do
Pleroma.Formatter.get_custom_emoji()
|> Enum.map(fn {shortcode, relative_url} ->
def public_timeline(%{assigns: %{user: user}} = conn, params) do
params = params
|> Map.put("type", ["Create", "Announce"])
- |> Map.put("local_only", !!params["local"])
+ |> Map.put("local_only", params["local"] in [true, "True", "true", "1"])
|> Map.put("blocking_user", user)
activities = ActivityPub.fetch_public_activities(params)
def post_status(%{assigns: %{user: user}} = conn, %{"status" => _} = params) do
params = params
|> Map.put("in_reply_to_status_id", params["in_reply_to_id"])
+ |> Map.put("no_attachment_links", true)
{:ok, activity} = CommonAPI.post(user, params)
render conn, StatusView, "status.json", %{activity: activity, for: user, as: :activity}
def login(conn, _) do
conn
- |> render(MastodonView, "login.html")
+ |> render(MastodonView, "login.html", %{error: false})
end
defp get_or_make_app() do
conn
|> put_session(:oauth_token, token.token)
|> redirect(to: "/web/getting-started")
+ else
+ _e ->
+ conn
+ |> render(MastodonView, "login.html", %{error: "Wrong username or password"})
end
end