Skip to content

Commit

Permalink
fix: update to correct juris on change requested (#3934)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludtkemorgan authored Mar 8, 2024
1 parent e68dbf0 commit cfc20e1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
14 changes: 11 additions & 3 deletions api/src/services/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ type EmailAttachmentData = {
type: string;
};

type listingInfo = {
id: string;
name: string;
juris: string;
};

@Injectable()
export class EmailService {
polyglot: Polyglot;
Expand Down Expand Up @@ -429,13 +435,15 @@ export class EmailService {
}

public async changesRequested(
jurisdictionId: IdDTO,
listingInfo: IdDTO,
user: User,
listingInfo: listingInfo,
emails: string[],
appUrl: string,
) {
try {
const jurisdiction = await this.getJurisdiction([jurisdictionId]);
const jurisdiction = listingInfo.juris
? await this.getJurisdiction([{ id: listingInfo.juris }])
: user.jurisdictions[0];
void (await this.loadTranslations(jurisdiction));
await this.send(
emails,
Expand Down
6 changes: 5 additions & 1 deletion api/src/services/listing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ export class ListingService implements OnModuleInit {
);
await this.emailService.changesRequested(
params.user,
{ id: params.listingInfo.id, name: params.listingInfo.name },
{
id: params.listingInfo.id,
name: params.listingInfo.name,
juris: params.jurisId,
},
userInfo.emails,
this.configService.get('PARTNERS_PORTAL_URL'),
);
Expand Down
2 changes: 1 addition & 1 deletion api/test/integration/listing.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ describe('Listing Controller Tests', () => {
expect.objectContaining({
id: adminUser.id,
}),
{ id: listing.id, name: val.name },
{ id: listing.id, name: val.name, juris: expect.anything() },
expect.arrayContaining([partnerUser.email]),
process.env.PARTNERS_PORTAL_URL,
);
Expand Down
2 changes: 1 addition & 1 deletion api/test/unit/services/email.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ describe('Testing email service', () => {
const service = await module.resolve(EmailService);
await service.changesRequested(
{ name: 'test', id: '1234' },
{ name: 'listing name', id: 'listingId' },
{ name: 'listing name', id: 'listingId', juris: 'jurisId' },
emailArr,
'http://localhost:3001',
);
Expand Down
2 changes: 1 addition & 1 deletion api/test/unit/services/listing.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2569,7 +2569,7 @@ describe('Testing listing service', () => {
);
expect(changesRequestedMock).toBeCalledWith(
user,
{ id: 'id', name: 'name' },
{ id: 'id', name: 'name', juris: 'jurisId' },
['[email protected]', '[email protected]'],
config.get('PARTNERS_PORTAL_URL'),
);
Expand Down

0 comments on commit cfc20e1

Please sign in to comment.