Skip to content

Commit bff8233

Browse files
authored
sync: allow a sync server to change the frequency of syncing to a min of 60 secs (#595)
1 parent b948f6c commit bff8233

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Source/common/SNTSyncConstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ extern NSString *const kPostflightRulesProcessed;
158158
///
159159
/// Are represented in seconds
160160
///
161+
extern const NSUInteger kMinimumFullSyncInterval;
161162
extern const NSUInteger kDefaultFullSyncInterval;
162163
extern const NSUInteger kDefaultPushNotificationsFullSyncInterval;
163164
extern const NSUInteger kDefaultPushNotificationsGlobalRuleSyncDeadline;

Source/common/SNTSyncConstants.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
NSString *const kPostflightRulesProcessed = @"rules_processed";
152152

153153
const NSUInteger kDefaultEventBatchSize = 50;
154+
const NSUInteger kMinimumFullSyncInterval = 60;
154155
const NSUInteger kDefaultFullSyncInterval = 600;
155156
const NSUInteger kDefaultPushNotificationsFullSyncInterval = 14400;
156157
const NSUInteger kDefaultPushNotificationsGlobalRuleSyncDeadline = 600;

Source/santasyncservice/SNTSyncPreflight.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ - (BOOL)sync {
182182
uint64_t value = resp.push_notification_full_sync_interval_seconds()
183183
?: resp.deprecated_fcm_full_sync_interval_seconds();
184184
self.syncState.pushNotificationsFullSyncInterval =
185-
(value < kDefaultFullSyncInterval) ? kDefaultPushNotificationsFullSyncInterval : value;
185+
(value < kMinimumFullSyncInterval) ? kMinimumFullSyncInterval : value;
186186

187187
value = resp.push_notification_global_rule_sync_deadline_seconds()
188188
?: resp.deprecated_fcm_global_rule_sync_deadline_seconds();
@@ -193,7 +193,8 @@ - (BOOL)sync {
193193

194194
// Check if our sync interval has changed
195195
value = resp.full_sync_interval_seconds();
196-
self.syncState.fullSyncInterval = (value < 60) ? kDefaultFullSyncInterval : value;
196+
self.syncState.fullSyncInterval =
197+
(value < kMinimumFullSyncInterval) ? kMinimumFullSyncInterval : value;
197198

198199
switch (resp.client_mode()) {
199200
case ::pbv1::MONITOR: self.syncState.clientMode = SNTClientModeMonitor; break;

0 commit comments

Comments
 (0)