diaspora/app/controllers/api/v1/streams_controller.rb
2018-11-01 13:56:18 +01:00

49 lines
1.1 KiB
Ruby

# frozen_string_literal: true
module Api
module V1
class StreamsController < Api::V1::BaseController
before_action do
require_access_token %w[read]
end
def aspects
aspect_ids = (params[:a_ids] || [])
@stream = Stream::Aspect.new(current_user, aspect_ids, max_time: max_time)
stream_responder
end
def activity
stream_responder(Stream::Activity)
end
def multi
stream_responder(Stream::Multi)
end
def commented
stream_responder(Stream::Comments)
end
def liked
stream_responder(Stream::Likes)
end
def mentioned
stream_responder(Stream::Mention)
end
def followed_tags
stream_responder(Stream::FollowedTag)
end
private
def stream_responder(stream_klass=nil)
@stream = stream_klass.present? ? stream_klass.new(current_user, max_time: max_time) : @stream
render json: @stream.stream_posts.map {|p| LastThreeCommentsDecorator.new(PostPresenter.new(p, current_user)) }
end
end
end
end