Skip to content

Commit

Permalink
Merge pull request #351 from DP-3T/release/1.2
Browse files Browse the repository at this point in the history
Release 1.2
  • Loading branch information
UBaggeler authored Oct 30, 2020
2 parents 0f07509 + 246ea66 commit 3870b55
Show file tree
Hide file tree
Showing 51 changed files with 1,009 additions and 618 deletions.
48 changes: 27 additions & 21 deletions DP3TApp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,56 @@
"pins": [
{
"package": "Cryptor",
"repositoryURL": "https://github.com/IBM-Swift/BlueCryptor.git",
"repositoryURL": "https://github.com/Kitura/BlueCryptor.git",
"state": {
"branch": null,
"revision": "12d2bf3ec7207ec3cd004b9582f69ef5fae1da3b",
"version": "1.0.32"
"revision": "ee5880e031da4c609f372cf7472476ab51d5dd19",
"version": "1.0.200"
}
},
{
"package": "CryptorECC",
"repositoryURL": "https://github.com/IBM-Swift/BlueECC.git",
"repositoryURL": "https://github.com/Kitura/BlueECC.git",
"state": {
"branch": null,
"revision": "73f362cb0d9c5f1fd0089240d7b293cd2bff18db",
"version": "1.2.5"
"revision": "baf6ed3fc1a622675f0041b4aff7c02dd1a93818",
"version": "1.2.200"
}
},
{
"package": "CryptorRSA",
"repositoryURL": "https://github.com/IBM-Swift/BlueRSA.git",
"repositoryURL": "https://github.com/Kitura/BlueRSA.git",
"state": {
"branch": null,
"revision": "8ea901f2582296837d88f882b0fa5a0601759598",
"version": "1.0.35"
"revision": "c885fcdbe1b04718cb46d747387137653c030f6c",
"version": "1.0.200"
}
},
{
"package": "DP3TSDK",
"repositoryURL": "https://github.com/DP-3T/dp3t-sdk-ios.git",
"state": {
"branch": "develop",
"revision": "26464b940751657223038838c2f5debd87b792a1",
"branch": null,
"revision": "522938daf30dfc93b47aba4d3956a01b5561905e",
"version": null
}
},
{
"package": "KituraContracts",
"repositoryURL": "https://github.com/IBM-Swift/KituraContracts.git",
"repositoryURL": "https://github.com/Kitura/KituraContracts.git",
"state": {
"branch": null,
"revision": "a30e2fb79e926672776a05ec6b919c239870a221",
"version": "1.2.1"
"revision": "8418006e39e2efae9b31ae92721cb597ac29c617",
"version": "1.2.200"
}
},
{
"package": "LoggerAPI",
"repositoryURL": "https://github.com/IBM-Swift/LoggerAPI.git",
"repositoryURL": "https://github.com/Kitura/LoggerAPI.git",
"state": {
"branch": null,
"revision": "3357dd9526cdf9436fa63bb792b669e6efdc43da",
"version": "1.9.0"
"revision": "e82d34eab3f0b05391082b11ea07d3b70d2f65bb",
"version": "1.9.200"
}
},
{
Expand All @@ -78,8 +78,8 @@
"repositoryURL": "https://github.com/IBM-Swift/Swift-JWT.git",
"state": {
"branch": null,
"revision": "0d435423d12e61c0d14adb6d04396c08a6a650f1",
"version": "3.6.1"
"revision": "2f2fc12ae88660e0760b04d9e6c341517b31ad7b",
"version": "3.6.200"
}
},
{
Expand All @@ -91,15 +91,6 @@
"version": "1.4.0"
}
},
{
"package": "SwiftProtobuf",
"repositoryURL": "https://github.com/apple/swift-protobuf.git",
"state": {
"branch": null,
"revision": "0279688c9fc5a40028e1b5bb0cb56534a45a6020",
"version": "1.12.0"
}
},
{
"package": "ZIPFoundation",
"repositoryURL": "https://github.com/weichsel/ZIPFoundation/",
Expand Down
2 changes: 1 addition & 1 deletion DP3TApp/Logic/Config/ConfigResponseBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ConfigResponseBody: UBCodable {
let enterCovidcodeBoxTitle: String
let enterCovidcodeBoxText: String
let enterCovidcodeBoxButtonTitle: String
let infoBox: InfoBox
let infoBox: InfoBox?
let faqEntries: [FAQEntry]

class FAQEntry: UBCodable {
Expand Down
10 changes: 10 additions & 0 deletions DP3TApp/Logic/Helpers/DateFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ extension DateFormatter {
return dateFormatter
}()

private static let dayWithMonthFormatter: DateFormatter = {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd. MMMM YYYY"
return dateFormatter
}()

static func ub_string(from date: Date) -> String {
dateFormatter.string(from: date)
}
Expand All @@ -33,6 +39,10 @@ extension DateFormatter {
dayDateFormatter.string(from: date)
}

static func ub_dayWithMonthString(from date: Date) -> String {
dayWithMonthFormatter.string(from: date)
}

static func ub_daysAgo(from date: Date, addExplicitDate: Bool) -> String {
let days = date.ns_differenceInDaysWithDate(date: Date())

Expand Down
12 changes: 1 addition & 11 deletions DP3TApp/Logic/Tracing/DatabaseSyncer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,7 @@ class DatabaseSyncer {
}
Logger.log("Start Database Sync", appState: true)

let runningInBackground: () -> Bool = {
if Thread.isMainThread {
return UIApplication.shared.applicationState == .background
} else {
return DispatchQueue.main.sync {
UIApplication.shared.applicationState == .background
}
}
}

DP3TTracing.sync(runningInBackground: runningInBackground()) { result in
DP3TTracing.sync { result in
switch result {
case let .failure(e):

Expand Down
2 changes: 1 addition & 1 deletion DP3TApp/Logic/Tracing/LocalPushProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import DP3TSDK
import Foundation

protocol LocalPushProtocol {
func scheduleExposureNotificationsIfNeeded(identifierProvider provider: ExposureIdentifierProvider)
func scheduleExposureNotificationsIfNeeded(provider: ExposureProvider)

func clearNotifications()

Expand Down
4 changes: 3 additions & 1 deletion DP3TApp/Logic/Tracing/Reporting/ReportingManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ class ReportingManager: ReportingManagerProtocol {
// MARK: - Second part: I was exposed

private func sendIWasExposed(token: String, date: Date, isFakeRequest fake: Bool, covidCode: String, completion: @escaping (ReportingProblem?) -> Void) {
DP3TTracing.iWasExposed(onset: date, authentication: .HTTPAuthorizationBearer(token: token), isFakeRequest: fake) { [weak self] result in
DP3TTracing.iWasExposed(onset: date,
authentication: .HTTPAuthorizationHeader(header: "Authorization", value: "Bearer \(token)"),
isFakeRequest: fake) { [weak self] result in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
switch result {
Expand Down
63 changes: 45 additions & 18 deletions DP3TApp/Logic/Tracing/TracingLocalPush.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,33 @@ protocol UserNotificationCenter {

extension UNUserNotificationCenter: UserNotificationCenter {}

protocol ExposureIdentifierProvider {
var exposureIdentifiers: [String]? { get }
struct Exposure: Comparable {
let identifier: String
let date: Date

init(exposureDay: ExposureDay) {
self.init(identifier: exposureDay.identifier.uuidString, date: exposureDay.exposedDate)
}

init(identifier: String, date: Date) {
self.identifier = identifier
self.date = date
}

static func < (lhs: Exposure, rhs: Exposure) -> Bool {
lhs.date < rhs.date
}
}

protocol ExposureProvider {
var exposures: [Exposure]? { get }
}

extension TracingState: ExposureIdentifierProvider {
var exposureIdentifiers: [String]? {
extension TracingState: ExposureProvider {
var exposures: [Exposure]? {
switch infectionStatus {
case let .exposed(matches):
return matches.map { $0.identifier.uuidString }
return matches.map(Exposure.init(exposureDay:))
case .healthy:
return []
case .infected:
Expand All @@ -50,13 +68,28 @@ class TracingLocalPush: NSObject, LocalPushProtocol {
center = notificationCenter
_exposureIdentifiers.keychain = keychain
_scheduledErrorIdentifiers.keychain = keychain
_lastestExposureDate.keychain = keychain
super.init()
center.delegate = self
}

func scheduleExposureNotificationsIfNeeded(identifierProvider provider: ExposureIdentifierProvider) {
if let identifers = provider.exposureIdentifiers {
exposureIdentifiers = identifers
func scheduleExposureNotificationsIfNeeded(provider: ExposureProvider) {
// sort the exposures from newset to oldest
if let exposures = provider.exposures?.sorted(by: >) {
for exposure in exposures {
// check if the exposure is new and if the latesExposureDate is prior to the new Exposure
// we only schedule the notification in these cases
if !exposureIdentifiers.contains(exposure.identifier), (lastestExposureDate ?? .distantPast) < exposure.date {
// we schedule the notification
scheduleNotification(identifier: exposure.identifier)
// and update the latestExpsoureDate
lastestExposureDate = exposure.date

break
}
}
// store all new identifiers
exposureIdentifiers = exposures.map(\.identifier)
}
}

Expand All @@ -68,17 +101,11 @@ class TracingLocalPush: NSObject, LocalPushProtocol {
.init()
}

@KeychainPersisted(key: "lastestExposureDate", defaultValue: nil)
private var lastestExposureDate: Date?

@KeychainPersisted(key: "exposureIdentifiers", defaultValue: [])
private var exposureIdentifiers: [String] {
didSet {
for identifier in exposureIdentifiers {
if !oldValue.contains(identifier) {
scheduleNotification(identifier: identifier)
return
}
}
}
}
private var exposureIdentifiers: [String]

@KeychainPersisted(key: "scheduledErrorIdentifiers", defaultValue: [])
private var scheduledErrorIdentifiers: [ErrorIdentifiers]
Expand Down
Loading

0 comments on commit 3870b55

Please sign in to comment.