mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
add strict rate limit
This commit is contained in:
@ -3496,13 +3496,22 @@ fn showDesktopNotification(self: *Surface, title: [:0]const u8, body: [:0]const
|
||||
|
||||
var new_notification_digest: [hash_algorithm.digest_length]u8 = undefined;
|
||||
|
||||
if (last_notification_time) |last| {
|
||||
if (now.since(last) < 1 * std.time.ns_per_s) {
|
||||
log.warn("rate limiting desktop notifications", .{});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var hash = hash_algorithm.init(.{});
|
||||
hash.update(title);
|
||||
hash.update(body);
|
||||
hash.final(&new_notification_digest);
|
||||
}
|
||||
|
||||
if (std.mem.eql(u8, &last_notification_digest, &new_notification_digest)) {
|
||||
if (last_notification_time) |last| {
|
||||
if (std.mem.eql(u8, &last_notification_digest, &new_notification_digest)) {
|
||||
if (now.since(last) < 5 * std.time.ns_per_s) {
|
||||
log.warn("suppressing identical notification", .{});
|
||||
return;
|
||||
|
Reference in New Issue
Block a user