bulltrackers-module 1.0.680 → 1.0.682
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.
|
@@ -222,21 +222,13 @@ async function processAlertForPI(db, logger, piCid, alertType, computationMetada
|
|
|
222
222
|
async function findSubscriptionsForPI(db, logger, piCid, alertTypeId, computationDate, dependencies = {}) {
|
|
223
223
|
const subscriptions = [];
|
|
224
224
|
|
|
225
|
-
//
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
'NewSectorExposure': 'newSector',
|
|
230
|
-
'PositionInvestedIncrease': 'increasedPositionSize',
|
|
231
|
-
'NewSocialPost': 'newSocialPost',
|
|
232
|
-
// [NEW] Mapping for BehavioralAnomaly
|
|
233
|
-
'BehavioralAnomaly': 'behavioralAnomaly',
|
|
234
|
-
'TestSystemProbe': 'increasedRisk' // Hack: Map to 'increasedRisk' key
|
|
235
|
-
};
|
|
225
|
+
// [DYNAMIC] Get configKey from alertType metadata instead of hardcoded mapping
|
|
226
|
+
// The alertType is passed in dependencies and contains the configKey from computation metadata
|
|
227
|
+
const alertType = dependencies.alertType;
|
|
228
|
+
const configKey = alertType?.configKey;
|
|
236
229
|
|
|
237
|
-
const configKey = computationToConfigKey[alertTypeId];
|
|
238
230
|
if (!configKey) {
|
|
239
|
-
logger.log('WARN', `[findSubscriptionsForPI] No
|
|
231
|
+
logger.log('WARN', `[findSubscriptionsForPI] No configKey found for alert type: ${alertTypeId}`);
|
|
240
232
|
return subscriptions;
|
|
241
233
|
}
|
|
242
234
|
|
|
@@ -264,8 +256,8 @@ async function findSubscriptionsForPI(db, logger, piCid, alertTypeId, computatio
|
|
|
264
256
|
increasedPositionSize: true,
|
|
265
257
|
newSocialPost: true,
|
|
266
258
|
newPositions: true,
|
|
267
|
-
|
|
268
|
-
|
|
259
|
+
behavioralAnomaly: true,
|
|
260
|
+
testSystemProbe: true // Test alerts for developers
|
|
269
261
|
};
|
|
270
262
|
|
|
271
263
|
// Check all developer accounts
|
|
@@ -184,18 +184,24 @@ const fetchPopularInvestorMasterList = async (firestore, userId = null) => {
|
|
|
184
184
|
// 4. Fetch developer overrides data
|
|
185
185
|
// GOAL : Used for allowing a given userID to have special abilities
|
|
186
186
|
// Any userID document given in path /dev_overrides/ like /dev_overrides/29312236, is considered a developer, we want to return a true bool if a given ID is a developer, otherwise return false
|
|
187
|
+
// [FIX] Must check that enabled === true, not just document existence
|
|
187
188
|
|
|
188
189
|
const isDeveloper = async (firestore, userId) => {
|
|
189
190
|
try {
|
|
190
191
|
const docRef = firestore.collection('dev_overrides').doc(userId);
|
|
191
|
-
|
|
192
192
|
const docSnapshot = await docRef.get();
|
|
193
|
-
|
|
193
|
+
|
|
194
|
+
// Check both that document exists AND enabled === true
|
|
195
|
+
if (!docSnapshot.exists) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const data = docSnapshot.data();
|
|
200
|
+
return data?.enabled === true;
|
|
194
201
|
}
|
|
195
202
|
catch (error) {
|
|
196
203
|
console.error(`Error checking developer status: ${error}`);
|
|
197
204
|
throw error;
|
|
198
|
-
|
|
199
205
|
}
|
|
200
206
|
};
|
|
201
207
|
|
|
@@ -47,11 +47,15 @@ router.get('/types', async (req, res, next) => {
|
|
|
47
47
|
// Check if user is a developer
|
|
48
48
|
const isDev = await isDeveloper(db, String(req.targetUserId));
|
|
49
49
|
|
|
50
|
+
logger?.log('INFO', `[GET /alerts/types] User ${req.targetUserId} isDeveloper: ${isDev}, loaded ${alertTypes.length} total alert types`);
|
|
51
|
+
|
|
50
52
|
// Filter out test alerts for non-developers
|
|
51
53
|
const filteredAlertTypes = isDev
|
|
52
54
|
? alertTypes
|
|
53
55
|
: alertTypes.filter(type => !type.isTest);
|
|
54
56
|
|
|
57
|
+
logger?.log('INFO', `[GET /alerts/types] After filtering: ${filteredAlertTypes.length} alert types (removed ${alertTypes.length - filteredAlertTypes.length} test alerts)`);
|
|
58
|
+
|
|
55
59
|
// Format response for frontend
|
|
56
60
|
const formattedTypes = filteredAlertTypes.map(type => ({
|
|
57
61
|
id: type.id,
|