logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

status_policy.rb (792B)


  1. # frozen_string_literal: true
  2. class StatusPolicy < ApplicationPolicy
  3. def index?
  4. staff?
  5. end
  6. def show?
  7. if direct?
  8. owned? || record.mentions.where(account: current_account).exists?
  9. elsif private?
  10. owned? || current_account&.following?(author) || record.mentions.where(account: current_account).exists?
  11. else
  12. current_account.nil? || !author.blocking?(current_account)
  13. end
  14. end
  15. def reblog?
  16. !direct? && !private? && show?
  17. end
  18. def destroy?
  19. staff? || owned?
  20. end
  21. alias unreblog? destroy?
  22. def update?
  23. staff?
  24. end
  25. private
  26. def direct?
  27. record.direct_visibility?
  28. end
  29. def owned?
  30. author.id == current_account&.id
  31. end
  32. def private?
  33. record.private_visibility?
  34. end
  35. def author
  36. record.account
  37. end
  38. end