def user_timeline(%{assigns: %{user: user}} = conn, params) do
case TwitterAPI.get_user(user, params) do
{:ok, target_user} ->
- params = Map.merge(params, %{"actor_id" => target_user.ap_id})
+ params = Map.merge(params, %{"actor_id" => target_user.ap_id, "whole_db" => true})
statuses = TwitterAPI.fetch_user_statuses(user, params)
conn
|> json_reply(200, statuses |> Poison.encode!)
end
end
+ def block(%{assigns: %{user: user}} = conn, params) do
+ case TwitterAPI.block(user, params) do
+ {:ok, user, blocked} ->
+ render conn, UserView, "show.json", %{user: blocked, for: user}
+ {:error, msg} -> forbidden_json_reply(conn, msg)
+ end
+ end
+
+ def unblock(%{assigns: %{user: user}} = conn, params) do
+ case TwitterAPI.unblock(user, params) do
+ {:ok, user, blocked} ->
+ render conn, UserView, "show.json", %{user: blocked, for: user}
+ {:error, msg} -> forbidden_json_reply(conn, msg)
+ end
+ end
+
def delete_post(%{assigns: %{user: user}} = conn, %{"id" => id}) do
with {:ok, delete} <- CommonAPI.delete(id, user) do
json = ActivityRepresenter.to_json(delete, %{user: user, for: user})