feat(policies): add CommentPolicy, update? and LikePolicy

This commit is contained in:
dualfroz committed 2026-09-04 18:23:56 +02:00
1 parent 5025bb8d9c
commit 4160704b23
3 files changed
+43

No files matched your search

@@ -0,0 +1,25 @@
class CommentPolicy < Prism::Policy
def update?
user && record.user_id == user.id
end
def destroy?
update?
end
def restore?
update?
end
# Approving/rejecting is a moderation call, not an authorship one - it
# belongs to whoever owns the post the comment hangs off of, same as the
# nested-attributes moderation form on PostsController#update (which goes
# through PostPolicy#update? instead, since that request targets the post).
def approve?
user && record.post.user_id == user.id
end
def reject?
approve?
end
end
@@ -0,0 +1,5 @@
class LikePolicy < Prism::Policy
def destroy?
user && record.user_id == user.id
end
end
+13
View File
@@ -0,0 +1,13 @@
class PostPolicy < Prism::Policy
def update?
user && record.user_id == user.id
end
def destroy?
update?
end
def restore?
update?
end
end