gitlab-org--gitlab-foss/app/controllers/autocomplete_controller.rb

42 lines
1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2015-03-26 22:06:19 -04:00
class AutocompleteController < ApplicationController
2017-08-30 03:48:55 -04:00
skip_before_action :authenticate_user!, only: [:users, :award_emojis]
2015-03-26 22:06:19 -04:00
def users
project = Autocomplete::ProjectFinder
.new(current_user, params)
.execute
group = Autocomplete::GroupFinder
.new(current_user, project, params)
.execute
users = Autocomplete::UsersFinder
.new(params: params, current_user: current_user, project: project, group: group)
.execute
2017-08-30 03:48:55 -04:00
render json: UserSerializer.new.represent(users)
2017-08-30 03:48:55 -04:00
end
def user
user = UserFinder.new(params[:id]).find_by_id!
render json: UserSerializer.new.represent(user)
end
# Displays projects to use for the dropdown when moving a resource from one
# project to another.
def projects
projects = Autocomplete::MoveToProjectFinder
.new(current_user, params)
.execute
render json: MoveToProjectSerializer.new.represent(projects)
end
def award_emojis
render json: AwardedEmojiFinder.new(current_user).execute
end
2015-03-26 22:06:19 -04:00
end