Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove special case notifying author of threads #1037

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ def create_thread

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

ThreadFollower.where(post: @post).each do |tf|
unless tf.user == current_user || tf.user == @comment.post.user
unless tf.user == current_user
tf.user.create_notification(notification, helpers.comment_link(@comment))
end
ThreadFollower.create(user: tf.user, comment_thread: @comment_thread)
Expand Down Expand Up @@ -237,8 +234,7 @@ def thread_unrestrict
end
@comment_thread.update(deleted: false, deleted_by: nil)
when 'follow'
tf = ThreadFollower.find_by(comment_thread: @comment_thread, user: current_user)
tf&.destroy
ThreadFollower.where(comment_thread: @comment_thread, user: current_user).destroy_all
else
return not_found
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def create

if @post.save
@post.update(last_activity: @post.created_at, last_activity_by: current_user)
ThreadFollower.create user: @post.user, post: @post
if @post_type.has_parent?
unless @post.user_id == @post.parent.user_id
@post.parent.user.create_notification("New response to your post #{@post.parent.title}",
Expand Down
10 changes: 0 additions & 10 deletions app/models/comment_thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class CommentThread < ApplicationRecord
scope :publicly_available, -> { where(deleted: false).where('reply_count > 0') }
scope :archived, -> { where(archived: true) }

after_create :create_follower

def read_only?
locked? || archived? || deleted?
end
Expand All @@ -38,12 +36,4 @@ def self.post_followed?(post, user)

private

# Comment author and post author are automatically followed to the thread. Question author is NOT
# automatically followed on new answer comment threads. Comment author follower creation is done
# on the Comment model.
def create_follower
if post.user.preference('auto_follow_comment_threads') == 'true'
ThreadFollower.create comment_thread: self, user: post.user
end
end
end
Loading