diff options
Diffstat (limited to 'app/controllers/pms_controller.rb')
-rw-r--r-- | app/controllers/pms_controller.rb | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/app/controllers/pms_controller.rb b/app/controllers/pms_controller.rb index 11f51c8..faaa38f 100644 --- a/app/controllers/pms_controller.rb +++ b/app/controllers/pms_controller.rb @@ -1,6 +1,26 @@ -class PmsController < ApplicationController - before_action :set_pm, only: [:show, :edit, :update, :destroy] +# Copyright (C) 2014 Andrew Murrell +# Copyright (C) 2014 Davis Webb +# Copyright (C) 2014 Guntas Grewal +# Copyright (C) 2014 Luke Shumaker +# Copyright (C) 2014 Nathaniel Foy +# Copyright (C) 2014 Tomer Kimia +# +# This file is part of Leaguer. +# +# Leaguer is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Leaguer is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the Affero GNU General Public License +# along with Leaguer. If not, see <http://www.gnu.org/licenses/>. +class PmsController < ApplicationController # GET /pms # GET /pms.json def index @@ -25,6 +45,10 @@ class PmsController < ApplicationController # POST /pms.json def create @pm = Pm.new(pm_params) + @pm.author = current_user + @pm.recipient = User.find_by_user_name(pm_params['recipient_id']) + + @pm.conversation = @pm.author.send_message(@pm.recipient, @pm.message, @pm.subject).conversation respond_to do |format| if @pm.save @@ -37,6 +61,10 @@ class PmsController < ApplicationController end end + #def reply + # current_user.reply_to_conversation(conversation, message) + #end + # PATCH/PUT /pms/1 # PATCH/PUT /pms/1.json def update @@ -49,6 +77,7 @@ class PmsController < ApplicationController format.json { render json: @pm.errors, status: :unprocessable_entity } end end + current_user.reply_to_conversation(@pm.conversation, @pm.message) end # DELETE /pms/1 |