lib/stream/fires.rb in Stream-0.1.6 vs lib/stream/fires.rb in Stream-0.1.7
- old
+ new
@@ -32,14 +32,32 @@
end
create_options[:activity_type] = activity_type.to_s
transaction do
- activity = ActivityItem.create!(create_options)
+ activity = ActivityItem.new(create_options)
if activity_type.to_s.eql?'new_message'
activity.subject.recipient.activity_items << activity
+ elsif activity_type.to_s.eql?'new_photo'
+
+ gallery = activity.subject.gallery
+ photo = activity.subject
+ # Find recent photo activity
+ last_activity = ActivityItem.find(:first, :conditions => ["subject_type = ? AND subject_id = ? AND DATE(updated_at) = current_date",
+ photo.class,photo.id])
+
+ unless last_activity && (activity.subject.gallery.eql?(last_activity.subject.gallery))
+ ([activity.actor] + gallery.allowed_contacts).each do |p|
+ activity.is_hidden = !p.subject.approval_status
+ activity.save
+ p.activity_items << activity
+ end
+ else
+ last_activity.photos << activity.subject
+ end
else
- ([activity.actor] + activity.actor.contacts).each{ |p| p.activity_items << activity }
+ activity.save
+ ([activity.actor] + activity.actor.contacts).each{|p| p.activity_items << activity }
end
end
end
send(:"after_#{opts[:on]}", method_name, :if => opts[:if])