mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:19:27 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
26 lines
542 B
Ruby
26 lines
542 B
Ruby
# frozen_string_literal: true
|
|
|
|
# mixin for all Guardian methods dealing with post_revisions permissions
|
|
module PostRevisionGuardian
|
|
|
|
def can_see_post_revision?(post_revision)
|
|
return false unless post_revision
|
|
return false if post_revision.hidden && !can_view_hidden_post_revisions?
|
|
|
|
can_view_edit_history?(post_revision.post)
|
|
end
|
|
|
|
def can_hide_post_revision?(post_revision)
|
|
is_staff?
|
|
end
|
|
|
|
def can_show_post_revision?(post_revision)
|
|
is_staff?
|
|
end
|
|
|
|
def can_view_hidden_post_revisions?
|
|
is_staff?
|
|
end
|
|
|
|
end
|