Alexey S
02/04/2022, 4:20 PMdefinition user {
// hack for accessing company admin
relation company: company
permission company_admin_access = company->admin
}
definition company {
relation member: user
relation admin: user
}
definition chat {
relation member: user
relation company: company
// hack for providing access for company's admin in case the group belongs to other company
permission read = member + company->admin + member->company_admin_access
}
definition message {
relation chat: chat
permission read = chat->read
}
Here is my playground with the schema, test data and assertions.
https://play.authzed.com/s/wMeYSz8cZCI4/schema
Would be happy if you could direct me on how to simplify it (for example avoiding backlink to the company in user).