19ab0fe108
* Chore: Enable Users to create multiple accounts Addresses: #402 - migrations to split roles and other attributes from users table - make changes in code to accommodate this change Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
35 lines
805 B
Ruby
35 lines
805 B
Ruby
class Api::V1::Accounts::ConversationsController < Api::BaseController
|
|
before_action :conversation, except: [:index]
|
|
|
|
def index
|
|
result = conversation_finder.perform
|
|
@conversations = result[:conversations]
|
|
@conversations_count = result[:count]
|
|
end
|
|
|
|
def show; end
|
|
|
|
def toggle_status
|
|
@status = @conversation.toggle_status
|
|
end
|
|
|
|
def update_last_seen
|
|
@conversation.agent_last_seen_at = parsed_last_seen_at
|
|
@conversation.save!
|
|
head :ok
|
|
end
|
|
|
|
private
|
|
|
|
def parsed_last_seen_at
|
|
DateTime.strptime(params[:agent_last_seen_at].to_s, '%s')
|
|
end
|
|
|
|
def conversation
|
|
@conversation ||= current_account.conversations.find_by(display_id: params[:id])
|
|
end
|
|
|
|
def conversation_finder
|
|
@conversation_finder ||= ConversationFinder.new(current_user, params)
|
|
end
|
|
end
|