Allowed sending follow-ups for sent messages

Fixes #3497. Adds Reply button when displaying sent messages (app/views/messages/show.html.erb) and allows replying to messages for which sender is current user (app/controllers/messages_controller.rb). Improved tests for testing added functionality.
This commit is contained in:
Nenad Vujicic 2024-08-22 23:37:39 +02:00
parent 5841813b82
commit 4716800144
3 changed files with 30 additions and 3 deletions

View file

@ -88,6 +88,16 @@ class MessagesController < ApplicationController
@title = @message.title
render :action => "new"
elsif message.sender == current_user
@message = Message.new(
:recipient => message.recipient,
:title => "Re: #{message.title.sub(/^Re:\s*/, '')}",
:body => "On #{message.sent_on} #{message.sender.display_name} wrote:\n\n#{message.body.gsub(/^/, '> ')}"
)
@title = @message.title
render :action => "new"
else
flash[:notice] = t ".wrong_user", :user => current_user.display_name

View file

@ -18,8 +18,8 @@
<div class="richtext text-break"><%= @message.body.to_html %></div>
<div>
<%= link_to t(".reply_button"), message_reply_path(@message), :class => "btn btn-primary" %>
<% if current_user == @message.recipient %>
<%= link_to t(".reply_button"), message_reply_path(@message), :class => "btn btn-primary" %>
<%= link_to t(".unread_button"), message_mark_path(@message, :mark => "unread"), :method => "post", :class => "btn btn-primary" %>
<%= link_to t(".destroy_button"), message_path(@message), :method => "delete", :class => "btn btn-danger" %>
<% else %>