lib/stream/fires.rb in Stream-0.1.20 vs lib/stream/fires.rb in Stream-0.1.21
- old
+ new
@@ -35,9 +35,26 @@
activity = ActivityItem.create(create_options)
if activity_type.to_s.eql?'new_message'
activity.subject.recipient.activity_items << activity
+ elsif activity_type.to_s.eql?'new_photo'
+ last_activity = ActivityItem.find(:first,
+ :conditions => ["subject_type = ? AND photos.gallery_id = ? AND DATE(activity_items.updated_at) = current_date",
+ activity.subject.class,activity.subject.gallery_id],:include=>[:photos])
+
+ if last_activity && (activity.subject.gallery.eql?(last_activity.subject.gallery))
+ last_activity.photos << activity.subject
+ last_activity.update_attribute(:updated_at,Time.now)
+ activity.destroy
+ else
+ ([activity.actor] + activity.subject.gallery.allowed_contacts).each do |p|
+ activity.is_hidden = activity.subject.approval_status ? false : true
+ activity.photos << activity.subject
+ activity.save
+ p.activity_items << activity
+ end
+ end
else
([activity.actor] + activity.actor.contacts).each{|p| p.activity_items << activity }
end
end