mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Various fixes to support posts with no user (#8877)
* Do not grant badges for posts with no user * Ensure instructions are correct in Change Owner modal * Hide user-dependent actions from posts with no user * Make PostRevisor work with posts with no user * Ensure posts with no user can be deleted * discourse-narrative-bot should ignore posts with no user * Skip TopicLink creation for posts with no user
This commit is contained in:
@@ -56,7 +56,7 @@ class CookedPostProcessor
|
||||
end
|
||||
|
||||
def grant_badges
|
||||
return unless Guardian.new.can_see?(@post)
|
||||
return if @post.user.blank? || !Guardian.new.can_see?(@post)
|
||||
|
||||
BadgeGranter.grant(Badge.find(Badge::FirstEmoji), @post.user, post_id: @post.id) if has_emoji?
|
||||
BadgeGranter.grant(Badge.find(Badge::FirstOnebox), @post.user, post_id: @post.id) if @has_oneboxes
|
||||
|
||||
@@ -30,7 +30,7 @@ module PostGuardian
|
||||
return false unless (can_see_post.nil? && can_see_post?(post)) || can_see_post
|
||||
|
||||
# no warnings except for staff
|
||||
return false if (action_key == :notify_user && !is_staff? && opts[:is_warning].present? && opts[:is_warning] == 'true')
|
||||
return false if action_key == :notify_user && (post.user.blank? || (!is_staff? && opts[:is_warning].present? && opts[:is_warning] == 'true'))
|
||||
|
||||
taken = opts[:taken_actions].try(:keys).to_a
|
||||
is_flag = PostActionType.notify_flag_types[action_key]
|
||||
@@ -71,7 +71,7 @@ module PostGuardian
|
||||
not(post.trashed?) &&
|
||||
|
||||
# don't like your own stuff
|
||||
not(action_key == :like && is_my_own?(post))
|
||||
not(action_key == :like && (post.user.blank? || is_my_own?(post)))
|
||||
end
|
||||
|
||||
!!result
|
||||
|
||||
@@ -276,6 +276,8 @@ class PostDestroyer
|
||||
end
|
||||
|
||||
def notify_deletion(reviewable)
|
||||
return if @post.user.blank?
|
||||
|
||||
allowed_user = @user.human? && @user.staff?
|
||||
return unless allowed_user && rs = reviewable.reviewable_scores.order('created_at DESC').first
|
||||
|
||||
|
||||
@@ -180,13 +180,13 @@ class PostRevisor
|
||||
@fields.has_key?('raw') &&
|
||||
@editor.staff? &&
|
||||
@editor != Discourse.system_user &&
|
||||
!@post.user.staff?
|
||||
!@post.user&.staff?
|
||||
)
|
||||
PostLocker.new(@post, @editor).lock
|
||||
end
|
||||
|
||||
# We log staff edits to posts
|
||||
if @editor.staff? && @editor.id != @post.user.id && @fields.has_key?('raw') && !@opts[:skip_staff_log]
|
||||
if @editor.staff? && @editor.id != @post.user_id && @fields.has_key?('raw') && !@opts[:skip_staff_log]
|
||||
StaffActionLogger.new(@editor).log_post_edit(
|
||||
@post,
|
||||
old_raw: old_raw
|
||||
|
||||
Reference in New Issue
Block a user