end
def follow(%{assigns: %{user: user}} = conn, %{ "user_id" => followed_id }) do
- { :ok, user, follower, _activity } = TwitterAPI.follow(user, followed_id)
-
- response = follower |> UserRepresenter.to_json(%{for: user})
-
- conn
- |> json_reply(200, response)
+ case TwitterAPI.follow(user, followed_id) do
- { :ok, _user, followed, _activity } ->
++ { :ok, user, followed, _activity } ->
+ response = followed |> UserRepresenter.to_json(%{for: user})
- conn |> json_reply(200, response)
++ conn
++ |> json_reply(200, response)
+ { :error, msg } -> forbidden_json_reply(conn, msg)
+ end
-
end
def unfollow(%{assigns: %{user: user}} = conn, %{ "user_id" => followed_id }) do