╭ changed ───────────╮ │src/event/Notify.zig│ ╰────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────╮ │ 4 const hash = xit.hash; │ │ 5 │ │ 6 // the repo's owner, whose user repo holds the subscriber index│ │ 7 -owner_id: []const u8, │ │ 7 +owner_id: [evt.event_id_size * 2]u8, │ │ 8 // the thread and its repo │ │ 9 -repo_id: []const u8, │ │ 9 +repo_id: [evt.event_id_size * 2]u8, │ │10 thread_id: [evt.event_id_size * 2]u8, │ │11 mode: Mode, │ │12 │ ╰───────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │33 pub const all_id_set_key = "notify-id-set"; │ │34 │ │35 // the id of the one record a user can hold on a thread │ │36 -pub fn idOf(repo_id: []const u8, thread_id: *const [evt.event_id_size]u8) [evt.event_id_size]u8 { │ │36 +pub fn idOf(repo_id: *const [evt.event_id_size]u8, thread_id: *const [evt.event_id_size]u8) [evt.event_id_size]u8 {│ │37 var hasher = std.crypto.hash.sha2.Sha256.init(.{}); │ │38 // the kind name keeps the id apart from the notif id the same pair hashes to │ │39 hasher.update(@tagName(evt.EventKind.notify)); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │47 // only what the event says about itself is checked. a record naming a missing │ │48 // repo or thread is inert. │ │49 fn validate(event_id: *const [evt.event_id_size]u8, record: Record) !void { │ │50 - if (record.event.owner_id.len != evt.event_id_size) return error.InvalidOwnerId; │ │51 - if (record.event.repo_id.len != evt.event_id_size) return error.InvalidRepoId; │ │50 + _ = try evt.parseEventId(&record.event.owner_id); │ │51 + const repo_id = try evt.parseEventId(&record.event.repo_id); │ │52 const thread_id = try evt.parseEventId(&record.event.thread_id); │ │53 - if (!std.mem.eql(u8, event_id, &idOf(record.event.repo_id, &thread_id))) return error.InvalidNotifyId;│ │53 + if (!std.mem.eql(u8, event_id, &idOf(&repo_id, &thread_id))) return error.InvalidNotifyId; │ │54 } │ │55 │ │56 pub fn consume( │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯