@@ -26,6 +26,7 @@ class CommentsController < ApplicationController
2626 before_action :check_unrestrict_access , only : [ :thread_unrestrict ]
2727 before_action :check_if_target_post_locked , only : [ :create , :post_follow ]
2828 before_action :check_if_parent_post_locked , only : [ :update , :destroy ]
29+ before_action :verify_moderator , only : [ :thread_followers ]
2930
3031 def create_thread
3132 title = params [ :title ]
@@ -203,8 +204,6 @@ def thread_content
203204 end
204205
205206 def thread_followers
206- return not_found! unless current_user &.at_least_moderator?
207-
208207 @followers = ThreadFollower . where ( comment_thread : @comment_thread ) . joins ( :user , user : :community_user )
209208 . includes ( :user , user : [ :community_user , :avatar_attachment ] )
210209 respond_to do |format |
@@ -222,19 +221,24 @@ def thread_rename
222221
223222 orig_title = @comment_thread . title
224223 title = helpers . strip_markdown ( params [ :title ] , strip_leading_quote : true )
224+
225+ if orig_title == title
226+ flash [ :danger ] = I18n . t ( 'comments.errors.no_rename_thread_to_current_title' )
227+ redirect_to comment_thread_path ( @comment_thread . id )
228+ return
229+ end
230+
225231 status = @comment_thread . update ( title : title )
226232
227233 if status
228234 # Comment is owned by System so regular users can't delete it. Without
229235 # this record, the title would be attributed to the thread creator,
230236 # which can be abused.
231- log_msg =
232- Comment . new ( post : @post ,
233- content :
234- "Thread renamed from \\ \" #{ orig_title } \\ \" to \\ \" #{ title } \\ \" by @##{ current_user . id } " ,
235- user : User . find ( -1 ) ,
236- comment_thread : @comment_thread ,
237- has_reference : false )
237+ log_msg = Comment . new ( post : @post ,
238+ content : "Thread renamed from \" #{ orig_title } \" to \" #{ title } \" by @##{ current_user . id } " ,
239+ user : helpers . system_user ,
240+ comment_thread : @comment_thread ,
241+ has_reference : false )
238242 comment_status = log_msg . save
239243 end
240244
0 commit comments