╭ changed ─╮ │src/ui.zig│ ╰──────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────╮ │2061 } │ │2062 │ │2063 // whether the user may write to the repo `identity` names with at least│ │2064 -// `min_role` │ │2064 +// `min_role`, and to the `thread_kind` tab when there is one │ │2065 pub fn authorizeUser( │ │2066 io: std.Io, │ │2067 moment: evt.AdminDB.HashMap(.read_only), │ ╰──────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │2070 user_id: [evt.event_id_size]u8, │ │2071 identity: []const u8, │ │2072 min_role: evt.Repo.Role, │ │2073 + thread_kind: ?evt.EventKind, │ │2074 ) !Authorization { │ │2075 const user = (try activeUser(moment, arena, user_id)) orelse return .login_required;│ │2076 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │2079 // a repo the user can't read doesn't exist to them │ │2080 const role = repo.role orelse return .repo_not_found; │ │2081 if (!role.atLeast(min_role)) return .forbidden; │ │2082 + if (thread_kind) |kind| { │ │2083 + // a tab that is off doesn't exist │ │2084 + const tab_role = repo.repo.event.threadRole(kind) orelse return .repo_not_found;│ │2085 + if (!role.atLeast(tab_role)) return .forbidden; │ │2086 + } │ │2087 return .{ .actor = .{ │ │2088 .author = .{ .name = user.event.name, .email = user.event.email }, │ │2089 .user_id = user_id, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────╮ │2261 name: []const u8, │ │2262 description: []const u8, │ │2263 access: evt.Repo.Access, │ │2264 + discuss_role: ?evt.Repo.Role,│ │2265 + issue_role: ?evt.Repo.Role, │ │2266 + patch_role: ?evt.Repo.Role, │ │2267 }, │ │2268 }, │ │2269 issue: struct { │ ╰───────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2376 } │ │2377 │ │2378 // the actor for a write to the repo `identity` names, or null when the │ │2370 - // session may not write there with at least `min_role`. local mode always │ │2371 - // writes. │ │2372 - pub fn authorize(self: *Self, identity: []const u8, min_role: evt.Repo.Role) !?Actor { │ │2379 + // session may not write there with at least `min_role` or in the │ │2380 + // `thread_kind` tab. local mode always writes. │ │2381 + pub fn authorize(self: *Self, identity: []const u8, min_role: evt.Repo.Role, thread_kind: ?evt.EventKind) !?Actor {│ │2382 if (self.data.host_kind == .local) { │ │2383 const author = blk: { │ │2384 const src = self.local orelse break :blk local_author_fallback; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2393 const io = self.io orelse return null; │ │2394 const users_dir = self.users_dir orelse return null; │ │2395 const moment = try evt.currentMoment(evt.admin_repo_opts, admin_repo); │ │2387 - return switch (try authorizeUser(io, moment, self.page_arena, users_dir, user_id, identity, min_role)) { │ │2396 + return switch (try authorizeUser(io, moment, self.page_arena, users_dir, user_id, identity, min_role, thread_kind)) {│ │2397 .actor => |actor| actor, │ │2398 .login_required, .repo_not_found, .forbidden => null, │ │2399 }; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯