Enum.member?(blocks, ap_id)
end
+ def local_user_query() do
+ from u in User,
+ where: u.local == true
+ end
+
end
@instance Application.get_env(:pleroma, :instance)
def masto_instance(conn, _params) do
+ user_count = Repo.aggregate(User.local_user_query, :count, :id)
response = %{
uri: Web.base_url,
title: Keyword.get(@instance, :name),
streaming_api: String.replace(Web.base_url, ["http","https"], "wss")
},
stats: %{
- user_count: 1,
status_count: 2,
+ user_count: user_count,
domain_count: 3
},
max_toot_chars: Keyword.get(@instance, :limit)
assert user["header"] != "https://placehold.it/700x335"
end
end
+
+ test "get instance information" do
+ insert(:user, %{local: true})
+ user = insert(:user, %{local: true})
+ insert(:user, %{local: false})
+
+ {:ok, _} = TwitterAPI.create_status(user, %{"status" => "cofe"})
+
+ conn = conn
+ |> get("/api/v1/instance")
+
+ assert result = json_response(conn, 200)
+
+ assert result["stats"]["user_count"] == 2
+ end
end