Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Loop/Managers/DeviceDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,21 @@ extension DeviceDataManager {
func handleRemoteNotification(_ notification: [String: AnyObject]) {

if FeatureFlags.remoteOverridesEnabled {

if let expirationStr = notification["expiration"] as? String {
let formatter = ISO8601DateFormatter()
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
if let expiration = formatter.date(from: expirationStr) {
guard expiration > Date() else {
log.error("Expired notification: %{public}@", String(describing: notification))
return
}
} else {
log.error("Invalid expiration: %{public}@", expirationStr)
return
}
}

if let command = RemoteCommand(notification: notification, allowedPresets: loopManager.settings.overridePresets) {
switch command {
case .temporaryScheduleOverride(let override):
Expand Down Expand Up @@ -1272,10 +1287,10 @@ extension DeviceDataManager {
}
}
}
// Wait up to 25 seconds for uploads to finish
// Wait up to 25 seconds for uploads triggered by these commands to finish
let _ = remoteDataServicesManager.waitForUploadsToFinish(timeout: .now() + TimeInterval(25))
} else {
log.info("Unhandled remote notification: %{public}@", String(describing: notification))
log.error("Unhandled remote notification: %{public}@", String(describing: notification))
}
}
log.info("Finished handling remote notification")
Expand Down