╭ changed ──╮ │src/web.zig│ ╰───────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │383 │ │384 // the author for an event created by this request, or null when the request │ │385 // may not create one. local mode has no accounts, so it authors anonymously.│ │386 -fn eventAuthorEmail( │ │386 +fn eventAuthor( │ │387 io: std.Io, │ │388 allocator: std.mem.Allocator, │ │389 arena: *std.heap.ArenaAllocator, │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │390 request: *std.http.Server.Request, │ │391 host: Host, │ │392 -) !?[]const u8 { │ │392 +) !?evt.CommitAuthor { │ │393 const remote = switch (host) { │ │394 .remote => |remote| remote, │ │395 - .local => return "user@haxy", // TODO: try the repo's git config user.email first│ │395 + .local => |src| return try ui.localAuthor(src, io, allocator, arena), │ │396 }; │ │397 const token = getCookieValue(request, cookie_name) orelse return null; │ │398 var user_id: [evt.event_id_size]u8 = undefined; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │402 defer repo.deinit(io, allocator); │ │403 const moment = try evt.currentMoment(evt.admin_repo_opts, &repo); │ │404 const user = (try evt.User.readById(evt.AdminDB, evt.admin_repo_opts.hash, moment, arena, &user_id)) orelse return null;│ │405 - return user.event.email; │ │405 + return .{ .name = user.event.name, .email = user.event.email }; │ │406 } │ │407 │ │408 // refuse a write from a request with no logged-in user. the body goes unread, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │446 ) !void { │ │447 var author_arena = std.heap.ArenaAllocator.init(allocator); │ │448 defer author_arena.deinit(); │ │449 - const author_email = (try eventAuthorEmail(io, allocator, &author_arena, request, host)) orelse return respondLoginRequired(request);│ │449 + const author = (try eventAuthor(io, allocator, &author_arena, request, host)) orelse return respondLoginRequired(request); │ │450 │ │451 var body_buf: [256]u8 = undefined; │ │452 const reader = request.readerExpectNone(&body_buf); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │481 const event = evt.EventWithId{ │ │482 .id = event_id_hex, │ │483 .timestamp = @intCast(std.Io.Timestamp.now(io, .real).toSeconds()),│ │484 - .author_email = author_email, │ │484 + .author = author, │ │485 .event = .{ .issue = .{ │ │486 .title = title, │ │487 .description = description, │ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │530 } │ │531 switch (src.repo_kind) { │ │532 inline else => |repo_kind| { │ │533 - var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, .{ .path = src.path }); │ │533 + var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); │ │534 defer any_repo.deinit(io, allocator); │ │535 switch (any_repo) { │ │536 inline else => |*repo| try evt.consume(repo_kind, repo.self_repo_opts, io, allocator, repo, evt.events_ref, &[_]evt.EventWithId{event}),│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │595 │ │596 var author_arena = std.heap.ArenaAllocator.init(allocator); │ │597 defer author_arena.deinit(); │ │598 - const author_email = (try eventAuthorEmail(io, allocator, &author_arena, request, host)) orelse return respondLoginRequired(request);│ │598 + const author = (try eventAuthor(io, allocator, &author_arena, request, host)) orelse return respondLoginRequired(request); │ │599 │ │600 var body_buf: [256]u8 = undefined; │ │601 const reader = request.readerExpectNone(&body_buf); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │646 │ │647 var repo = try rp.Repo(.xit, .{}).open(io, allocator, .{ .path = repo_path }); │ │648 defer repo.deinit(io, allocator); │ │649 - event_id_hex = try evt.Comment.create(.xit, .{}, io, allocator, &repo, &thread_id_hex, &parent_id_hex, body, author_email);│ │649 + event_id_hex = try evt.Comment.create(.xit, .{}, io, allocator, &repo, &thread_id_hex, &parent_id_hex, body, author); │ │650 }, │ │651 .local => |src| { │ │652 if (parts.repo_base.len != 0) { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │658 } │ │659 switch (src.repo_kind) { │ │660 inline else => |repo_kind| { │ │661 - var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, .{ .path = src.path }); │ │661 + var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); │ │662 defer any_repo.deinit(io, allocator); │ │663 switch (any_repo) { │ │664 - inline else => |*repo| event_id_hex = try evt.Comment.create(repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id_hex, &parent_id_hex, body, author_email),│ │664 + inline else => |*repo| event_id_hex = try evt.Comment.create(repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id_hex, &parent_id_hex, body, author), │ │665 } │ │666 }, │ │667 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │684 host: Host, │ │685 parts: CommentBaseParts, │ │686 body: []const u8, │ │687 - author_email: []const u8, │ │687 + author: evt.CommitAuthor, │ │688 ) !void { │ │689 const comment_id = parts.comment_id orelse return error.NotFound;│ │690 const thread_id = std.fmt.bytesToHex(parts.thread_id, .lower); │ ╰──────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯