@@ -14,13 +14,8 @@ const {
1414 generateGuardianPrivacyAuthToken,
1515} = require ( "./utils" ) ;
1616
17- // /api/privacy/student/ultra-secret/view
18- // /api/privacy/student/ultra-secret/reset/under13/new
19- // /api/privacy/student/ultra-secret/reset/under13/8daysago
20- // /api/privacy/student/ultra-secret/reset/over13/new
21- // /api/privacy/student/ultra-secret/reset/over13/8daysago
22- // /api/privacy/student/ultra-secret/reset/year8webinar/new
23- // /api/privacy/student/ultra-secret/reset/year8webinar/31daysago
17+ // /api/privacy/student/ultra-secret/view (GET)
18+ // /api/privacy/student/ultra-secret/reset (POST)
2419
2520const userDB = firebase . firestore ( ) . collection ( "users" ) ;
2621
@@ -70,114 +65,61 @@ const getResponseBody = (req, updateBody) => {
7065 } ;
7166} ;
7267
73- router . get ( "/reset/under13/new " , studentMiddleware , async ( req , res ) => {
68+ router . post ( "/reset" , studentMiddleware , async ( req , res ) => {
7469 const updateBody = {
75- [ firstSeenKey ] : null ,
76- [ dueByKey ] : null ,
77- [ guardianPrivacyAuthTokenKey ] : null ,
78- [ userNeedsGuardianTouchKey ] : null ,
79- [ acceptedKey ] : null ,
80- [ acceptedByKey ] : null ,
81- [ variantModeKey ] : null ,
82- birthMonth : "1" ,
83- birthYear : "2025" ,
70+ [ firstSeenKey ] : req . body . firstSeen || null ,
71+ [ dueByKey ] : req . body . dueBy || null ,
72+ [ guardianPrivacyAuthTokenKey ] : req . body . guardianPrivacyAuthToken ? generateGuardianPrivacyAuthToken ( ) : null ,
73+ [ userNeedsGuardianTouchKey ] : req . body . userNeedsGuardianTouch || null ,
74+ [ acceptedKey ] : req . body . acceptedKey || null ,
75+ [ acceptedByKey ] : req . body . acceptedByKey || null ,
76+ [ variantModeKey ] : req . body . variantMode || null ,
77+ birthMonth : req . body . birthMonth || "1" ,
78+ birthYear : req . body . birthYear || "2025" ,
8479 } ;
8580
8681 await userDB . doc ( req . user . uid ) . update ( updateBody ) ;
8782
8883 return res . status ( 200 ) . send ( getResponseBody ( req , updateBody ) ) ;
8984} ) ;
9085
91- router . get ( "/reset/over13/new" , studentMiddleware , async ( req , res ) => {
92- const updateBody = {
93- [ firstSeenKey ] : null ,
94- [ dueByKey ] : null ,
95- [ guardianPrivacyAuthTokenKey ] : null ,
96- [ userNeedsGuardianTouchKey ] : null ,
97- [ acceptedKey ] : null ,
98- [ acceptedByKey ] : null ,
99- [ variantModeKey ] : null ,
100- birthMonth : "1" ,
101- birthYear : "1990" ,
102- } ;
103-
104- await userDB . doc ( req . user . uid ) . update ( updateBody ) ;
105-
106- return res . status ( 200 ) . send ( getResponseBody ( req , updateBody ) ) ;
107- } ) ;
108-
109-
110- router . get ( "/reset/year8webinar/new" , studentMiddleware , async ( req , res ) => {
111- const updateBody = {
112- [ firstSeenKey ] : null ,
113- [ dueByKey ] : Date . now ( ) + 30 * 24 * 60 * 60 * 1000 , // 30 days from now
114- [ guardianPrivacyAuthTokenKey ] : null ,
115- [ userNeedsGuardianTouchKey ] : null ,
116- [ acceptedKey ] : null ,
117- [ acceptedByKey ] : null ,
118- [ variantModeKey ] : 'year8webinar' ,
119- birthMonth : "1" ,
120- birthYear : "1990" ,
121- } ;
122-
123- await userDB . doc ( req . user . uid ) . update ( updateBody ) ;
124-
125- return res . status ( 200 ) . send ( getResponseBody ( req , updateBody ) ) ;
126- } ) ;
127-
128- router . get ( "/reset/year8webinar/31daysago" , studentMiddleware , async ( req , res ) => {
129- const updateBody = {
130- [ firstSeenKey ] : Date . now ( ) - 31 * 24 * 60 * 60 * 1000 , // first seen was 31 days ago
131- [ dueByKey ] : Date . now ( ) - 24 * 60 * 60 * 1000 , // due date was 1 day ago
132- [ userNeedsGuardianTouchKey ] : null ,
133- [ guardianPrivacyAuthTokenKey ] : null ,
134- [ acceptedKey ] : null ,
135- [ acceptedByKey ] : null ,
136- [ variantModeKey ] : 'year8webinar' ,
137- birthMonth : "1" ,
138- birthYear : "2025" , // Age doesn't matter for this variant
139- } ;
140-
141- await userDB . doc ( req . user . uid ) . update ( updateBody ) ;
142-
143- return res . status ( 200 ) . send ( getResponseBody ( req , updateBody ) ) ;
144- } ) ;
145-
146- router . get ( "/reset/under13/8daysago" , studentMiddleware , async ( req , res ) => {
147- const updateBody = {
148- [ firstSeenKey ] : Date . now ( ) - 8 * 24 * 60 * 60 * 1000 , // first seen was 8 days ago
149- [ dueByKey ] : Date . now ( ) - 24 * 60 * 60 * 1000 , // due date was 1 day ago
150- [ userNeedsGuardianTouchKey ] : Date . now ( ) - 8 * 24 * 60 * 60 * 1000 , // guardian touch was 8 days ago
151- [ guardianPrivacyAuthTokenKey ] : generateGuardianPrivacyAuthToken ( ) ,
152- [ acceptedKey ] : null ,
153- [ acceptedByKey ] : null ,
154- [ variantModeKey ] : null ,
155- birthMonth : "1" ,
156- birthYear : "2025" ,
157- } ;
158-
159- await userDB . doc ( req . user . uid ) . update ( updateBody ) ;
160-
161- return res . status ( 200 ) . send ( getResponseBody ( req , updateBody ) ) ;
162- } ) ;
163-
164- router . get ( "/reset/over13/8daysago" , studentMiddleware , async ( req , res ) => {
165- const updateBody = {
166- [ firstSeenKey ] : Date . now ( ) - 8 * 24 * 60 * 60 * 1000 , // first seen was 8 days ago
167- [ dueByKey ] : Date . now ( ) - 24 * 60 * 60 * 1000 , // due date was 1 day ago
168- [ userNeedsGuardianTouchKey ] : null ,
169- [ guardianPrivacyAuthTokenKey ] : null ,
170- [ acceptedKey ] : null ,
171- [ acceptedByKey ] : null ,
172- [ variantModeKey ] : null ,
173- birthMonth : "1" ,
174- birthYear : "1990" ,
175- } ;
176-
177- await userDB . doc ( req . user . uid ) . update ( updateBody ) ;
178-
179- return res . status ( 200 ) . send ( getResponseBody ( req , updateBody ) ) ;
180- } ) ;
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+ // }
181123
182124router . get ( "/view" , studentMiddleware , async ( req , res ) => {
183125 return res . status ( 200 ) . send ( { data : getViewData ( req ) } ) ;
0 commit comments