Skip to content

Commit

Permalink
url for collab template (#4880)
Browse files Browse the repository at this point in the history
  • Loading branch information
hero101 authored Jan 27, 2025
1 parent a8feed8 commit 3e58ddb
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions src/services/infrastructure/url-generator/url.generator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,39 @@ export class UrlGeneratorService {
},
},
});
if (collaboration) {
return await this.getJourneyUrlPath('collaborationId', collaboration.id);
if (!collaboration) {
throw new EntityNotFoundException(
`Unable to find innovationFlow for profile: ${profileID}`,
LogContext.URL_GENERATOR
);
}
if (collaboration.isTemplate) {
return this.getCollaborationTemplateUrlPathOrFail(collaboration.id);
}

throw new EntityNotFoundException(
`Unable to find innovationFlow for profile: ${profileID}`,
LogContext.URL_GENERATOR
);
return this.getJourneyUrlPath('collaborationId', collaboration.id);
}

private async getCollaborationTemplateUrlPathOrFail(collaborationId: string) {
const template = await this.entityManager.findOne(Template, {
where: {
collaboration: {
id: collaborationId,
},
},
relations: {
profile: true,
},
});

if (!template || !template.profile) {
throw new EntityNotFoundException(
`Unable to find collaboration template for collaboration: ${collaborationId}`,
LogContext.URL_GENERATOR
);
}

return this.getTemplateUrlPathOrFail(template.profile.id);
}

private async getCommunityGuidelinesUrlPathOrFail(
Expand Down Expand Up @@ -667,6 +692,11 @@ export class UrlGeneratorService {
LogContext.URL_GENERATOR
);
}

if (collaboration.isTemplate) {
return this.getCollaborationTemplateUrlPathOrFail(collaboration.id);
}

const collaborationJourneyUrlPath = await this.getJourneyUrlPath(
'collaborationId',
collaboration.id
Expand Down

0 comments on commit 3e58ddb

Please sign in to comment.