From 7d0ecadd4388b663fe2039a8fd28915fa14000d2 Mon Sep 17 00:00:00 2001 From: Guillaume Cauchois Date: Tue, 24 Sep 2024 13:53:03 +0200 Subject: [PATCH 1/5] fix(Messaging): report mail binder reporter reported was inverted --- src/user-profiles/user-profiles.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/user-profiles/user-profiles.service.ts b/src/user-profiles/user-profiles.service.ts index c61dfcd4..7e34058b 100644 --- a/src/user-profiles/user-profiles.service.ts +++ b/src/user-profiles/user-profiles.service.ts @@ -643,8 +643,8 @@ export class UserProfilesService { ), this.mailsService.sendUserReportedMail( report, - userReporter, - userReported + userReported, + userReporter ), ]); } From 03c73937cc4880a790bba102ae42b6a392c06d16 Mon Sep 17 00:00:00 2001 From: "Dorian P." Date: Tue, 24 Sep 2024 15:54:03 +0200 Subject: [PATCH 2/5] Added variables (#208) --- src/mails/mails.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mails/mails.service.ts b/src/mails/mails.service.ts index 9ddabd16..c27c1e83 100644 --- a/src/mails/mails.service.ts +++ b/src/mails/mails.service.ts @@ -128,7 +128,11 @@ export class MailsService { { toEmail: user.email, templateId: MailjetTemplates.ONBOARDING_J3_PROFILE_COMPLETION, - variables: { firstName: user.firstName }, + variables: { + firstName: user.firstName, + role: getRoleString(user), + zone: user.zone, + }, }, { //trois jours après la création du compte From b7c996f2ad661c3c7f2730332c604714386caedd Mon Sep 17 00:00:00 2001 From: Dorian Date: Tue, 24 Sep 2024 16:48:25 +0200 Subject: [PATCH 3/5] v2.26.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1db958a9..34c14428 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "linkedout-backend", - "version": "2.25.6", + "version": "2.26.0", "license": "ISC", "engines": { "node": "18.x" From 4ea58d2aab7f8b9801f800a446b5d6e2bd0588e4 Mon Sep 17 00:00:00 2001 From: Guillaume Cauchois Date: Wed, 25 Sep 2024 13:37:40 +0200 Subject: [PATCH 4/5] refacto(cv-pdf): remove useless isTwoPages params --- src/cvs/cvs.controller.ts | 26 +++----------------- src/cvs/cvs.service.ts | 8 ++---- src/queues/consumers/work-queue.processor.ts | 3 +-- src/queues/queues.types.ts | 1 - 4 files changed, 7 insertions(+), 31 deletions(-) diff --git a/src/cvs/cvs.controller.ts b/src/cvs/cvs.controller.ts index dcc86303..1d3ce935 100644 --- a/src/cvs/cvs.controller.ts +++ b/src/cvs/cvs.controller.ts @@ -34,7 +34,7 @@ import { UserRoles, } from 'src/users/users.types'; import { isRoleIncluded } from 'src/users/users.utils'; -import { AdminZone, FilterParams } from 'src/utils/types'; +import { FilterParams } from 'src/utils/types'; import { CVsService } from './cvs.service'; import { CVFilterKey } from './cvs.types'; import { getPDFPaths } from './cvs.utils'; @@ -60,7 +60,6 @@ export class CVsController { @UserPayload() user: User, @UserPayload('id', new ParseUUIDPipe()) userId: string, @UserPayload('role') role: UserRole, - @UserPayload('zone') zone: AdminZone, @Param('candidateId', new ParseUUIDPipe()) candidateId: string, @Body('cv', new ParseCVPipe()) createCVDto: CreateCVDto, @Body('autoSave') autoSave: boolean, @@ -147,28 +146,17 @@ export class CVsController { const token = getTokenFromHeaders(req); - let isTwoPages = false; - - if ( - (createCVDto.experiences?.length || 0) + - (createCVDto.formations?.length || 0) > - 4 - ) { - isTwoPages = true; - } - // génération du CV en version PDF; exécution par lambda AWS await this.cvsService.sendGenerateCVPDF( candidateId, token, - `${firstName}_${lastName}`, - isTwoPages + `${firstName}_${lastName}` ); } return createdCV; } - /* + /* récupérer une liste de CVs publiés aléatoirement pour la gallerie */ @Public() @@ -216,17 +204,11 @@ export class CVsController { const pdfUrl = await this.cvsService.findPDF(s3Key); - const cv = await this.cvsService.findOneByCandidateId(candidateId); - - let isTwoPages = false; - if (cv.experiences?.length + cv.formations?.length > 4) isTwoPages = true; - if (!pdfUrl) { const createdPdfUrl = await this.cvsService.generatePDFFromCV( candidateId, getTokenFromHeaders(req), - fileName, - isTwoPages + fileName ); return { pdfUrl: createdPdfUrl, diff --git a/src/cvs/cvs.service.ts b/src/cvs/cvs.service.ts index 458afff2..b55fd406 100644 --- a/src/cvs/cvs.service.ts +++ b/src/cvs/cvs.service.ts @@ -657,8 +657,7 @@ export class CVsService { async generatePDFFromCV( candidateId: string, token: string, - /*paths: string[],*/ fileName: string, - isTwoPages: boolean + fileName: string ) { const response = await fetch(`${process.env.CV_PDF_GENERATION_AWS_URL}`, { headers: { @@ -670,7 +669,6 @@ export class CVsService { candidateId, token, fileName, - isTwoPages, }), }); @@ -1108,14 +1106,12 @@ export class CVsService { async sendGenerateCVPDF( candidateId: string, token: string, - fileName: string, - isTwoPages: boolean + fileName: string ) { await this.queuesService.addToWorkQueue(Jobs.GENERATE_CV_PDF, { candidateId, token, fileName, - isTwoPages, }); } diff --git a/src/queues/consumers/work-queue.processor.ts b/src/queues/consumers/work-queue.processor.ts index 8bc9aa38..dd668003 100644 --- a/src/queues/consumers/work-queue.processor.ts +++ b/src/queues/consumers/work-queue.processor.ts @@ -321,8 +321,7 @@ export class WorkQueueProcessor { await this.cvsService.generatePDFFromCV( data.candidateId, data.token, - data.fileName, - data.isTwoPages + data.fileName ); await this.pusherService.sendEvent( diff --git a/src/queues/queues.types.ts b/src/queues/queues.types.ts index cf65f71c..136d5d97 100644 --- a/src/queues/queues.types.ts +++ b/src/queues/queues.types.ts @@ -126,7 +126,6 @@ export interface GenerateCVPDFJob { candidateId: string; token: string; fileName: string; - isTwoPages: boolean; } export interface GenerateCVPreviewJob { From 7cb7ae66cd007f50b771dfbef3ef1e0a0f1f2634 Mon Sep 17 00:00:00 2001 From: "Dorian P." Date: Thu, 26 Sep 2024 16:02:04 +0200 Subject: [PATCH 5/5] [EN-7243] Sending gender to SF (#207) * Sending gender to SF - WIP error * ??? * Removed comments --- .../external-databases.service.ts | 19 +++++++++++++++++++ .../salesforce/salesforce.service.ts | 6 ++++++ .../salesforce/salesforce.types.ts | 4 ++++ .../salesforce/salesforce.utils.ts | 2 ++ src/queues/consumers/work-queue.processor.ts | 1 + src/queues/queues.types.ts | 2 ++ .../users-creation.controller.ts | 1 + src/users-creation/users-creation.service.ts | 1 + 8 files changed, 36 insertions(+) diff --git a/src/external-databases/external-databases.service.ts b/src/external-databases/external-databases.service.ts index 8679b24e..341f274c 100644 --- a/src/external-databases/external-databases.service.ts +++ b/src/external-databases/external-databases.service.ts @@ -1,7 +1,9 @@ import { Injectable } from '@nestjs/common'; import { CreateUserRegistrationDto } from '../users-creation/dto'; +import { CandidateGender, CandidateGenders } from 'src/contacts/contacts.types'; import { QueuesService } from 'src/queues/producers/queues.service'; import { Jobs } from 'src/queues/queues.types'; +import { Genders } from 'src/users/users.types'; @Injectable() export class ExternalDatabasesService { @@ -50,13 +52,30 @@ export class ExternalDatabasesService { | 'workingExperience' | 'jobSearchDuration' | 'workingRight' + | 'gender' > ) { + let conertedGenderType: CandidateGender; + switch (otherInfo.gender) { + case Genders.MALE: + conertedGenderType = CandidateGenders.MALE; + break; + case Genders.FEMALE: + conertedGenderType = CandidateGenders.FEMALE; + break; + case Genders.OTHER: + conertedGenderType = CandidateGenders.OTHER; + break; + default: + throw new Error('Invalid gender value'); + } + await this.queuesService.addToWorkQueue( Jobs.CREATE_OR_UPDATE_SALESFORCE_USER, { userId, ...otherInfo, + gender: conertedGenderType, } ); } diff --git a/src/external-services/salesforce/salesforce.service.ts b/src/external-services/salesforce/salesforce.service.ts index f88887ae..352c60c8 100644 --- a/src/external-services/salesforce/salesforce.service.ts +++ b/src/external-services/salesforce/salesforce.service.ts @@ -5,6 +5,7 @@ import moment from 'moment-timezone'; import { CandidateAccommodation, + CandidateGender, CandidateResource, CandidateYesNoNSPPValue, JobSearchDuration, @@ -1190,6 +1191,7 @@ export class SalesforceService { workingExperience, workingRight, jobSearchDuration, + gender, }: UserProps) { const contactSf = await this.findContact(email); let contactSfId = contactSf?.Id; @@ -1220,6 +1222,7 @@ export class SalesforceService { workingExperience, jobSearchDuration, workingRight, + gender, }; const leadSfId = (await this.findOrCreateLead( @@ -1283,6 +1286,7 @@ export class SalesforceService { studiesLevel, workingExperience, jobSearchDuration, + gender, }; contactSfId = (await this.createContact( @@ -1813,6 +1817,7 @@ export class SalesforceService { studiesLevel?: StudiesLevel; workingExperience?: WorkingExperience; jobSearchDuration?: JobSearchDuration; + gender?: CandidateGender; } ) { this.setIsWorker(true); @@ -1832,6 +1837,7 @@ export class SalesforceService { studiesLevel: otherInfo.studiesLevel, workingExperience: otherInfo.workingExperience, jobSearchDuration: otherInfo.jobSearchDuration, + gender: otherInfo.gender, }); } diff --git a/src/external-services/salesforce/salesforce.types.ts b/src/external-services/salesforce/salesforce.types.ts index a4d0e4ac..79135e10 100644 --- a/src/external-services/salesforce/salesforce.types.ts +++ b/src/external-services/salesforce/salesforce.types.ts @@ -609,6 +609,7 @@ export interface ContactProps { studiesLevel?: StudiesLevel; workingExperience?: WorkingExperience; jobSearchDuration?: JobSearchDuration; + gender?: CandidateGender; } export interface SalesforceContact { @@ -634,6 +635,7 @@ export interface SalesforceContact { Dur_e_de_recherche_d_emploi__c: string; Situation_d_h_bergement__c: string; Type_de_ressources__c?: string; + Genre__c: string; } export interface CompanyLeadProps { @@ -861,6 +863,7 @@ export interface CoachSalesforceLead { RecordTypeId: LeadRecordType; Antenne__c: string; Source__c: 'Lead entrant'; + Genre__c: CandidateGender | null; } export interface UserProps { @@ -882,4 +885,5 @@ export interface UserProps { studiesLevel?: StudiesLevel; workingExperience?: WorkingExperience; jobSearchDuration?: JobSearchDuration; + gender?: CandidateGender; } diff --git a/src/external-services/salesforce/salesforce.utils.ts b/src/external-services/salesforce/salesforce.utils.ts index 5525d71e..875c0a46 100644 --- a/src/external-services/salesforce/salesforce.utils.ts +++ b/src/external-services/salesforce/salesforce.utils.ts @@ -618,6 +618,7 @@ export const mapSalesforceContactFields = ( studiesLevel, workingExperience, jobSearchDuration, + gender, }: ContactProps, recordType: ContactRecordType ): SalesforceContact => { @@ -667,6 +668,7 @@ export const mapSalesforceContactFields = ( resources, LeadResources ), + Genre__c: formatSalesforceValue(gender, LeadGender), }; }; diff --git a/src/queues/consumers/work-queue.processor.ts b/src/queues/consumers/work-queue.processor.ts index dd668003..773794ab 100644 --- a/src/queues/consumers/work-queue.processor.ts +++ b/src/queues/consumers/work-queue.processor.ts @@ -433,6 +433,7 @@ export class WorkQueueProcessor { workingExperience: data.workingExperience, jobSearchDuration: data.jobSearchDuration, workingRight: data.workingRight, + gender: data.gender, }); return `Salesforce : created or updated user '${data.userId}'`; } diff --git a/src/queues/queues.types.ts b/src/queues/queues.types.ts index 136d5d97..6587b746 100644 --- a/src/queues/queues.types.ts +++ b/src/queues/queues.types.ts @@ -2,6 +2,7 @@ import { BusinessLine } from 'src/common/business-lines/models'; import { Location } from 'src/common/locations/models'; import { CandidateAccommodation, + CandidateGender, CandidateResource, CandidateYesNoNSPPValue, JobSearchDuration, @@ -164,6 +165,7 @@ export interface CreateOrUpdateSalesforceUserJob { workingExperience?: WorkingExperience; jobSearchDuration?: JobSearchDuration; workingRight?: CandidateYesNoNSPPValue; + gender?: CandidateGender; } export interface SendOffersEmailAfterCVPublishJob { diff --git a/src/users-creation/users-creation.controller.ts b/src/users-creation/users-creation.controller.ts index bf5cc1ad..4c103d71 100644 --- a/src/users-creation/users-creation.controller.ts +++ b/src/users-creation/users-creation.controller.ts @@ -231,6 +231,7 @@ export class UsersCreationController { studiesLevel: createUserRegistrationDto.studiesLevel, workingExperience: createUserRegistrationDto.workingExperience, jobSearchDuration: createUserRegistrationDto.jobSearchDuration, + gender: createUserRegistrationDto.gender, }); if (createUserRegistrationDto.program === Programs.BOOST) { diff --git a/src/users-creation/users-creation.service.ts b/src/users-creation/users-creation.service.ts index 0df23666..4772aa54 100644 --- a/src/users-creation/users-creation.service.ts +++ b/src/users-creation/users-creation.service.ts @@ -40,6 +40,7 @@ export class UsersCreationService { | 'workingExperience' | 'jobSearchDuration' | 'workingRight' + | 'gender' > ) { return this.externalDatabasesService.createExternalDBUser(