@programisto/edrm-exams 0.3.17 → 0.3.18
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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retourne la base du lien d'invitation au test technique (portail candidat).
|
|
3
|
+
* Utilise la config de l'entité (testInvitationLink) ou dérive depuis domain/domains.
|
|
4
|
+
* Fallback : process.env.TEST_INVITATION_LINK (ex. https://app.programisto.fr/magic?email=).
|
|
5
|
+
*/
|
|
6
|
+
export declare function getTestInvitationLinkBase(entity: {
|
|
7
|
+
config?: Record<string, string>;
|
|
8
|
+
domain?: string;
|
|
9
|
+
domains?: string[];
|
|
10
|
+
} | null | undefined): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retourne la base du lien d'invitation au test technique (portail candidat).
|
|
3
|
+
* Utilise la config de l'entité (testInvitationLink) ou dérive depuis domain/domains.
|
|
4
|
+
* Fallback : process.env.TEST_INVITATION_LINK (ex. https://app.programisto.fr/magic?email=).
|
|
5
|
+
*/
|
|
6
|
+
export function getTestInvitationLinkBase(entity) {
|
|
7
|
+
if (!entity) {
|
|
8
|
+
return process.env.TEST_INVITATION_LINK || '';
|
|
9
|
+
}
|
|
10
|
+
const config = entity.config;
|
|
11
|
+
if (config && typeof config.testInvitationLink === 'string' && config.testInvitationLink.trim() !== '') {
|
|
12
|
+
const base = config.testInvitationLink.trim();
|
|
13
|
+
return base.includes('?') ? base : `${base}?email=`;
|
|
14
|
+
}
|
|
15
|
+
const domains = entity.domains;
|
|
16
|
+
if (Array.isArray(domains) && domains.length > 0) {
|
|
17
|
+
const appHost = domains.find((d) => String(d).toLowerCase().startsWith('app.'));
|
|
18
|
+
const host = appHost ?? domains[0];
|
|
19
|
+
const base = String(host).toLowerCase().split(':')[0].trim();
|
|
20
|
+
if (base)
|
|
21
|
+
return `https://${base}/magic?email=`;
|
|
22
|
+
}
|
|
23
|
+
const domain = entity.domain;
|
|
24
|
+
if (domain && String(domain).trim() !== '') {
|
|
25
|
+
const base = String(domain).trim().toLowerCase().replace(/^(my\.|jobs\.|api\.)/, '');
|
|
26
|
+
if (base)
|
|
27
|
+
return `https://app.${base}/magic?email=`;
|
|
28
|
+
}
|
|
29
|
+
return process.env.TEST_INVITATION_LINK || '';
|
|
30
|
+
}
|
|
@@ -51,7 +51,8 @@ async function inviteCandidateToTest(payload) {
|
|
|
51
51
|
console.warn('[INVITE_TO_TECHNICAL_TEST] No email for contact');
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
const
|
|
54
|
+
const linkBase = payload.testInvitationLinkBase ?? process.env.TEST_INVITATION_LINK ?? '';
|
|
55
|
+
const testLink = linkBase + email;
|
|
55
56
|
const emailUser = process.env.EMAIL_USER;
|
|
56
57
|
const emailPassword = process.env.EMAIL_PASSWORD;
|
|
57
58
|
const entityIdForMail = payload.entityId != null
|
|
@@ -8,6 +8,7 @@ import Candidate from '../models/candidate.model.js';
|
|
|
8
8
|
import ContactModel from '../models/contact.model.js';
|
|
9
9
|
import { generateLiveMessage } from '../lib/openai.js';
|
|
10
10
|
import { computeScoresByCategory } from '../lib/score-utils.js';
|
|
11
|
+
import { getTestInvitationLinkBase } from '../lib/test-invitation-link.js';
|
|
11
12
|
import { Types } from 'mongoose';
|
|
12
13
|
// Fonction utilitaire pour récupérer le nom du job
|
|
13
14
|
async function getJobName(targetJob) {
|
|
@@ -1505,8 +1506,9 @@ class ExamsRouter extends EnduranceRouter {
|
|
|
1505
1506
|
});
|
|
1506
1507
|
await newResult.save();
|
|
1507
1508
|
const email = contact.email;
|
|
1508
|
-
// Construire le lien d'invitation
|
|
1509
|
-
const
|
|
1509
|
+
// Construire le lien d'invitation (URL de l'entité ou défaut env)
|
|
1510
|
+
const testLinkBase = getTestInvitationLinkBase(req.entity);
|
|
1511
|
+
const testLink = testLinkBase + email;
|
|
1510
1512
|
// Récupérer les credentials d'envoi
|
|
1511
1513
|
const emailUser = process.env.EMAIL_USER;
|
|
1512
1514
|
const emailPassword = process.env.EMAIL_PASSWORD;
|
|
@@ -2302,8 +2304,9 @@ class ExamsRouter extends EnduranceRouter {
|
|
|
2302
2304
|
const email = contact.email;
|
|
2303
2305
|
const emailUser = process.env.EMAIL_USER;
|
|
2304
2306
|
const emailPassword = process.env.EMAIL_PASSWORD;
|
|
2305
|
-
// Construire le lien d'invitation
|
|
2306
|
-
const
|
|
2307
|
+
// Construire le lien d'invitation (URL de l'entité ou défaut env)
|
|
2308
|
+
const testLinkBase = getTestInvitationLinkBase(req.entity);
|
|
2309
|
+
const testLink = testLinkBase + email;
|
|
2307
2310
|
// Envoyer l'email via l'event emitter (entityId pour utiliser le template de l'entité courante)
|
|
2308
2311
|
const entityIdForReinvite = req.entity?._id != null
|
|
2309
2312
|
? (req.entity._id instanceof Types.ObjectId ? req.entity._id : new Types.ObjectId(String(req.entity._id)))
|
|
@@ -2316,6 +2319,8 @@ class ExamsRouter extends EnduranceRouter {
|
|
|
2316
2319
|
emailPassword,
|
|
2317
2320
|
...(entityIdForReinvite && { entityId: entityIdForReinvite }),
|
|
2318
2321
|
data: {
|
|
2322
|
+
firstname: contact.firstname,
|
|
2323
|
+
testName: test?.title || '',
|
|
2319
2324
|
testLink
|
|
2320
2325
|
}
|
|
2321
2326
|
});
|