mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
speed up document authorizer by skipping unnecessary queries
This commit is contained in:
parent
3555e27e20
commit
d52f8b3893
@ -4,13 +4,13 @@ class DocumentAuthorizer < ApplicationAuthorizer
|
||||
end
|
||||
|
||||
def readable_by?(user)
|
||||
[
|
||||
resource.user_id == user.id,
|
||||
resource.privacy == 'public',
|
||||
resource.universe.present? && resource.universe.privacy == 'public',
|
||||
resource.universe.present? && resource.universe.contributors.pluck(:user_id).include?(user.id),
|
||||
resource.universe.present? && resource.universe.user_id == user.id
|
||||
].any?
|
||||
return true if resource.user_id == user.id
|
||||
return true if resource.privacy == 'public'
|
||||
return true if resource.universe.present? && resource.universe.privacy == 'public'
|
||||
return true if resource.universe.present? && resource.universe.contributors.pluck(:user_id).include?(user.id)
|
||||
return true if resource.universe.present? && resource.universe.user_id == user.id
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
def updatable_by?(user)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user