docbrown/app/controllers/concerns/api/follows_controller.rb
Fernando Valverde 8c836430ca
API V1 transition (#17835)
* API Articles v0-v1 restructure

* Remove unused helper

* Bulk move API controllers into concerns + add V1 controllers

* Extract API routes + some fixes

* Fix v1 api_controller authenticate! + add more article_controller specs

* Completed spec/requests/api/v1/articles_spec.rb

* specs up to listings

* All v1 specs except for 9 skips

* mime_types cleanup + authenticate! relocation

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
2022-06-23 14:26:00 -06:00

20 lines
585 B
Ruby

module Api
module FollowsController
extend ActiveSupport::Concern
def create
user_ids = params[:users].map { |h| h["id"] }
user_ids.each do |user_id|
Users::FollowWorker.perform_async(current_user.id, user_id, "User")
end
render json: { outcome: I18n.t("api.v0.follows_controller.followed", count: user_ids.count) }
end
def tags
@follows = @user.follows_by_type("ActsAsTaggableOn::Tag")
.select(%i[id followable_id followable_type points])
.includes(:followable)
.order(points: :desc)
end
end
end