╭ changed ─────────╮ │src/event/Repo.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────╮ │ 7 name: []const u8, │ │ 8 description: []const u8, │ │ 9 read_access: Access = .private, │ │10 -write_access: Access = .private, │ │10 // the least role that may write in each tab, null turns the tab off│ │11 discuss_role: ?Role = .read, │ │12 issue_role: ?Role = .read, │ ╰────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │75 } │ │76 │ │77 // the role `user_id_maybe` holds in the repo, or null when they hold none: its│ │79 -// creator owns it, and anyone else gets the higher of the base role and their │ │80 -// grant. `user_moment` is the owner's, which holds the grants. a null user is │ │81 -// logged out. │ │78 +// creator owns it, and anyone else gets their grant, else the base role. │ │79 +// `user_moment` is the owner's, which holds the grants. a null user is logged │ │80 +// out. │ │81 pub fn roleOf( │ │82 comptime DB: type, │ │83 comptime hash_kind: hash.HashKind, │ ╰───────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │87 repo_id: *const [evt.event_id_size]u8, │ │88 user_id_maybe: ?[evt.event_id_size]u8, │ │89 ) !?Role { │ │91 - // what the access fields give everyone, logged in or not │ │92 - const base_maybe: ?Role = if (record.event.write_access == .public) .write else if (record.event.read_access == .public) .read else null;│ │93 - const user_id = user_id_maybe orelse return base_maybe; │ │90 + // what read access gives everyone, logged in or not │ │91 + const base: ?Role = if (record.event.read_access == .public) .read else null; │ │92 + const user_id = user_id_maybe orelse return base; │ │93 if (std.mem.eql(u8, &record.event.user_id, &std.fmt.bytesToHex(user_id, .lower))) return .owner; │ │94 │ │96 - const granted = (try evt.Grant.readRole(DB, hash_kind, user_moment, arena, repo_id, &user_id)) orelse return base_maybe; │ │97 - const base = base_maybe orelse return granted; │ │98 - return if (granted.atLeast(base)) granted else base; │ │95 + // a grant is never below the base role │ │96 + return (try evt.Grant.readRole(DB, hash_kind, user_moment, arena, repo_id, &user_id)) orelse base; │ │97 } │ │98 │ │99 // the moment keys `evt.merge` reads and writes for this kind │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯