╭ changed ────────────╮ │src/event/Comment.zig│ ╰─────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────╮ │105 io: std.Io, │ │106 allocator: std.mem.Allocator, │ │107 repo: *rp.Repo(repo_kind, repo_opts), │ │108 + thread_kind: evt.EventKind, │ │109 thread_id: *const [evt.event_id_size * 2]u8,│ │110 parent_id: *const [evt.event_id_size * 2]u8,│ │111 body: []const u8, │ ╰─────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │112 author: evt.CommitAuthor, │ │113 ) ![evt.event_id_size * 2]u8 { │ │114 if (!fieldsValid(body)) return error.InvalidFields; │ │115 + │ │116 + // a reply's parent is the thread itself or one of its comments │ │117 + const thread_id_bytes = evt.parseEventId(thread_id) catch return error.NotFound; │ │118 + const parent_id_bytes = evt.parseEventId(parent_id) catch return error.NotFound; │ │119 + const parent: ?evt.ThreadChild = if (std.mem.eql(u8, thread_id, parent_id)) null else .{ .comment = &parent_id_bytes }; │ │120 + if (!try evt.threadHolds(repo_kind, repo_opts, io, allocator, repo, thread_kind, &thread_id_bytes, parent)) return error.NotFound;│ │121 │ │122 var id_bytes: [evt.event_id_size]u8 = undefined; │ │123 io.random(&id_bytes); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────╮ │144 io: std.Io, │ │145 allocator: std.mem.Allocator, │ │146 repo: *rp.Repo(repo_kind, repo_opts), │ │147 + thread_kind: evt.EventKind, │ │148 thread_id: *const [evt.event_id_size * 2]u8,│ │149 comment_id: *const [evt.event_id_size]u8, │ │150 body: []const u8, │ ╰─────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │151 author: evt.CommitAuthor, │ │152 ) !void { │ │153 if (!fieldsValid(body)) return error.InvalidFields; │ │154 + │ │155 + const thread_id_bytes = evt.parseEventId(thread_id) catch return error.NotFound; │ │156 + if (!try evt.threadHolds(repo_kind, repo_opts, io, allocator, repo, thread_kind, &thread_id_bytes, .{ .comment = comment_id })) return error.NotFound;│ │157 │ │158 var arena = std.heap.ArenaAllocator.init(allocator); │ │159 defer arena.deinit(); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │170 evt.currentMoment(repo_opts, repo)) catch return error.NotFound; │ │171 break :blk (try readById(DB, repo_opts.hash, moment, &arena, comment_id)) orelse return error.NotFound;│ │172 }; │ │162 - if (!std.mem.eql(u8, &comment.event.thread_id, thread_id)) return error.NotFound; │ │173 if (comment.removed) return error.NotFound; │ │174 │ │175 var updated = comment.event; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯