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:
parent
9e4c450eea
commit
bea76a4801
2 changed files with 14 additions and 10 deletions
|
|
@ -68,7 +68,7 @@ private
|
||||||
|
|
||||||
|
|
||||||
def self.make_notification(recipient, target, actor, notification_type)
|
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,
|
n = notification_type.new(:target => target,
|
||||||
:recipient_id => recipient.id)
|
:recipient_id => recipient.id)
|
||||||
n.actors = n.actors | [actor]
|
n.actors = n.actors | [actor]
|
||||||
|
|
@ -77,7 +77,10 @@ private
|
||||||
n
|
n
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#horrible hack that should not be here!
|
||||||
def self.post_visiblity_is_hidden?(recipient, post)
|
def self.post_visiblity_is_hidden?(recipient, post)
|
||||||
|
return false unless post.is_a?(Post)
|
||||||
|
|
||||||
contact = recipient.contact_for(post.author)
|
contact = recipient.contact_for(post.author)
|
||||||
return false unless contact && recipient && post
|
return false unless contact && recipient && post
|
||||||
pv = PostVisibility.where(:contact_id => contact.id, :post_id => post.id).first
|
pv = PostVisibility.where(:contact_id => contact.id, :post_id => post.id).first
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,18 @@ if !ENV['SINGLE_PROCESS'] && AppConfig[:redis_url]
|
||||||
Resque.redis = Redis.new(:host => AppConfig[:redis_url], :port => 6379)
|
Resque.redis = Redis.new(:host => AppConfig[:redis_url], :port => 6379)
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
if ENV['SINGLE_PROCESS'] || AppConfig.single_process_mode
|
||||||
if ENV['SINGLE_PROCESS']
|
|
||||||
if Rails.env == 'production'
|
if Rails.env == 'production'
|
||||||
puts "WARNING: You are running Diaspora in production without Resque workers turned on. Please don't do this."
|
puts "WARNING: You are running Diaspora in production without Resque workers turned on. Please don't do this."
|
||||||
end
|
end
|
||||||
module Resque
|
module Resque
|
||||||
def enqueue(klass, *args)
|
def enqueue(klass, *args)
|
||||||
|
begin
|
||||||
klass.send(:perform, *args)
|
klass.send(:perform, *args)
|
||||||
end
|
rescue Exception => e
|
||||||
end
|
Rails.logger(e.message)
|
||||||
end
|
|
||||||
rescue
|
|
||||||
nil
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue