Skip to content

Commit

Permalink
GUI: Fix distributed notifications in silent mode (#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellhancox authored Nov 16, 2022
1 parent 6a84023 commit 80b2695
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Source/gui/SNTNotificationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,16 @@ - (BOOL)notificationAlreadyQueued:(SNTMessageWindowController *)pendingMsg {
}

- (void)queueMessage:(SNTMessageWindowController *)pendingMsg {
NSString *messageHash = [pendingMsg messageHash];
// Post a distributed notification, regardless of queue state.
[self postDistributedNotification:pendingMsg];

// If GUI is in silent mode or if there's already a notification queued for
// this message, don't do anything else.
if ([SNTConfigurator configurator].enableSilentMode) return;
if ([self notificationAlreadyQueued:pendingMsg]) return;

// See if this message is silenced.
// See if this message has been user-silenced.
NSString *messageHash = [pendingMsg messageHash];
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSDate *silenceDate = [ud objectForKey:silencedNotificationsKey][messageHash];
if ([silenceDate isKindOfClass:[NSDate class]]) {
Expand All @@ -114,7 +120,6 @@ - (void)queueMessage:(SNTMessageWindowController *)pendingMsg {

pendingMsg.delegate = self;
[self.pendingNotifications addObject:pendingMsg];
[self postDistributedNotification:pendingMsg];

if (!self.currentWindowController) {
[self showQueuedWindow];
Expand Down Expand Up @@ -315,8 +320,6 @@ - (void)postRuleSyncNotificationWithCustomMessage:(NSString *)message {
}

- (void)postBlockNotification:(SNTStoredEvent *)event withCustomMessage:(NSString *)message {
if ([SNTConfigurator configurator].enableSilentMode) return;

if (!event) {
LOGI(@"Error: Missing event object in message received from daemon!");
return;
Expand All @@ -329,8 +332,6 @@ - (void)postBlockNotification:(SNTStoredEvent *)event withCustomMessage:(NSStrin
}

- (void)postUSBBlockNotification:(SNTDeviceEvent *)event withCustomMessage:(NSString *)message {
if ([SNTConfigurator configurator].enableSilentMode) return;

if (!event) {
LOGI(@"Error: Missing event object in message received from daemon!");
return;
Expand Down

0 comments on commit 80b2695

Please sign in to comment.