summaryrefslogtreecommitdiff
path: root/app/controllers/pms_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/pms_controller.rb')
-rw-r--r--app/controllers/pms_controller.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/controllers/pms_controller.rb b/app/controllers/pms_controller.rb
index 11f51c8..3368663 100644
--- a/app/controllers/pms_controller.rb
+++ b/app/controllers/pms_controller.rb
@@ -1,6 +1,4 @@
class PmsController < ApplicationController
- before_action :set_pm, only: [:show, :edit, :update, :destroy]
-
# GET /pms
# GET /pms.json
def index
@@ -25,6 +23,12 @@ class PmsController < ApplicationController
# POST /pms.json
def create
@pm = Pm.new(pm_params)
+ @pm.author = current_user
+ #require 'pp'
+ #pp @pm.message
+ @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 +41,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 +57,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