Skip to content

Commit

Permalink
Merge pull request #54 from CrunchyBagel/feat/apple_framework
Browse files Browse the repository at this point in the history
Feat/apple framework
  • Loading branch information
HendX committed Apr 30, 2020
2 parents 7f323ea + 0cb8ea3 commit ce38301
Show file tree
Hide file tree
Showing 18 changed files with 593 additions and 281 deletions.
6 changes: 6 additions & 0 deletions KeyServer/KeyServer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ paths:
type: integer
example: 1234
description: The rolling start number for the key.
l:
type: integer
description: Represents the calculated risk level from 1-100
deleted_keys:
description: |
A list of keys that have subsequently been marked as not infected. Client should remove them from their cache.
Expand Down Expand Up @@ -214,6 +217,9 @@ paths:
type: integer
example: 1234
description: The rolling start number for the key.
l:
type: integer
description: Represents the calculated risk level from 1-100
form:
type: array
description: Additional form data gathered from user. Each item
Expand Down
8 changes: 5 additions & 3 deletions KeyServer/sample/htdocs/infected.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}
}

$stmt = $db->prepare('SELECT infected_key, rolling_start_number FROM infected_keys WHERE status = :s AND status_updated >= :t');
$stmt = $db->prepare('SELECT infected_key, rolling_start_number, risk_level FROM infected_keys WHERE status = :s AND status_updated >= :t');
$stmt->bindValue(':t', $time, SQLITE3_INTEGER);
$stmt->bindValue(':s', 'A', SQLITE3_TEXT);

Expand All @@ -48,15 +48,17 @@
while (($row = $result->fetchArray(SQLITE3_NUM))) {
$keys[] = array(
'd' => base64_decode($row[0]),
'r' => (int) $row[1]
'r' => (int) $row[1],
'l' => (int) $row[2]
);
}
}
else {
while (($row = $result->fetchArray(SQLITE3_NUM))) {
$keys[] = array(
'd' => $row[0],
'r' => (int) $row[1]
'r' => (int) $row[1],
'l' => (int) $row[2]
);
}
}
Expand Down
6 changes: 5 additions & 1 deletion KeyServer/sample/htdocs/submit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
require_once('shared.php');

// TODO: Handle additional form data

if (!isValidBearer($db)) {
sendJsonErrorResponse(401, 'Invalid bearer token');
exit;
Expand Down Expand Up @@ -43,15 +45,17 @@

$submissionId = $db->lastInsertRowID();

$stmt = $db->prepare('INSERT INTO infected_keys (infected_key, rolling_start_number, timestamp, status, status_updated, submission_id) VALUES (:k, :r, :t, :s, :d, :i)');
$stmt = $db->prepare('INSERT INTO infected_keys (infected_key, rolling_start_number, risk_level, timestamp, status, status_updated, submission_id) VALUES (:k, :r, :l, :t, :s, :d, :i)');

// It's possible there are no keys with a submission, and a placeholder record is created so subsequent keys can be recorded
foreach ($json['keys'] as $key) {
$encodedKey = $key['d'];
$rollingStartNumber = $key['r'];
$riskLevel = $key['l'];

$stmt->bindValue(':k', $encodedKey, SQLITE3_TEXT);
$stmt->bindValue(':r', $rollingStartNumber, SQLITE3_INTEGER);
$stmt->bindValue(':l', $riskLevel, SQLITE3_INTEGER);
$stmt->bindValue(':t', $time, SQLITE3_INTEGER);
$stmt->bindValue(':s', 'P', SQLITE3_TEXT); // Pending state, must be approved
$stmt->bindValue(':d', $time, SQLITE3_INTEGER);
Expand Down
1 change: 1 addition & 0 deletions KeyServer/sample/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CREATE INDEX infected_key_submissions_timestamp ON infected_key_submissions (tim
CREATE TABLE infected_keys (
infected_key STRING,
rolling_start_number INTEGER,
risk_level INTEGER,
status TEXT,
timestamp INTEGER,
status_updated INTEGER,
Expand Down
12 changes: 11 additions & 1 deletion TracePrivately.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
6614BB052452B9D900885F23 /* ExposureDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6614BB042452B9D900885F23 /* ExposureDetailsViewController.swift */; };
6621056D245251B10011EB42 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6621056C245251B10011EB42 /* main.swift */; };
6621057124525FC90011EB42 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6621057324525FC90011EB42 /* Localizable.strings */; };
663BD8B9245A510C00A3E029 /* ExposureDataTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 663BD8B8245A510C00A3E029 /* ExposureDataTypes.swift */; };
66437F76244A86AE000B8C6C /* Disease.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66437F75244A86AE000B8C6C /* Disease.swift */; };
66437F9E244A9A02000B8C6C /* TracePrivately.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 66437F9C244A9A02000B8C6C /* TracePrivately.xcdatamodeld */; };
66437FA0244A9B2C000B8C6C /* DataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66437F9F244A9B2C000B8C6C /* DataManager.swift */; };
Expand Down Expand Up @@ -93,6 +94,9 @@
662105782452602D0011EB42 /* hi-IN */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "hi-IN"; path = "hi-IN.lproj/Localizable.strings"; sourceTree = "<group>"; };
6625219B2453955F00C68AD1 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
6625219C2453957100C68AD1 /* sr-RS */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "sr-RS"; path = "sr-RS.lproj/Localizable.strings"; sourceTree = "<group>"; };
663BD8B7245A3F8100A3E029 /* TracePrivately.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TracePrivately.entitlements; sourceTree = "<group>"; };
663BD8B8245A510C00A3E029 /* ExposureDataTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExposureDataTypes.swift; sourceTree = "<group>"; };
663BD8BA245A537900A3E029 /* Model 8.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Model 8.xcdatamodel"; sourceTree = "<group>"; };
66437F75244A86AE000B8C6C /* Disease.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Disease.swift; sourceTree = "<group>"; };
66437F9D244A9A02000B8C6C /* Model.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model.xcdatamodel; sourceTree = "<group>"; };
66437F9F244A9B2C000B8C6C /* DataManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -188,6 +192,7 @@
66CB7BD02453D51A0044D32B /* ENMockFramework.swift */,
66437F75244A86AE000B8C6C /* Disease.swift */,
66437F9F244A9B2C000B8C6C /* DataManager.swift */,
663BD8B8245A510C00A3E029 /* ExposureDataTypes.swift */,
668CE842244D01F50065960A /* ContactTraceManager.swift */,
66C4BBC424564B56008AACC2 /* ExposureNotificationConfig.swift */,
66CB95BC244FB51000D775B6 /* ActionButton.swift */,
Expand Down Expand Up @@ -244,6 +249,7 @@
66F818692448FD5C0043AC2D /* TracePrivately */ = {
isa = PBXGroup;
children = (
663BD8B7245A3F8100A3E029 /* TracePrivately.entitlements */,
39BD8847244C6CF000EB8B6C /* Storyboards */,
66437F77244A8A4C000B8C6C /* Classes */,
66F818732448FD5E0043AC2D /* Assets.xcassets */,
Expand Down Expand Up @@ -386,6 +392,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
663BD8B9245A510C00A3E029 /* ExposureDataTypes.swift in Sources */,
66793892245460B600868B84 /* KeyServer.swift in Sources */,
66848C2D244D5F8800497D2A /* AsyncBlockOperation.swift in Sources */,
66EAEB62244DA72E0044FF70 /* SubmitInfectionViewController.swift in Sources */,
Expand Down Expand Up @@ -630,6 +637,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = TracePrivately/TracePrivately.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = CHZS3BHM57;
INFOPLIST_FILE = TracePrivately/Info.plist;
Expand All @@ -651,6 +659,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = TracePrivately/TracePrivately.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = CHZS3BHM57;
INFOPLIST_FILE = TracePrivately/Info.plist;
Expand Down Expand Up @@ -702,6 +711,7 @@
66437F9C244A9A02000B8C6C /* TracePrivately.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
663BD8BA245A537900A3E029 /* Model 8.xcdatamodel */,
664C5236245802C9003EBE63 /* Model 7.xcdatamodel */,
66BF646624578E2B00492070 /* Model 6.xcdatamodel */,
66CB7BD22453EB190044D32B /* Model 5.xcdatamodel */,
Expand All @@ -710,7 +720,7 @@
668D4B22244D705100D90C26 /* Model 2.xcdatamodel */,
66437F9D244A9A02000B8C6C /* Model.xcdatamodel */,
);
currentVersion = 664C5236245802C9003EBE63 /* Model 7.xcdatamodel */;
currentVersion = 663BD8BA245A537900A3E029 /* Model 8.xcdatamodel */;
path = TracePrivately.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
Expand Down

0 comments on commit ce38301

Please sign in to comment.