Sha256: 97cf9a3f24e99c949befa33b47ead3721a7d8dc4df7ce2d67f07a9f22fc215db
Contents?: true
Size: 785 Bytes
Versions: 2
Compression:
Stored size: 785 Bytes
Contents
require 'grape' class ConversationApi < Grape::API format :json prefix :api helpers do def take_current_user(params) params[:class].constantize.find(params[:user]) end def class_name(klass) klass.class.name end def conversation Denshobato::Conversation end end resource :conversations do desc 'Get info from conversation' get :conversation_info do # Get current user id, and Conversation id current_user = take_current_user(params) room = conversation.find(params[:id]) { author: room.sender.email, conversation_id: room.id, sender_id: current_user.id, sender_class: class_name(current_user), recipient: room.recipient.full_name, recipient_class: class_name(room.recipient) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
denshobato_chat_panel-0.0.2 | lib/api/conversation_api.rb |
denshobato_chat_panel-0.0.1 | lib/api/conversation_api.rb |