╭ changed ─────────╮ │src/event/Repo.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │ 6 user_id: []const u8, │ │ 7 name: []const u8, │ │ 8 description: []const u8, │ │ 9 +read_access: Access = .private, │ │10 +write_access: Access = .private, │ │11 +read_user_ids: []const u8 = "", │ │12 +write_user_ids: []const u8 = "", │ │13 │ │14 // what the db stores: the event's data plus the commit-derived fields│ │15 pub const Record = struct { │ ╰──────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────╮ │25 }; │ │26 │ │27 const Self = @This(); │ │28 + │ │29 +pub const Access = enum { │ │30 + private, │ │31 + public, │ │32 +}; │ │33 │ │34 pub const name_max_len = 32;│ │35 │ ╰────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────╮ │48 if (!std.ascii.isAlphanumeric(c) and c != '-' and c != '_' and c != '.')│ │49 return error.InvalidName; │ │50 } │ │51 +} │ │52 + │ │53 +fn validateUserIds(user_ids: []const u8) !void { │ │54 + var lines = std.mem.tokenizeScalar(u8, user_ids, '\n'); │ │55 + while (lines.next()) |id| _ = try evt.parseEventId(id); │ │56 } │ │57 │ │58 pub fn consume( │ ╰────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │87 break :blk record; │ │88 }; │ │89 │ │76 - if (!record_to_write.removed) try validateName(record_to_write.event.name); │ │90 + if (!record_to_write.removed) { │ │91 + try validateName(record_to_write.event.name); │ │92 + try validateUserIds(record_to_write.event.read_user_ids); │ │93 + try validateUserIds(record_to_write.event.write_user_ids); │ │94 + } │ │95 │ │96 const user_id_to_repo_id_set_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "user-id->repo-id-set"));│ │97 const user_id_to_repo_id_set = try DB.HashMap(.read_write).init(user_id_to_repo_id_set_cursor); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯