Jake
02/04/2022, 2:17 PMAlexey 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).Joey
02/04/2022, 4:32 PMchatuser
, that links a chat to a user, and then you can place the company on that, if you likeJoey
02/04/2022, 4:33 PMmessage
having a unique permission on it, you might just want to check chat#read
, since otherwise you'll need to create a message
object per messageAlexey S
02/04/2022, 4:40 PMJoey
02/04/2022, 4:41 PMpermission read = member + company->admin + member->company_admin_access
as being a hack; where do you find the issue (if any)?Joey
02/04/2022, 4:48 PMpermission read = member + company->admin
Joey
02/04/2022, 4:48 PMrelation member_company: company
Joey
02/04/2022, 4:49 PMpermission read = member + company->admin + member_company->admin
Joey
02/04/2022, 4:49 PMAlexey S
02/04/2022, 4:51 PMJoey
02/04/2022, 4:52 PMAlexey S
02/04/2022, 4:53 PMJoey
02/04/2022, 4:53 PMJoey
02/04/2022, 4:53 PMJoey
02/04/2022, 4:54 PMJoey
02/04/2022, 4:54 PMJoey
02/04/2022, 4:54 PMAlexey S
02/04/2022, 4:55 PMJoey
02/04/2022, 4:55 PMJoey
02/04/2022, 4:55 PMJoey
02/04/2022, 4:56 PMmessage
, unless you need it to have distinct permissionsAlexey S
02/04/2022, 4:56 PMAlexey S
02/04/2022, 4:59 PMJoey
02/04/2022, 4:59 PMJoey
02/04/2022, 4:59 PMJoey
02/04/2022, 5:00 PMJoey
02/04/2022, 5:00 PMAlexey S
02/04/2022, 5:00 PMJoey
02/04/2022, 5:00 PMmessage->user<-company#member