My Ash app has 3 resources: Chat_Room, Post, and Comment,
Chat_Room has_many Posts, and Post has_many Comments.
Chat_Room has the following policy defined for read access restriction, and users are granted access to Chat_Room level.
policy action_type(:read) do
authorize_if expr(visible_to(user_id: actor(:id)))
end
calculate :visible_to, :boolean, expr( ..... ) do
argument :user_id, :uuid
end
Now, in Comment.ex, I want to do something like this so that I don’t have to define visible_to calculation in Comment.ex.
policy action_type(:read) do
authorize_if expr(exists(post, chat_room.visible_to(user_id: actor(:id)))
end
However, I get “key :destination not found in: nil” error instead, from lib/expr.ex.