Skip to content

Commit 7d89490

Browse files
authored
Merge pull request #1037 from MoshiKoi/issue-1025
Remove special case notifying author of threads. This merge takes the changes so far from MoshiKoi's fork to a new branch `MoshiKoi/1025/remove-special-case-notifying-author-of-threads` in the `qpixel` repo. This will allow any qpixel developer access to continue work on this new branch and make a new pull request into `develop`.
2 parents cb332b0 + 71c59f2 commit 7d89490

3 files changed

Lines changed: 3 additions & 16 deletions

File tree

app/controllers/comments_controller.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,9 @@ def create_thread
4141

4242
if success
4343
notification = "New comment thread on #{@comment.root.title}: #{@comment_thread.title}"
44-
unless @comment.post.user == current_user
45-
@comment.post.user.create_notification(notification, helpers.comment_link(@comment))
46-
end
4744

4845
ThreadFollower.where(post: @post).each do |tf|
49-
unless tf.user == current_user || tf.user == @comment.post.user
46+
unless tf.user == current_user
5047
tf.user.create_notification(notification, helpers.comment_link(@comment))
5148
end
5249
ThreadFollower.create(user: tf.user, comment_thread: @comment_thread)
@@ -237,8 +234,7 @@ def thread_unrestrict
237234
end
238235
@comment_thread.update(deleted: false, deleted_by: nil)
239236
when 'follow'
240-
tf = ThreadFollower.find_by(comment_thread: @comment_thread, user: current_user)
241-
tf&.destroy
237+
ThreadFollower.where(comment_thread: @comment_thread, user: current_user).destroy_all
242238
else
243239
return not_found
244240
end

app/controllers/posts_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def create
100100

101101
if @post.save
102102
@post.update(last_activity: @post.created_at, last_activity_by: current_user)
103+
ThreadFollower.create user: @post.user, post: @post
103104
if @post_type.has_parent?
104105
unless @post.user_id == @post.parent.user_id
105106
@post.parent.user.create_notification("New response to your post #{@post.parent.title}",

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)