bulltrackers-module 1.0.560 → 1.0.561

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -170,14 +170,48 @@ async function finalizeVerification(req, res, dependencies, config) {
170
170
  // Send unified request to task engine that handles both portfolio/history AND social data
171
171
  const pubsubUtils = new PubSubUtils(dependencies);
172
172
 
173
+ // Generate a requestId for tracking and to ensure finalizeOnDemandRequest runs
174
+ // This is critical - without requestId, the root data indexer and computations won't be triggered
175
+ const requestId = `signup-${realCID}-${Date.now()}`;
176
+ const { signedInUsersCollection } = config;
177
+
178
+ // Create request tracking document (similar to user sync requests)
179
+ try {
180
+ const requestRef = db.collection('user_sync_requests')
181
+ .doc(String(realCID))
182
+ .collection('requests')
183
+ .doc(requestId);
184
+
185
+ await requestRef.set({
186
+ targetUserCid: realCID,
187
+ username: profileData.username,
188
+ status: 'pending',
189
+ source: 'user_signup',
190
+ requestedAt: FieldValue.serverTimestamp(),
191
+ createdAt: FieldValue.serverTimestamp(),
192
+ metadata: {
193
+ isNewUser: true,
194
+ verificationSource: 'otp_verification'
195
+ }
196
+ });
197
+
198
+ logger.log('INFO', `[Verification] Created request tracking document for ${username} (${realCID}): ${requestId}`);
199
+ } catch (reqError) {
200
+ logger.log('WARN', `[Verification] Failed to create request tracking document: ${reqError.message}`);
201
+ // Continue anyway - the requestId is still set
202
+ }
203
+
173
204
  // Create a unified on-demand request that includes both portfolio and social
174
205
  // The task engine will process both, update root data, then trigger computations
175
206
  const unifiedTask = {
176
207
  type: 'ON_DEMAND_USER_UPDATE', // Matches Task Engine handler
208
+ cid: realCID, // Top-level CID for handler
209
+ username: profileData.username, // Top-level username for handler
210
+ requestId: requestId, // CRITICAL: Required for finalizeOnDemandRequest to run
211
+ source: 'user_signup', // Mark as signup to ensure computations are triggered
177
212
  data: {
178
213
  cid: realCID,
179
214
  username: profileData.username,
180
- source: 'user_signup', // Mark as signup to ensure computations are triggered
181
215
  includeSocial: true, // Flag to include social data fetch
182
216
  since: new Date(Date.now() - (7 * 24 * 60 * 60 * 1000)).toISOString() // Last 7 days for social
183
217
  },
@@ -185,22 +219,26 @@ async function finalizeVerification(req, res, dependencies, config) {
185
219
  onDemand: true,
186
220
  targetCid: realCID, // Optimization: only process this user
187
221
  isNewUser: true, // Flag to add to daily update queue
188
- requestedAt: new Date().toISOString()
222
+ requestedAt: new Date().toISOString(),
223
+ userType: 'SIGNED_IN_USER' // Explicitly set userType for computation selection
189
224
  }
190
225
  };
191
226
 
192
227
  // Only trigger if user is public (has portfolio data)
193
228
  if (!isOptOut) {
194
229
  await pubsubUtils.publish(taskEngineTopic, unifiedTask);
195
- logger.log('INFO', `[Verification] Triggered unified data fetch (portfolio + social) for ${username} (${realCID}) via on-demand topic`);
230
+ logger.log('INFO', `[Verification] Triggered unified data fetch (portfolio + social) for ${username} (${realCID}) via on-demand topic with requestId: ${requestId}`);
196
231
  } else {
197
232
  // For private users, still fetch social data but no portfolio
198
233
  const socialOnlyTask = {
199
234
  type: 'ON_DEMAND_USER_UPDATE',
235
+ cid: realCID,
236
+ username: profileData.username,
237
+ requestId: requestId, // CRITICAL: Required for finalizeOnDemandRequest to run
238
+ source: 'user_signup',
200
239
  data: {
201
240
  cid: realCID,
202
241
  username: profileData.username,
203
- source: 'user_signup',
204
242
  includeSocial: true,
205
243
  portfolioOnly: false, // Skip portfolio for private users
206
244
  since: new Date(Date.now() - (7 * 24 * 60 * 60 * 1000)).toISOString()
@@ -209,11 +247,12 @@ async function finalizeVerification(req, res, dependencies, config) {
209
247
  onDemand: true,
210
248
  targetCid: realCID,
211
249
  isNewUser: true,
212
- requestedAt: new Date().toISOString()
250
+ requestedAt: new Date().toISOString(),
251
+ userType: 'SIGNED_IN_USER' // Explicitly set userType for computation selection
213
252
  }
214
253
  };
215
254
  await pubsubUtils.publish(taskEngineTopic, socialOnlyTask);
216
- logger.log('INFO', `[Verification] Triggered social-only fetch for private user ${username} (${realCID}) via on-demand topic`);
255
+ logger.log('INFO', `[Verification] Triggered social-only fetch for private user ${username} (${realCID}) via on-demand topic with requestId: ${requestId}`);
217
256
  }
218
257
 
219
258
  return res.status(200).json({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.560",
3
+ "version": "1.0.561",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [