╭ changed ─────────╮ │src/event/Repo.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────╮ │41 │ │42 pub fn atLeast(self: Role, min: Role) bool { │ │43 return @intFromEnum(self) >= @intFromEnum(min); │ │44 + } │ │45 + │ │46 + // whether a user may change an event: anyone's with the write role, │ │47 + // otherwise only one they authored │ │48 + pub fn canModify(self: Role, user_email: []const u8, author_email_maybe: ?[]const u8) bool {│ │49 + if (self.atLeast(.write)) return true; │ │50 + const author_email = author_email_maybe orelse return false; │ │51 + return self.atLeast(.read) and std.mem.eql(u8, user_email, author_email); │ │52 } │ │53 }; │ │54 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯