diff --git a/app/controllers/v1/feed_controller.rb b/app/controllers/v1/feed_controller.rb index cd1aeb110f26b4f7787d676647ac57d7cacb8f28..365474469518ab4070ef94c0d41a7d5a35462c7a 100644 --- a/app/controllers/v1/feed_controller.rb +++ b/app/controllers/v1/feed_controller.rb @@ -1,5 +1,6 @@ class V1::FeedController < ApplicationController include ::Paginator + include ActivitiesFilterService before_action :authenticate_user! # GET v1/feed @@ -13,11 +14,23 @@ class V1::FeedController < ApplicationController private def activities_followed - activities = [] + query = "" + values = [""] + current_user.watching.each do |watching| - activities.push(*watching.activities_filtered.to_a) + if !watching.respond_to?(:state) || watching.state == "published" + query += " (trackable_type = ? and trackable_id = ?) or (owner_type = ? and owner_id = ?) or (recipient_type = ? and recipient_id = ?) or" + values << watching.class.to_s + values << watching.id + values << watching.class.to_s + values << watching.id + values << watching.class.to_s + values << watching.id + end end - activities + + values[0] = query[0..-3] + PublicActivity::Activity.where(key: activities_filter).where(values).order(created_at: :desc) end end