@stackedapp/utils 2.21.0 → 2.23.0
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.
- package/dist/conditions/handlers.js +39 -4
- package/package.json +1 -1
|
@@ -359,14 +359,15 @@ function evaluateDynamic(cond, ctx) {
|
|
|
359
359
|
}],
|
|
360
360
|
};
|
|
361
361
|
}
|
|
362
|
+
const AUTH_PLATFORM_DISPLAY_NAMES = {
|
|
363
|
+
sms: 'SMS', email: 'Email', apple: 'Apple', google: 'Google',
|
|
364
|
+
tiktok: 'TikTok', twitter: 'X/Twitter',
|
|
365
|
+
};
|
|
362
366
|
function evaluateIdentifiers(cond, ctx) {
|
|
363
367
|
const playerPlatforms = new Set(ctx.snap.identifiers?.map((i) => i.platform.toLowerCase()) || []);
|
|
364
368
|
const platformsToCheck = cond.platforms;
|
|
365
|
-
const platformsMap = {
|
|
366
|
-
sms: 'SMS', email: 'Email', apple: 'Apple', google: 'Google', tiktok: 'TikTok',
|
|
367
|
-
};
|
|
368
369
|
const metPlatforms = platformsToCheck.filter((p) => playerPlatforms.has(p.toLowerCase()));
|
|
369
|
-
const platforms = platformsToCheck.map((p) =>
|
|
370
|
+
const platforms = platformsToCheck.map((p) => AUTH_PLATFORM_DISPLAY_NAMES[p.toLowerCase()] ?? p);
|
|
370
371
|
let isMet;
|
|
371
372
|
let displayText;
|
|
372
373
|
let percentCompleted;
|
|
@@ -493,6 +494,40 @@ function evaluateStackedAccount(cond, ctx) {
|
|
|
493
494
|
text: cond.hasProfilePic ? 'Set a custom profile picture' : 'Must not have a custom profile picture',
|
|
494
495
|
});
|
|
495
496
|
}
|
|
497
|
+
if (cond.authPlatforms && cond.authPlatforms.platforms.length > 0) {
|
|
498
|
+
const playerPlatforms = new Set((ctx.additionalData?.linkedPlatforms || []).map((p) => p.toLowerCase()));
|
|
499
|
+
const platformsToCheck = cond.authPlatforms.platforms;
|
|
500
|
+
const metPlatforms = platformsToCheck.filter((p) => playerPlatforms.has(p.toLowerCase()));
|
|
501
|
+
const platforms = platformsToCheck.map((p) => AUTH_PLATFORM_DISPLAY_NAMES[p.toLowerCase()] ?? p);
|
|
502
|
+
let met;
|
|
503
|
+
let displayText;
|
|
504
|
+
let percentCompleted;
|
|
505
|
+
if (cond.authPlatforms.behaviour === 'AND') {
|
|
506
|
+
met = metPlatforms.length === platformsToCheck.length;
|
|
507
|
+
displayText = platformsToCheck.length > 1
|
|
508
|
+
? `Link your ${(0, helpers_1.formatList)(platforms)} accounts in Stacked`
|
|
509
|
+
: `Link your ${platforms[0]} account in Stacked`;
|
|
510
|
+
percentCompleted = (0, helpers_1.calculatePercent)(metPlatforms.length, platformsToCheck.length, met);
|
|
511
|
+
}
|
|
512
|
+
else if (cond.authPlatforms.behaviour === 'NOT') {
|
|
513
|
+
met = metPlatforms.length === 0;
|
|
514
|
+
displayText = `Must not have ${(0, helpers_1.formatList)(platforms)} linked in Stacked`;
|
|
515
|
+
percentCompleted = met ? 100 : 0;
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
met = platformsToCheck.some((p) => playerPlatforms.has(p.toLowerCase()));
|
|
519
|
+
displayText = `Link any of your ${(0, helpers_1.formatList)(platforms)} accounts in Stacked`;
|
|
520
|
+
percentCompleted = met ? 100 : 0;
|
|
521
|
+
}
|
|
522
|
+
if (!met)
|
|
523
|
+
isMet = false;
|
|
524
|
+
details.push({
|
|
525
|
+
isMet: met, kind: 'stackedAccount',
|
|
526
|
+
trackerAmount: met ? 1 : 0, trackerGoal: 1,
|
|
527
|
+
percentCompleted,
|
|
528
|
+
text: displayText,
|
|
529
|
+
});
|
|
530
|
+
}
|
|
496
531
|
return { isMet, details };
|
|
497
532
|
}
|
|
498
533
|
function evaluateUserSettings(cond, ctx) {
|