Skip to content

Commit f0f5555

Browse files
committed
Fix duplicate ThreadFollowers
1 parent c716972 commit f0f5555

2 files changed

Lines changed: 1 addition & 12 deletions

File tree

app/controllers/comments_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ def thread_unrestrict
227227
end
228228
@comment_thread.update(deleted: false, deleted_by: nil)
229229
when 'follow'
230-
tf = ThreadFollower.find_by(comment_thread: @comment_thread, user: current_user)
231-
tf&.destroy
230+
ThreadFollower.where(comment_thread: @comment_thread, user: current_user).destroy_all
232231
else
233232
return not_found
234233
end

app/models/comment_thread.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ class CommentThread < ApplicationRecord
1313
scope :publicly_available, -> { where(deleted: false).where('reply_count > 0') }
1414
scope :archived, -> { where(archived: true) }
1515

16-
after_create :create_follower
17-
1816
def read_only?
1917
locked? || archived? || deleted?
2018
end
@@ -38,12 +36,4 @@ def self.post_followed?(post, user)
3836

3937
private
4038

41-
# Comment author and post author are automatically followed to the thread. Question author is NOT
42-
# automatically followed on new answer comment threads. Comment author follower creation is done
43-
# on the Comment model.
44-
def create_follower
45-
if post.user.preference('auto_follow_comment_threads') == 'true'
46-
ThreadFollower.create comment_thread: self, user: post.user
47-
end
48-
end
4939
end

0 commit comments

Comments
 (0)