Skip to content

Commit e81522b

Browse files
committed
Privacy tweaks
1 parent 908bb86 commit e81522b

3 files changed

Lines changed: 8 additions & 38 deletions

File tree

functions/utilities/privacy/debugRouter.js

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
acceptedKey,
1010
acceptedByKey,
1111
variantModeKey,
12+
latestTouchKey,
1213
isUnderThirteen,
1314
getPrivacyState,
1415
generateGuardianPrivacyAuthToken,
@@ -35,6 +36,7 @@ const getViewData = (req) => {
3536
acceptedKey,
3637
acceptedByKey,
3738
variantModeKey,
39+
latestTouchKey,
3840
"birthMonth",
3941
"birthYear",
4042
];
@@ -74,6 +76,7 @@ router.post("/reset", studentMiddleware, async (req, res) => {
7476
[acceptedKey]: req.body.acceptedKey || null,
7577
[acceptedByKey]: req.body.acceptedByKey || null,
7678
[variantModeKey]: req.body.variantMode || null,
79+
[latestTouchKey]: req.body.latestTouch || null,
7780
birthMonth: req.body.birthMonth || "1",
7881
birthYear: req.body.birthYear || "2025",
7982
};
@@ -83,44 +86,6 @@ router.post("/reset", studentMiddleware, async (req, res) => {
8386
return res.status(200).send(getResponseBody(req, updateBody));
8487
});
8588

86-
// const bodies = {
87-
// under13_new: {
88-
// birthMonth: "1",
89-
// birthYear: "2025",
90-
// },
91-
// over13_new: {
92-
// birthMonth: "1",
93-
// birthYear: "1990",
94-
// },
95-
// year8webinar_new: {
96-
// birthMonth: "1",
97-
// birthYear: "1990",
98-
// [dueByKey]: Date.now() + 30 * 24 * 60 * 60 * 1000, // 30 days from now
99-
// [variantModeKey]: 'year8webinar',
100-
// },
101-
// year8webinar_31daysago: {
102-
// [firstSeenKey]: Date.now() - 31 * 24 * 60 * 60 * 1000, // first seen was 31 days ago
103-
// [dueByKey]: Date.now() - 24 * 60 * 60 * 1000, // due date was 1 day ago
104-
// birthMonth: "1",
105-
// birthYear: "2025", // Age doesn't matter for this variant
106-
// [variantModeKey]: 'year8webinar',
107-
// },
108-
// under13_8daysago: {
109-
// [firstSeenKey]: Date.now() - 8 * 24 * 60 * 60 * 1000, // first seen was 8 days ago
110-
// [dueByKey]: Date.now() - 24 * 60 * 60 * 1000, // due date was 1 day ago
111-
// [userNeedsGuardianTouchKey]: Date.now() - 8 * 24 * 60 * 60 * 1000, // guardian touch was 8 days ago
112-
// [guardianPrivacyAuthTokenKey]: generateGuardianPrivacyAuthToken(),
113-
// birthMonth: "1",
114-
// birthYear: "2025",
115-
// },
116-
// over13_8daysago: {
117-
// [firstSeenKey]: Date.now() - 8 * 24 * 60 * 60 * 1000, // first seen was 8 days ago
118-
// [dueByKey]: Date.now() - 24 * 60 * 60 * 1000, // due date was 1 day ago
119-
// birthMonth: "1",
120-
// birthYear: "1990",
121-
// }
122-
// }
123-
12489
router.get("/view", studentMiddleware, async (req, res) => {
12590
return res.status(200).send({ data: getViewData(req) });
12691
});

functions/utilities/privacy/router.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
guardianPrivacyAuthTokenKey,
1010
acceptedKey,
1111
acceptedByKey,
12+
latestTouchKey,
1213
validateGuardianToken,
1314
} = require("./utils");
1415
const debugRouter = require("./debugRouter");
@@ -117,6 +118,7 @@ router.get("/student/delay", studentMiddleware, async (req, res) => {
117118
const updateBody = {
118119
[firstSeenKey]: req.user[firstSeenKey] || Date.now(),
119120
[dueByKey]: req.user[dueByKey] || Date.now() + SevenDays,
121+
[latestTouchKey]: Date.now(),
120122
};
121123

122124
await userDB.doc(req.user.uid).update(updateBody);
@@ -146,6 +148,7 @@ router.post("/student/update", studentMiddleware, async (req, res) => {
146148
req.user[userNeedsGuardianTouchKey] || Date.now(),
147149
[firstSeenKey]: req.user[firstSeenKey] || Date.now(),
148150
[dueByKey]: req.user[dueByKey] || Date.now() + SevenDays,
151+
[latestTouchKey]: Date.now(),
149152
};
150153

151154
await userDB.doc(req.user.uid).update(updateBody);

functions/utilities/privacy/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function generateGuardianPrivacyAuthToken() {
1212
const latestPrivacyVersion = "privacy-testing-002";
1313

1414
const firstSeenKey = `${latestPrivacyVersion}-firstSeen`;
15+
const latestTouchKey = `${latestPrivacyVersion}-latestTouch`;
1516
const dueByKey = `${latestPrivacyVersion}-dueBy`;
1617
const userNeedsGuardianTouchKey = `${latestPrivacyVersion}-ng-touch`;
1718
const guardianPrivacyAuthTokenKey = "guardianPrivacyAuthToken";
@@ -150,3 +151,4 @@ exports.validateGuardianToken = validateGuardianToken;
150151
exports.userNeedsGuardianTouchKey = userNeedsGuardianTouchKey;
151152
exports.isUnderThirteen = isUnderThirteen;
152153
exports.variantModeKey = variantModeKey;
154+
exports.latestTouchKey = latestTouchKey;

0 commit comments

Comments
 (0)