╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Comment.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
174 175 var updated = comment.event; 176 updated.body = body; 177 try evt.consume(host, .repo, repo_kind, repo_opts, io, allocator, repo, evt.events_ref, &.{.{ 178 .id = std.fmt.bytesToHex(comment_id.*, .lower), 179 .timestamp = @intCast(std.Io.Timestamp.now(io, .real).toSeconds()), 180 .author = author, 181 .event = .{ .comment = updated }, 182 }}); 183 } 184 185 // read a comment by event id, or null if the id isn't a known comment. field 186 // byte slices are allocated in `arena`. 187 pub fn readById( 188 comptime DB: type, 189 comptime hash_kind: hash.HashKind, 190 haxy_moment: DB.HashMap(.read_only), 191 arena: *std.heap.ArenaAllocator, 192 comment_id: []const u8, 193 ) !?Record { 194 const records_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, record_map_key)) orelse return null; 195 const records = try DB.HashMap(.read_only).init(records_cursor); 196 const record_cursor = try records.getCursor(hash.hashInt(hash_kind, comment_id)) orelse return null; 197 const record_map = try DB.HashMap(.read_only).init(record_cursor); 198 return try evt.read(Record, DB, hash_kind, arena, record_map); 199 } 200