╭ changed ─────────╮ │src/test/event.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────╮ │← previous│ ╰──────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────╮ │177 // for each event we want to process... │ │178 for (ctx.events) |event| { │ │179 // get the id of the current event as bytes │ │165 - var current_event_id_buffer: [id_size]u8 = undefined; │ │180 + var current_event_id_buffer: [event_id_size]u8 = undefined; │ │181 _ = try std.fmt.hexToBytes(&current_event_id_buffer, &event.id);│ │182 │ │183 // if this event has already been processed, skip it │ ╰─────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │209 const views = try Repo.DB.HashMap(.read_write).init(views_cursor); │ │210 │ │211 if (std.mem.eql(u8, "add-issue", event.kind)) { │ │212 + const data = switch (event.data) { │ │213 + .object => |object| object, │ │214 + else => return error.InvalidEventData, │ │215 + }; │ │216 + │ │217 const issues_cursor = try views.putCursor(hash.hashInt(repo_opts.hash, "issues"));│ │218 const issues = try Repo.DB.ArrayList(.read_write).init(issues_cursor); │ │219 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │221 const issue = try Repo.DB.HashMap(.read_write).init(issue_cursor); │ │222 │ │223 try issue.put(hash.hashInt(repo_opts.hash, "id"), .{ .bytes = &event.id }); │ │204 - try issue.put(hash.hashInt(repo_opts.hash, "title"), .{ .bytes = event.data.title }); │ │205 - try issue.put(hash.hashInt(repo_opts.hash, "description"), .{ .bytes = event.data.description }); │ │224 + try issue.put(hash.hashInt(repo_opts.hash, "title"), .{ .bytes = try getObjectString(data, "title") }); │ │225 + try issue.put(hash.hashInt(repo_opts.hash, "description"), .{ .bytes = try getObjectString(data, "description") });│ │226 } else { │ │227 return error.InvalidEventKind; │ │228 } │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │239 try haxy.put(hash.hashInt(repo_opts.hash, "last-event-id"), .{ .bytes = last_event_id });│ │240 } │ │241 } │ │242 + │ │243 + fn getObjectString(object: std.json.ObjectMap, key: []const u8) ![]const u8 { │ │244 + const value = object.get(key) orelse return error.MissingEventField; │ │245 + return switch (value) { │ │246 + .string => |string| string, │ │247 + else => error.InvalidEventField, │ │248 + }; │ │249 + } │ │250 }; │ │251 │ │252 try repo.core.db_file.lock(io, .exclusive); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯