Class: MessagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/messages_controller.rb

Overview

Copyright © 2010-2011, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Instance Method Summary collapse

Instance Method Details

#createObject


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/messages_controller.rb', line 13

def create
  conversation = Conversation.find(params[:conversation_id])

  opts = params.require(:message).permit(:text)
  message = current_user.build_message(conversation, opts)

  if message.save
    logger.info "event=create type=message user=#{current_user.diaspora_handle} status=success " \
                "message=#{message.id} chars=#{params[:message][:text].length}"
    Diaspora::Federation::Dispatcher.defer_dispatch(current_user, message)
  else
    flash[:error] = I18n.t('conversations.new_conversation.fail')
  end
  redirect_to conversations_path(:conversation_id => conversation.id)
end