- def conditions_user(user)
- unless user.nil?
- # user input checking, we don't have any UIDs < 1
- raise OSM::APIBadUserInput.new("invalid user ID") if user.to_i < 1
+ def conditions_user(user, name)
+ unless user.nil? and name.nil?
+ # shouldn't provide both name and UID
+ raise OSM::APIBadUserInput.new("provide either the user ID or display name, but not both") if user and name
+
+ # use either the name or the UID to find the user which we're selecting on.
+ u = if name.nil?
+ # user input checking, we don't have any UIDs < 1
+ raise OSM::APIBadUserInput.new("invalid user ID") if user.to_i < 1
+ u = User.find(user.to_i)
+ else
+ u = User.find_by_display_name(name)
+ end
+
+ # make sure we found a user
+ raise OSM::APINotFoundError.new if u.nil?