From: Tom Hughes Date: Tue, 15 Jan 2008 19:05:17 +0000 (+0000) Subject: Make the message reply link prefill the title with "Re: original title". X-Git-Tag: live~7950 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/b4165975078d6a520f80296fafea19b4c6b83bf5 Make the message reply link prefill the title with "Re: original title". Closes #634. --- diff --git a/app/controllers/message_controller.rb b/app/controllers/message_controller.rb index b54fdf9d1..9dc1d6922 100644 --- a/app/controllers/message_controller.rb +++ b/app/controllers/message_controller.rb @@ -20,6 +20,14 @@ class MessageController < ApplicationController end end + def reply + message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ]) + title = message.title.sub(/^Re:\s*/, "Re: ") + redirect_to :action => 'new', :user_id => message.from_user_id, :title => title + rescue ActiveRecord::RecordNotFound + render :nothing => true, :status => :not_found + end + def read @title = 'read message' @message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ]) diff --git a/app/models/notifier.rb b/app/models/notifier.rb index bc4db6477..f934a8bde 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -59,8 +59,8 @@ class Notifier < ActionMailer::Base :controller => "message", :action => "read", :message_id => message.id), :replyurl => url_for(:host => SERVER_URL, - :controller => "message", :action => "new", - :user_id => message.from_user_id) + :controller => "message", :action => "reply", + :message_id => message.id) end def friend_notification(friend) diff --git a/app/views/message/_message_summary.rhtml b/app/views/message/_message_summary.rhtml index d1604e9b5..381a6cce1 100644 --- a/app/views/message/_message_summary.rhtml +++ b/app/views/message/_message_summary.rhtml @@ -9,5 +9,5 @@ <% else %> <%= button_to 'Mark as read', :controller => 'message', :action => 'mark', :message_id => message_summary.id, :mark => 'read' %> <% end %> - <%= button_to 'Reply', :controller => 'message', :action => 'new', :user_id => message_summary.from_user_id %> + <%= button_to 'Reply', :controller => 'message', :action => 'reply', :message_id => message_summary.id %> diff --git a/app/views/message/new.rhtml b/app/views/message/new.rhtml index 27c501322..84b3bfdc8 100644 --- a/app/views/message/new.rhtml +++ b/app/views/message/new.rhtml @@ -1,4 +1,5 @@ -<% display_name = (User.find_by_id(params[:user_id])).display_name %> +<% display_name = User.find_by_id(params[:user_id]).display_name %> +<% title = params[:message] ? params[:message][:title] : params[:title] %>

Send a new message to <%= display_name %>

@@ -13,7 +14,7 @@ - + diff --git a/app/views/message/read.rhtml b/app/views/message/read.rhtml index b3dcd1f23..d0517d0bf 100644 --- a/app/views/message/read.rhtml +++ b/app/views/message/read.rhtml @@ -25,7 +25,7 @@
Subject<%= f.text_field :title, :size => 60 %><%= text_field_tag 'message[title]', title, :size => 60 %>
Body
- + diff --git a/config/routes.rb b/config/routes.rb index dce4042de..3cfc51977 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -122,7 +122,8 @@ ActionController::Routing::Routes.draw do |map| map.connect '/message/new/:user_id', :controller => 'message', :action => 'new' map.connect '/message/read/:message_id', :controller => 'message', :action => 'read' map.connect '/message/mark/:message_id', :controller => 'message', :action => 'mark' - + map.connect '/message/reply/:message_id', :controller => 'message', :action => 'reply' + # fall through map.connect ':controller/:id/:action' map.connect ':controller/:action'
<%= button_to 'Reply', :controller => 'message', :action => 'new', :user_id => @message.from_user_id %><%= button_to 'Reply', :controller => 'message', :action => 'reply', :message_id => @message.id %> <%= button_to 'Mark as unread', :controller => 'message', :action => 'mark', :message_id => @message.id, :mark => 'unread' %> <%= link_to 'Back to inbox', :controller => 'message', :action => 'inbox', :display_name => @user.display_name %>