move the ugly type check into the ugly method, to keep all the ugly in

one place; restore listening to single process mode in resque; move the
exception handling to inside the method, rather than around the
intializer, and log when resque errors happen in development in single
process mode
This commit is contained in:
Maxwell Salzberg 2011-09-09 08:57:56 -07:00
parent 9e4c450eea
commit bea76a4801
2 changed files with 14 additions and 10 deletions

View file

@ -68,7 +68,7 @@ private
def self.make_notification(recipient, target, actor, notification_type)
return nil if target.is_a?(Post) && post_visiblity_is_hidden?(recipient, target)
return nil if post_visiblity_is_hidden?(recipient, target)
n = notification_type.new(:target => target,
:recipient_id => recipient.id)
n.actors = n.actors | [actor]
@ -77,7 +77,10 @@ private
n
end
#horrible hack that should not be here!
def self.post_visiblity_is_hidden?(recipient, post)
return false unless post.is_a?(Post)
contact = recipient.contact_for(post.author)
return false unless contact && recipient && post
pv = PostVisibility.where(:contact_id => contact.id, :post_id => post.id).first

View file

@ -6,17 +6,18 @@ if !ENV['SINGLE_PROCESS'] && AppConfig[:redis_url]
Resque.redis = Redis.new(:host => AppConfig[:redis_url], :port => 6379)
end
begin
if ENV['SINGLE_PROCESS']
if Rails.env == 'production'
puts "WARNING: You are running Diaspora in production without Resque workers turned on. Please don't do this."
end
module Resque
def enqueue(klass, *args)
if ENV['SINGLE_PROCESS'] || AppConfig.single_process_mode
if Rails.env == 'production'
puts "WARNING: You are running Diaspora in production without Resque workers turned on. Please don't do this."
end
module Resque
def enqueue(klass, *args)
begin
klass.send(:perform, *args)
rescue Exception => e
Rails.logger(e.message)
nil
end
end
end
rescue
nil
end