Skip to content

Commit bd7c8a8

Browse files
[BUGFIX] Revert la migration des Job/handler PE (PIX-12850)
#9194
2 parents 7967ed8 + fe69b6b commit bd7c8a8

File tree

53 files changed

+223
-309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+223
-309
lines changed

api/src/prescription/campaign-participation/application/pole-emploi-route.js api/lib/application/pole-emploi/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Joi from 'joi';
22

3-
import { erreurDoc } from '../../../shared/infrastructure/open-api-doc/erreur-doc.js';
4-
import { poleEmploiEnvoisDoc } from '../infrastructure/open-api-doc/pole-emploi-sendings-doc.js';
3+
import { poleEmploiEnvoisDoc } from '../../infrastructure/open-api-doc/pole-emploi/envois-doc.js';
4+
import { erreurDoc } from '../../infrastructure/open-api-doc/pole-emploi/erreur-doc.js';
55
import { poleEmploiController } from './pole-emploi-controller.js';
66

77
const register = async function (server) {

api/src/prescription/campaign-participation/application/pole-emploi-controller.js api/lib/application/pole-emploi/pole-emploi-controller.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { UnprocessableEntityError } from '../../../shared/application/http-errors.js';
2-
import * as poleEmploiService from '../domain/services/pole-emploi-service.js';
3-
import { usecases } from '../domain/usecases/index.js';
1+
import * as poleEmploiService from '../../domain/services/pole-emploi-service.js';
2+
import { usecases } from '../../domain/usecases/index.js';
3+
import { UnprocessableEntityError } from '../http-errors.js';
44

55
const getSendings = async function (request, h, dependencies = { poleEmploiService }) {
66
let cursorData;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { AssessmentCompleted } from '../../../../../lib/domain/events/AssessmentCompleted.js';
2-
import { checkEventTypes } from '../../../../../lib/domain/events/check-event-types.js';
3-
import * as httpErrorsHelper from '../../../../../lib/infrastructure/http/errors-helper.js';
4-
import { httpAgent } from '../../../../../lib/infrastructure/http/http-agent.js';
5-
import { monitoringTools } from '../../../../../lib/infrastructure/monitoring-tools.js';
6-
import { PoleEmploiPayload } from '../../infrastructure/externals/PoleEmploiPayload.js';
1+
import { PoleEmploiPayload } from '../../infrastructure/externals/pole-emploi/PoleEmploiPayload.js';
2+
import * as httpErrorsHelper from '../../infrastructure/http/errors-helper.js';
3+
import { httpAgent } from '../../infrastructure/http/http-agent.js';
4+
import * as monitoringTools from '../../infrastructure/monitoring-tools.js';
75
import { PoleEmploiSending } from '../models/PoleEmploiSending.js';
6+
import { AssessmentCompleted } from './AssessmentCompleted.js';
7+
import { checkEventTypes } from './check-event-types.js';
88

99
const eventTypes = [AssessmentCompleted];
1010

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { CampaignParticipationStarted } from '../../../../../lib/domain/events/CampaignParticipationStarted.js';
2-
import { checkEventTypes } from '../../../../../lib/domain/events/check-event-types.js';
3-
import * as httpErrorsHelper from '../../../../../lib/infrastructure/http/errors-helper.js';
4-
import { httpAgent } from '../../../../../lib/infrastructure/http/http-agent.js';
5-
import { monitoringTools } from '../../../../../lib/infrastructure/monitoring-tools.js';
6-
import { PoleEmploiPayload } from '../../infrastructure/externals/PoleEmploiPayload.js';
1+
import { PoleEmploiPayload } from '../../infrastructure/externals/pole-emploi/PoleEmploiPayload.js';
2+
import * as httpErrorsHelper from '../../infrastructure/http/errors-helper.js';
3+
import { httpAgent } from '../../infrastructure/http/http-agent.js';
4+
import * as monitoringTools from '../../infrastructure/monitoring-tools.js';
75
import { PoleEmploiSending } from '../models/PoleEmploiSending.js';
6+
import { CampaignParticipationStarted } from './CampaignParticipationStarted.js';
7+
import { checkEventTypes } from './check-event-types.js';
8+
89
const eventTypes = [CampaignParticipationStarted];
910

1011
async function handlePoleEmploiParticipationStarted({

api/lib/domain/events/index.js

+17
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import { config } from '../../config.js';
3030
import * as eventBusBuilder from '../../infrastructure/events/EventBusBuilder.js';
3131
import { EventDispatcher } from '../../infrastructure/events/EventDispatcher.js';
3232
import { EventDispatcherLogger } from '../../infrastructure/events/EventDispatcherLogger.js';
33+
import * as disabledPoleEmploiNotifier from '../../infrastructure/externals/pole-emploi/disabled-pole-emploi-notifier.js';
34+
import * as poleEmploiNotifier from '../../infrastructure/externals/pole-emploi/pole-emploi-notifier.js';
3335
import { monitoringTools as MonitoringTools } from '../../infrastructure/monitoring-tools.js';
3436
import * as badgeAcquisitionRepository from '../../infrastructure/repositories/badge-acquisition-repository.js';
3537
import * as campaignParticipationRepository from '../../infrastructure/repositories/campaign-participation-repository.js';
@@ -41,16 +43,27 @@ import * as complementaryCertificationScoringCriteriaRepository from '../../infr
4143
import * as juryCertificationSummaryRepository from '../../infrastructure/repositories/jury-certification-summary-repository.js';
4244
import * as knowledgeElementRepository from '../../infrastructure/repositories/knowledge-element-repository.js';
4345
import { participantResultsSharedRepository } from '../../infrastructure/repositories/participant-results-shared-repository.js';
46+
import * as poleEmploiSendingRepository from '../../infrastructure/repositories/pole-emploi-sending-repository.js';
4447
import * as targetProfileRepository from '../../infrastructure/repositories/target-profile-repository.js';
4548
import * as scoringCertificationService from '../services/scoring/scoring-certification-service.js';
4649
import { handleAutoJury } from './handle-auto-jury.js';
4750
import { handleCertificationRescoring } from './handle-certification-rescoring.js';
4851
import { handleCertificationScoring } from './handle-certification-scoring.js';
4952
import { handleComplementaryCertificationsScoring } from './handle-complementary-certifications-scoring.js';
53+
import { handlePoleEmploiParticipationFinished } from './handle-pole-emploi-participation-finished.js';
54+
import { handlePoleEmploiParticipationStarted } from './handle-pole-emploi-participation-started.js';
5055
import { handleSessionFinalized } from './handle-session-finalized.js';
5156

5257
const { performance } = perf_hooks;
5358

59+
function requirePoleEmploiNotifier() {
60+
if (config.poleEmploi.pushEnabled) {
61+
return poleEmploiNotifier;
62+
} else {
63+
return disabledPoleEmploiNotifier;
64+
}
65+
}
66+
5467
const dependencies = {
5568
answerRepository,
5669
assessmentRepository,
@@ -80,6 +93,8 @@ const dependencies = {
8093
logger,
8194
organizationRepository,
8295
participantResultsSharedRepository,
96+
poleEmploiNotifier: requirePoleEmploiNotifier(),
97+
poleEmploiSendingRepository,
8398
scoringCertificationService,
8499
scoringDegradationService,
85100
skillRepository,
@@ -94,6 +109,8 @@ const handlersToBeInjected = {
94109
handleCertificationScoring,
95110
handleCertificationRescoring,
96111
handleComplementaryCertificationsScoring,
112+
handlePoleEmploiParticipationFinished,
113+
handlePoleEmploiParticipationStarted,
97114
handleSessionFinalized,
98115
};
99116

api/lib/domain/models/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import { CampaignForArchiving } from '../../../src/prescription/campaign/domain/
3030
import { CampaignForCreation } from '../../../src/prescription/campaign/domain/models/CampaignForCreation.js';
3131
import { Group } from '../../../src/prescription/campaign/domain/models/Group.js';
3232
import { CampaignToStartParticipation } from '../../../src/prescription/campaign-participation/domain/models/CampaignToStartParticipation.js';
33-
import { PoleEmploiSending } from '../../../src/prescription/campaign-participation/domain/models/PoleEmploiSending.js';
3433
import { OrganizationPlacesLot } from '../../../src/prescription/organization-place/domain/models/OrganizationPlacesLot.js';
3534
import { CampaignParticipationStatuses, CampaignTypes } from '../../../src/prescription/shared/domain/constants.js';
3635
import { OrganizationsToAttachToTargetProfile } from '../../../src/prescription/target-profile/domain/models/OrganizationsToAttachToTargetProfile.js';
@@ -96,6 +95,7 @@ import { OrganizationTag } from './OrganizationTag.js';
9695
import { ParticipantResultsShared } from './ParticipantResultsShared.js';
9796
import { PartnerCertificationScoring } from './PartnerCertificationScoring.js';
9897
import { PlacementProfile } from './PlacementProfile.js';
98+
import { PoleEmploiSending } from './PoleEmploiSending.js';
9999
import { PrivateCertificate } from './PrivateCertificate.js';
100100
import { ReproducibilityRate } from './ReproducibilityRate.js';
101101
import { ResultCompetence } from './ResultCompetence.js';

api/src/prescription/campaign-participation/domain/services/pole-emploi-service.js api/lib/domain/services/pole-emploi-service.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { config } from '../../../../../lib/config.js';
1+
import { config } from '../../config.js';
22

33
function generateLink(sending, filters = {}) {
44
const host = config.apiManager.url;
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as poleEmploiService from '../services/pole-emploi-service.js';
1+
import * as poleEmploiService from '../../domain/services/pole-emploi-service.js';
22

33
const getPoleEmploiSendings = async function ({ cursorData, poleEmploiSendingRepository, filters }) {
44
const sendings = await poleEmploiSendingRepository.find(cursorData, filters);

api/lib/domain/usecases/index.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ import * as campaignAssessmentParticipationRepository from '../../../src/prescri
5959
import * as campaignAssessmentParticipationResultRepository from '../../../src/prescription/campaign-participation/infrastructure/repositories/campaign-assessment-participation-result-repository.js';
6060
import * as campaignParticipationBCRepository from '../../../src/prescription/campaign-participation/infrastructure/repositories/campaign-participation-repository.js';
6161
import * as campaignProfileRepository from '../../../src/prescription/campaign-participation/infrastructure/repositories/campaign-profile-repository.js';
62-
import * as poleEmploiSendingRepository from '../../../src/prescription/campaign-participation/infrastructure/repositories/pole-emploi-sending-repository.js';
6362
import * as supOrganizationLearnerRepository from '../../../src/prescription/learner-management/infrastructure/repositories/sup-organization-learner-repository.js';
6463
import * as organizationLearnerActivityRepository from '../../../src/prescription/organization-learner/infrastructure/repositories/organization-learner-activity-repository.js';
6564
import * as activityAnswerRepository from '../../../src/school/infrastructure/repositories/activity-answer-repository.js';
@@ -109,6 +108,8 @@ import * as resetPasswordService from '../../domain/services/reset-password-serv
109108
import * as scoringCertificationService from '../../domain/services/scoring/scoring-certification-service.js';
110109
import * as sessionPublicationService from '../../domain/services/session-publication-service.js';
111110
import * as verifyCertificateCodeService from '../../domain/services/verify-certificate-code-service.js';
111+
import * as disabledPoleEmploiNotifier from '../../infrastructure/externals/pole-emploi/disabled-pole-emploi-notifier.js';
112+
import * as poleEmploiNotifier from '../../infrastructure/externals/pole-emploi/pole-emploi-notifier.js';
112113
import * as accountRecoveryDemandRepository from '../../infrastructure/repositories/account-recovery-demand-repository.js';
113114
import * as attachableTargetProfileRepository from '../../infrastructure/repositories/attachable-target-profiles-repository.js';
114115
import * as badgeAcquisitionRepository from '../../infrastructure/repositories/badge-acquisition-repository.js';
@@ -150,6 +151,7 @@ import * as organizationMemberIdentityRepository from '../../infrastructure/repo
150151
import * as organizationTagRepository from '../../infrastructure/repositories/organization-tag-repository.js';
151152
import * as participantResultRepository from '../../infrastructure/repositories/participant-result-repository.js';
152153
import { participantResultsSharedRepository } from '../../infrastructure/repositories/participant-results-shared-repository.js';
154+
import * as poleEmploiSendingRepository from '../../infrastructure/repositories/pole-emploi-sending-repository.js';
153155
import * as resetPasswordDemandRepository from '../../infrastructure/repositories/reset-password-demands-repository.js';
154156
import * as scoCertificationCandidateRepository from '../../infrastructure/repositories/sco-certification-candidate-repository.js';
155157
import * as studentRepository from '../../infrastructure/repositories/student-repository.js';
@@ -171,8 +173,17 @@ import * as userReconciliationService from '../services/user-reconciliation-serv
171173
import * as organizationCreationValidator from '../validators/organization-creation-validator.js';
172174
import * as organizationValidator from '../validators/organization-with-tags-and-target-profiles-script.js';
173175
import { findTargetProfileOrganizations as findPaginatedFilteredTargetProfileOrganizations } from './find-paginated-filtered-target-profile-organizations.js';
176+
174177
const oidcAuthenticationServiceRegistry = new OidcAuthenticationServiceRegistry({ oidcProviderRepository });
175178

179+
function requirePoleEmploiNotifier() {
180+
if (config.poleEmploi.pushEnabled) {
181+
return poleEmploiNotifier;
182+
} else {
183+
return disabledPoleEmploiNotifier;
184+
}
185+
}
186+
176187
/**
177188
* Using {@link https://jsdoc.app/tags-type "Closure Compiler's syntax"} to document injected dependencies
178189
*
@@ -302,6 +313,7 @@ const dependencies = {
302313
pickChallengeService,
303314
pixAuthenticationService,
304315
placementProfileService,
316+
poleEmploiNotifier: requirePoleEmploiNotifier(),
305317
poleEmploiSendingRepository,
306318
refreshTokenService,
307319
resetPasswordDemandRepository,
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as httpErrorsHelper from '../../../../../lib/infrastructure/http/errors-helper.js';
2-
import { httpAgent } from '../../../../../lib/infrastructure/http/http-agent.js';
3-
import * as monitoringTools from '../../../../../lib/infrastructure/monitoring-tools.js';
4-
import { PoleEmploiPayload } from '../../infrastructure/externals/PoleEmploiPayload.js';
1+
import { PoleEmploiPayload } from '../../infrastructure/externals/pole-emploi/PoleEmploiPayload.js';
2+
import * as httpErrorsHelper from '../../infrastructure/http/errors-helper.js';
3+
import { httpAgent } from '../../infrastructure/http/http-agent.js';
4+
import * as monitoringTools from '../../infrastructure/monitoring-tools.js';
55
import { PoleEmploiSending } from '../models/PoleEmploiSending.js';
66

77
const sendSharedParticipationResultsToPoleEmploi = async ({

api/src/prescription/campaign-participation/infrastructure/externals/PoleEmploiPayload.js api/lib/infrastructure/externals/pole-emploi/PoleEmploiPayload.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from 'lodash';
22

3-
import { config } from '../../../../shared/config.js';
3+
import { config } from '../../../config.js';
44

55
const CAMPAIGN_TYPE = 'EVALUATION';
66
const STRUCTURE_NAME = 'Pix';

api/src/prescription/campaign-participation/infrastructure/externals/pole-emploi-notifier.js api/lib/infrastructure/externals/pole-emploi/pole-emploi-notifier.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import querystring from 'node:querystring';
66

77
import dayjs from 'dayjs';
88

9-
import { UnexpectedUserAccountError } from '../../../../../lib/domain/errors.js';
10-
import * as OidcIdentityProviders from '../../../../identity-access-management/domain/constants/oidc-identity-providers.js';
11-
import { AuthenticationMethod } from '../../../../identity-access-management/domain/models/AuthenticationMethod.js';
12-
import { config } from '../../../../shared/config.js';
9+
import * as OidcIdentityProviders from '../../../../src/identity-access-management/domain/constants/oidc-identity-providers.js';
10+
import { AuthenticationMethod } from '../../../../src/identity-access-management/domain/models/AuthenticationMethod.js';
11+
import { config } from '../../../config.js';
12+
import { UnexpectedUserAccountError } from '../../../domain/errors.js';
1313

1414
const notify = async (userId, payload, dependencies) => {
1515
const { authenticationMethodRepository, httpAgent, httpErrorsHelper, monitoringTools } = dependencies;

api/lib/infrastructure/jobs/campaign-result/SendSharedParticipationResultsToPoleEmploiHandler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { usecases } from '../../../../src/prescription/campaign-participation/domain/usecases/index.js';
1+
import { usecases } from '../../../domain/usecases/index.js';
22
import { SendSharedParticipationResultsToPoleEmploiJob } from './SendSharedParticipationResultsToPoleEmploiJob.js';
33

44
class SendSharedParticipationResultsToPoleEmploiHandler {
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { knex } from '../../../../../db/knex-database-connection.js';
2-
import { config } from '../../../../../lib/config.js';
3-
import * as OidcIdentityProviders from '../../../../identity-access-management/domain/constants/oidc-identity-providers.js';
1+
import { knex } from '../../../db/knex-database-connection.js';
2+
import { config } from '../../../lib/config.js';
3+
import * as OidcIdentityProviders from '../../../src/identity-access-management/domain/constants/oidc-identity-providers.js';
44

55
const create = function ({ poleEmploiSending }) {
66
return knex('pole-emploi-sendings').insert({ ...poleEmploiSending });

api/lib/routes.js

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import * as organizationLearners from './application/organization-learners/index
2727
import * as organizations from './application/organizations/index.js';
2828
import * as organizationsAdministration from './application/organizations-administration/index.js';
2929
import * as passwords from './application/passwords/index.js';
30+
import * as poleEmploi from './application/pole-emploi/index.js';
3031
import * as scoOrganizationLearners from './application/sco-organization-learners/index.js';
3132
import * as sessions from './application/sessions/index.js';
3233
import * as supOrganizationLearners from './application/sup-organization-learners/index.js';
@@ -63,6 +64,7 @@ const routes = [
6364
organizations,
6465
organizationsAdministration,
6566
passwords,
67+
poleEmploi,
6668
organizationInvitations,
6769
scoOrganizationLearners,
6870
supOrganizationLearners,

api/src/certification/complementary-certification/application/attach-target-profile-route.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Joi from 'joi';
22

3+
import { erreurDoc } from '../../../../lib/infrastructure/open-api-doc/pole-emploi/erreur-doc.js';
34
import { securityPreHandlers } from '../../../shared/application/security-pre-handlers.js';
45
import { identifiersType } from '../../../shared/domain/types/identifiers-type.js';
5-
import { erreurDoc } from '../../../shared/infrastructure/open-api-doc/erreur-doc.js';
66
import { attachTargetProfileController } from './attach-target-profile-controller.js';
77

88
const register = async function (server) {

0 commit comments

Comments
 (0)