braden
03/20/2024, 3:03 AMbraden
03/20/2024, 3:07 AMbraden
03/20/2024, 3:18 AMbraden
03/20/2024, 3:28 AMyetitwo
03/20/2024, 3:53 AMyetitwo
03/20/2024, 3:54 AMyetitwo
03/20/2024, 3:54 AMbraden
03/20/2024, 4:07 AMecordell
03/20/2024, 1:17 PMdefinition user {}
caveat minimum_karma(minimum int, current int) {
current > minimum
}
definition subreddit {
relation change_flair: user:* with minimum_karma
}
You then just write one relationship for each subreddit to set the minimum values, like:
subreddit:funny#change_flair@user:*[minimum_karma:{"minimum":"200"}]
subreddit:pics#change_flair@user:*[minimum_karma:{"minimum":"700"}]
and then when you check
you can send the actual user along and get the answer (or just a placeholder value if you want)
The nice thing about doing this is that you can start sending users in checks before you have users in SpiceDB at all. Then later on maybe you want to just store moderators
in SpiceDB and you can start writing rules like "must have 200 karma to change flair, or be a moderator"
here's a quick example: https://play.authzed.com/s/xTHM7JGUulpz/schemabraden
03/25/2024, 2:49 AM