Class: V0::MessagesController
- Inherits:
-
SMController
- Object
- ActionController::API
- ApplicationController
- SMController
- V0::MessagesController
- Includes:
- Filterable
- Defined in:
- app/controllers/v0/messages_controller.rb
Constant Summary
Constants inherited from ApplicationController
ApplicationController::VERSION_STATUS
Constants included from SignIn::Authentication
SignIn::Authentication::BEARER_PATTERN
Constants included from ExceptionHandling
ExceptionHandling::SKIP_SENTRY_EXCEPTION_TYPES
Instance Method Summary collapse
- #categories ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #move ⇒ Object
- #reply ⇒ Object
- #show ⇒ Object
- #thread ⇒ Object
Methods included from Filterable
Methods inherited from SMController
#authorize, #client, #raise_access_denied, #use_cache?
Methods included from MHVControllerConcerns
Methods inherited from ApplicationController
#clear_saved_form, #cors_preflight, #routing_error
Methods included from Traceable
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Methods included from SignIn::Authentication
#authenticate, #authenticate_service_account, #load_user
Methods included from Headers
#block_unknown_hosts, #set_app_info_headers
Methods included from AuthenticationAndSSOConcerns
#authenticate, #clear_session, #extend_session!, #load_user, #log_sso_info, #render_unauthorized, #reset_session, #set_api_cookie!, #set_session_expiration_header, #sso_logging_info, #validate_inbound_login_params, #validate_session
Instance Method Details
#categories ⇒ Object
87 88 89 90 91 92 |
# File 'app/controllers/v0/messages_controller.rb', line 87 def categories resource = client.get_categories render json: resource, serializer: CategorySerializer end |
#create ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/v0/messages_controller.rb', line 33 def create = Message.new(.merge(upload_params)) raise Common::Exceptions::ValidationErrors, unless .valid? [:id] = .delete(:draft_id) if [:draft_id].present? = { message: }.merge(upload_params) client_response = if .uploads.present? client.() else client.() end render json: client_response, serializer: MessageSerializer, include: 'attachments', meta: {} end |
#destroy ⇒ Object
52 53 54 55 |
# File 'app/controllers/v0/messages_controller.rb', line 52 def destroy client.(params[:id]) head :no_content end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/v0/messages_controller.rb', line 7 def index resource = client.(@current_user.uuid, params[:folder_id].to_s, use_cache?) raise Common::Exceptions::RecordNotFound, params[:folder_id] if resource.blank? resource = params[:filter].present? ? resource.find_by(filter_params) : resource resource = resource.sort(params[:sort]) resource = resource.paginate(**pagination_params) render json: resource.data, serializer: CollectionSerializer, each_serializer: MessagesSerializer, meta: resource. end |
#move ⇒ Object
94 95 96 97 98 |
# File 'app/controllers/v0/messages_controller.rb', line 94 def move folder_id = params.require(:folder_id) client.(params[:id], folder_id) head :no_content end |
#reply ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/v0/messages_controller.rb', line 68 def reply = Message.new(.merge(upload_params)).as_reply raise Common::Exceptions::ValidationErrors, unless .valid? [:id] = .delete(:draft_id) if [:draft_id].present? = { message: }.merge(upload_params) client_response = if .uploads.present? client.(params[:id], ) else client.(params[:id], ) end render json: client_response, serializer: MessageSerializer, include: 'attachments', status: :created end |
#show ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/v0/messages_controller.rb', line 21 def show = params[:id].try(:to_i) response = client.() raise Common::Exceptions::RecordNotFound, if response.blank? render json: response, serializer: MessageSerializer, include: 'attachments', meta: response. end |
#thread ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/v0/messages_controller.rb', line 57 def thread = params[:id].try(:to_i) resource = client.() raise Common::Exceptions::RecordNotFound, if resource.blank? render json: resource.data, serializer: CollectionSerializer, each_serializer: MessagesSerializer, meta: resource. end |