- conn
- |> json_reply(200, response)
- { :error, msg } -> forbidden_json_reply(conn, msg)
+ conn
+ |> json_reply(200, json)
+ end
+
+ def follow(%{assigns: %{user: user}} = conn, params) do
+ case TwitterAPI.follow(user, params) do
+ {:ok, user, followed, _activity} ->
+ render(conn, UserView, "show.json", %{user: followed, for: user})
+ {:error, msg} -> forbidden_json_reply(conn, msg)
+ end
+ end
+
+ def unfollow(%{assigns: %{user: user}} = conn, params) do
+ case TwitterAPI.unfollow(user, params) do
+ {:ok, user, unfollowed} ->
+ render(conn, UserView, "show.json", %{user: unfollowed, for: user})
+ {:error, msg} -> forbidden_json_reply(conn, msg)