╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ notify.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
554 if (record.removed or record.created_order != order) continue; 555 break :blk .{ .thread_id = record.event.thread_id, .actor_email = record.author_email }; 556 }, 557 else => continue, 558 }; 559 560 const thread_id = try evt.parseEventId(&created.thread_id); 561 const Titled = struct { event: struct { title: []const u8 } }; 562 const thread_kind = (try evt.readEventKind(repo_opts.hash, kinds, &thread_id)) orelse continue; 563 const thread = (switch (thread_kind) { 564 .issue => try evt.readRecordSubset(evt.Issue, Titled, DB, repo_opts.hash, haxy_moment, &arena, &thread_id), 565 .patch => try evt.readRecordSubset(evt.Patch, Titled, DB, repo_opts.hash, haxy_moment, &arena, &thread_id), 566 .discuss => try evt.readRecordSubset(evt.Discussion, Titled, DB, repo_opts.hash, haxy_moment, &arena, &thread_id), 567 else => null, 568 }) orelse continue; 569 570 const notif: Notif = .{ 571 .repo_id = location.repo_id, 572 .owner_name = owner.event.name, 573 .repo_name = repo_record.event.name, 574 .thread_id = thread_id, 575 .thread_kind = thread_kind, 576 .title = thread.event.title, 577 .last_child_id = id, 578 }; 579 580 // a user hears of no comment or assignment they made or pushed 581 const actor_id = if (created.actor_email) |email| try evt.User.readIdByEmail(evt.AdminDB, evt.admin_repo_opts.hash, admin_moment, email) else null; 582 for (try readNotified(owner_latest, &arena, &idOf(&location.repo_id, &thread_id))) |user_id| { 583 if (actor_id) |actor| if (std.mem.eql(u8, &actor, &user_id)) continue; 584 if (pusher_id) |pusher| if (std.mem.eql(u8, pusher, &user_id)) continue; 585 try inboxes.add(user_id, notif); 586 } 587 } 588 589 if (inboxes.by_user.count() == 0) return; 590 progress.report(repo_opts, io, progress_ctx_maybe, .{ .text = "Delivering notifications" }); 591 progress.report(repo_opts, io, progress_ctx_maybe, .{ .start = .{ .kind = .writing_patch, .estimated_total_items = inboxes.by_user.count() } }); 592 for (inboxes.by_user.keys(), inboxes.by_user.values()) |*user_id, notifs| { 593 deliver(io, allocator, users_dir, user_id, notifs.items) catch |err| { 594 std.log.warn("failed to deliver notifications: {s}", .{@errorName(err)}); 595 }; 596 progress.report(repo_opts, io, progress_ctx_maybe, .{ .complete_one = .writing_patch }); 597 } 598 progress.report(repo_opts, io, progress_ctx_maybe, .{ .end = .writing_patch }); 599 } 600