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