lib/flapjack/api.rb in flapjack-0.6.38 vs lib/flapjack/api.rb in flapjack-0.6.39
- old
+ new
@@ -281,20 +281,19 @@
end
errors.empty? ? ret : [ret, {}, {:errors => [errors]}.to_json]
end
post '/contacts' do
- begin
pass unless 'application/json'.eql?(request.content_type)
content_type :json
errors = []
ret = nil
contacts = params[:contacts]
if contacts && contacts.is_a?(Enumerable) && contacts.any? {|c| !c['id'].nil?}
- Flapjack::Data::Contact.delete_all
+ Flapjack::Data::Contact.delete_all(:redis => @@redis)
contacts.each do |contact|
unless contact['id']
logger.warn "Contact not imported as it has no id: #{contact.inspect}"
next
end
@@ -304,12 +303,9 @@
else
ret = 403
errors << "No valid contacts were submitted"
end
errors.empty? ? ret : [ret, {}, {:errors => [errors]}.to_json]
- rescue Exception => e
- puts e.message
- end
end
not_found do
[404, {}, {:errors => ["Not found"]}.to_json]
end