bulltrackers-module 1.0.596 → 1.0.597
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.
|
@@ -510,23 +510,6 @@ const fetchUserVerificationData = async (firestore, userId) => {
|
|
|
510
510
|
const docRef = firestore.collection('SignedInUsers').doc(userId).collection('verification').doc('data');
|
|
511
511
|
const docSnapshot = await docRef.get();
|
|
512
512
|
if (!docSnapshot.exists) {
|
|
513
|
-
// Attempt migration from old location
|
|
514
|
-
const oldCollectionRef = firestore.collection('signedInUsers');
|
|
515
|
-
const oldSnapshot = await oldCollectionRef.get();
|
|
516
|
-
for (const doc of oldSnapshot.docs) {
|
|
517
|
-
const data = doc.data();
|
|
518
|
-
if (data.etoroCID && String(data.etoroCID) === String(userId)) {
|
|
519
|
-
// Found old data, migrate it
|
|
520
|
-
await docRef.set({
|
|
521
|
-
...data,
|
|
522
|
-
migratedFromId: doc.id // Store old firestore ID
|
|
523
|
-
});
|
|
524
|
-
// Delete old document
|
|
525
|
-
await oldCollectionRef.doc(doc.id).delete();
|
|
526
|
-
return { id: doc.id, ...data, migratedFromId: doc.id };
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
// No data found
|
|
530
513
|
throw new Error(`Verification data for User ID ${userId} not found`);
|
|
531
514
|
}
|
|
532
515
|
return { id: docSnapshot.id, ...docSnapshot.data() };
|
|
@@ -1517,19 +1500,7 @@ const finalizeVerification = async (db, pubsub, userId, username) => {
|
|
|
1517
1500
|
isOptOut
|
|
1518
1501
|
});
|
|
1519
1502
|
|
|
1520
|
-
// 2. Create/Update
|
|
1521
|
-
// Note: We use the realCID as the document ID, matching the generic-api logic
|
|
1522
|
-
await db.collection(signedInUsersCollection).doc(String(realCID)).set({
|
|
1523
|
-
username: profileData.username,
|
|
1524
|
-
cid: realCID,
|
|
1525
|
-
fullName: `${profileData.firstName || ''} ${profileData.lastName || ''}`.trim(),
|
|
1526
|
-
avatar: profileData.avatars?.find(a => a.type === 'Original')?.url || null,
|
|
1527
|
-
isOptOut,
|
|
1528
|
-
verifiedAt: FieldValue.serverTimestamp(),
|
|
1529
|
-
lastLogin: FieldValue.serverTimestamp()
|
|
1530
|
-
}, { merge: true });
|
|
1531
|
-
|
|
1532
|
-
// 3. Create/Update verification data in new format location: /SignedInUsers/{cid}/verification/data
|
|
1503
|
+
// 2. Create/Update verification data in new format location: /SignedInUsers/{cid}/verification/data
|
|
1533
1504
|
const verificationDataRef = db.collection('SignedInUsers').doc(String(realCID)).collection('verification').doc('data');
|
|
1534
1505
|
const existingVerificationDoc = await verificationDataRef.get();
|
|
1535
1506
|
|