# Generated by amazon-chime-sdk-rails class MeetingsController < ApplicationController before_action :authenticate_user! before_action :set_room before_action :check_membership include ChimeSdk::Controller::Meetings::Mixin private # Use callbacks to share common setup or constraints between actions. def set_room @room = Room.find(params[:room_id]) end # Use callbacks to share common setup or constraints between actions. def check_membership unless @room.member?(current_user) message = 'Unauthorized: you are not a member of this private room.' respond_to do |format| format.html { redirect_to @room, notice: message } format.json { render json: { room: @room, notice: message }, status: :forbidden } end end end # Override the following functions in your controllers. # Request parameter representing meeting id such as params[:id]. # Configure it depending on your application routes. # @api protected # @return [String, Integer] Meeting id from request parameter # def meeting_id_param # params[:id] # end # Unique meeting request id to identify meeting by Amazon Chime. # Configure it depending on your application resources to identify meeting. # For example, set "PrivateRoom-#{@room.id}" by Room model. # @api protected # @return [String] Unique meeting request id to identify meeting by Amazon Chime def meeting_request_id "PrivateRoom-#{@room.id}" end # Unique attendee request id to identify attendee by Amazon Chime. # Configure it depending on your application resources to identify attendee. # For example, set "User-#{current_user.id}" by User model. # @api protected # @return [String] Unique attendee request id to identify attendee by Amazon Chime def attendee_request_id "User-#{current_user.id}" end # Path for meetings#index action such as meetings_path. # Configure it depending on your application routes. # @api protected # @param [Hash] params Request parameters for path method # @return [String] Path for meetings#index action such as meetings_path def meeting_resources_path(params = {}) room_meetings_path(@room, params) end # Path for meetings#show action such as meeting_path(meeting_id). # Configure it depending on your application routes. # @api protected # @param [String] meeting_id Meeting id # @param [Hash] params Request parameters for path method # @return [String] Path for meetings#show action such as meeting_path(meeting_id) def meeting_resource_path(meeting_id, params = {}) room_meeting_path(@room, meeting_id, params) end # Path for attendees#index action such as attendees_path(meeting_id). # Configure it depending on your application routes. # @api protected # @param [String] meeting_id Meeting id # @param [Hash] params Request parameters for path method # @return [String] Path for attendees#index action such as attendees_path(meeting_id) def attendee_resources_path(meeting_id, params = {}) room_meeting_attendees_path(@room, meeting_id, params) end # Path for attendees#show action such as attendee_path(meeting_id, attendee_id). # Configure it depending on your application routes. # @api protected # @param [String] meeting_id Meeting id # @param [String] attendee_id Attendee id # @param [Hash] params Request parameters for path method # @return [String] Path for attendees#index action such as attendees_path(meeting_id) def attendee_resource_path(meeting_id, attendee_id, params = {}) room_meeting_attendee_path(@room, meeting_id, attendee_id, params) end # Optional meeting tags to pass to Amazon Chime. # This is an optional parameter and configure it depending on your application. # @api protected # @return [Array] Optional tags for meetings def optional_meeting_tags [ { key: "MeetingType", value: "PrivateRoom" }, { key: "RoomId", value: @room.id.to_s } ] end # Optional attendee tags to pass to Amazon Chime. # This is an optional parameter and configure it depending on your application. # @api protected # @return [Array] Optional tags for attendees def optional_attendee_tags [ { key: "AttendeeType", value: "User" }, { key: "UserId", value: current_user.id.to_s } ] end # Appication metadata that meetings API returns as JSON response included in meeting resource. # This is an optional parameter and configure it depending on your application. # @api protected # @param [Hash] meeting Meeting JSON object as hash # @return [Hash] Appication metadata for meetings def application_meeting_metadata(meeting) { "MeetingType": "PrivateRoom", "Room": @room } end # Appication metadata that attendees API returns as JSON response included in attendee resource. # This is an optional parameter and configure it depending on your application. # @api protected # @param [Hash] meeting Attendee JSON object as hash # @return [Hash] Appication metadata for attendees def application_attendee_metadata(attendee) user_id = attendee[:Attendee][:ExternalUserId].split('-')[3] { "AttendeeType": "User", "User": User.find_by_id(user_id) } end # Application attendee name to resolve from attendee object in your view. # This is an optional parameter and configure it depending on your application. # @api protected # @param [Hash] meeting Attendee JSON object as hash # @return [String] Appication attendee name to resolve from attendee object in your view def application_attendee_name(attendee) attendee[:Attendee][:ApplicationMetadata][:User][:name] end end