bulltrackers-module 1.0.459 → 1.0.460
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.
|
@@ -135,12 +135,34 @@ async function hasUserCopied(db, userCid, piCid, config) {
|
|
|
135
135
|
const userDoc = await db.collection(signedInUsersCollection).doc(String(userCid)).get();
|
|
136
136
|
if (userDoc.exists) {
|
|
137
137
|
const data = userDoc.data();
|
|
138
|
+
|
|
139
|
+
// Check AggregatedMirrors (current copies)
|
|
138
140
|
if (data.AggregatedMirrors && Array.isArray(data.AggregatedMirrors)) {
|
|
139
141
|
const isCopying = data.AggregatedMirrors.some(m => Number(m.ParentCID) === piCidNum);
|
|
140
|
-
if (isCopying)
|
|
142
|
+
if (isCopying) {
|
|
143
|
+
console.log(`[hasUserCopied] Found PI ${piCidNum} in AggregatedMirrors for user ${userCid}`);
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Also check historical mirrors if available
|
|
149
|
+
if (data.snapshots && typeof data.snapshots === 'object') {
|
|
150
|
+
// Check recent snapshots for any copy history
|
|
151
|
+
const snapshotDates = Object.keys(data.snapshots).sort().reverse().slice(0, 30); // Last 30 days
|
|
152
|
+
for (const date of snapshotDates) {
|
|
153
|
+
const snapshot = data.snapshots[date];
|
|
154
|
+
if (snapshot && snapshot.AggregatedMirrors && Array.isArray(snapshot.AggregatedMirrors)) {
|
|
155
|
+
const wasCopying = snapshot.AggregatedMirrors.some(m => Number(m.ParentCID) === piCidNum);
|
|
156
|
+
if (wasCopying) {
|
|
157
|
+
console.log(`[hasUserCopied] Found PI ${piCidNum} in historical snapshot ${date} for user ${userCid}`);
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
141
162
|
}
|
|
142
163
|
}
|
|
143
164
|
|
|
165
|
+
console.log(`[hasUserCopied] User ${userCid} has not copied PI ${piCidNum} (checked computation and portfolio)`);
|
|
144
166
|
return false;
|
|
145
167
|
} catch (error) {
|
|
146
168
|
console.error('[hasUserCopied] Error checking copy status:', error);
|
|
@@ -435,6 +457,8 @@ async function checkReviewEligibility(req, res, dependencies, config) {
|
|
|
435
457
|
|
|
436
458
|
const canReview = await hasUserCopied(db, effectiveCid, piCid, config);
|
|
437
459
|
|
|
460
|
+
logger.log('INFO', `[checkReviewEligibility] User ${effectiveCid} eligibility for PI ${piCid}: ${canReview}`);
|
|
461
|
+
|
|
438
462
|
return res.status(200).json({
|
|
439
463
|
piCid: Number(piCid),
|
|
440
464
|
eligible: canReview,
|