diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index aae53e48bf1..45cdc533a6a 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -136,7 +136,7 @@ def alert_and_redirect_moderated
flash.now[:warning] = "First-time poster #{@node.author.name} submitted this #{time_ago_in_words(@node.created_at)} ago and it has not yet been approved by a moderator. Approve Spam"
elsif @node.status == 4 && (current_user && current_user.id == @node.author.id) && !flash[:first_time_post]
flash.now[:warning] = "Thank you for contributing open research, and thanks for your patience while your post is approved by community moderators and we'll email you when it is published. In the meantime, if you have more to contribute, feel free to do so."
- elsif @node.status == 3 && (current_user && (current_user.is_coauthor(@node) || current_user.can_moderate?)) && !flash[:first_time_post]
+ elsif @node.status == 3 && (current_user && (current_user.is_coauthor?(@node) || current_user.can_moderate?)) && !flash[:first_time_post]
flash.now[:warning] = "This is a draft note. Once you're ready, click Publish Draft to make it public. You can share it with collaborators using this private link #{@node.draft_url}"
elsif @node.status != 1 && @node.status != 3 && !(current_user && (current_user.role == 'admin' || current_user.role == 'moderator'))
# if it's spam or a draft
diff --git a/app/models/comment.rb b/app/models/comment.rb
index c7034a1f77a..d1600b2483b 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -101,11 +101,7 @@ def next_thread
end
def parent
- if aid == 0
- node
- else
- return answer.node unless answer.nil?
- end
+ aid.zero? ? node : answer&.node
end
def mentioned_users
@@ -370,15 +366,14 @@ def trimmed_content?
end
def parse_quoted_text
- match = body.match(/(.+)(On .+<.+@.+> wrote:)(.+)/m)
- if match.nil?
- false
- else
+ if regex_match = body.match(/(.+)(On .+<.+@.+> wrote:)(.+)/m)
{
- body: match[1], # the new message text
- boundary: match[2], # quote delimeter, i.e. "On Tuesday, 3 July 2018, 11:20:57 PM IST, RP