Skip to content

Commit

Permalink
enhancement(TaxForms): bring back delegated links (#8483)
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree authored Jan 31, 2023
1 parent b975db3 commit b52e7ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
29 changes: 16 additions & 13 deletions server/lib/tax-forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export async function sendHelloWorksUsTaxForm(
workflowId,
documentDelivery: true,
documentDeliveryType: 'link',
// delegatedAuthentication: true, // See "authenticated link" below.
delegatedAuthentication: true, // See "authenticated link" below.
participants,
metadata: {
accountType: accountToSubmitRequestTo.type,
Expand All @@ -157,20 +157,23 @@ export async function sendHelloWorksUsTaxForm(
});

// Get the authenticated link ("delegated authentication")
// We currently don't have access to this feature with our pricing plan
// try {
// documentLink = await client.workflowInstances.getAuthenticatedLinkForStep({
// instanceId: instance.id,
// step: step.step,
// });
// } catch (e) {
// // Fallback to the default `step.url` (unauthenticated link)
// logger.warn(`Tax form: error getting authenticated link for ${instance.id}: ${e.message}`);
// }
const step = instance.steps[0];
let documentLink = step.url;
try {
documentLink = await client.workflowInstances.getAuthenticatedLinkForStep({
instanceId: instance.id,
step: step.step,
});
} catch (e) {
// Fallback to the default `step.url` (unauthenticated link)
reportErrorToSentry(e, {
severity: 'warning',
transactionName: 'taxForm.sendHelloWorksUsTaxForm.getAuthenticatedLinkForStep',
extra: { instanceId: instance.id, step: JSON.stringify(step) },
});
}

// Save the authenticated link to the database, in case we want to send it again later
const step = instance.steps[0];
const documentLink = step.url;
await document.update({ data: deepMerge(document.data, { helloWorks: { documentLink } }) });

// Send the actual email
Expand Down
2 changes: 1 addition & 1 deletion test/server/lib/tax-forms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ describe('server/lib/tax-forms', () => {
expect(client.workflowInstances.createInstance.called).to.be.true;
const callArgs = client.workflowInstances.createInstance.firstCall.args;
expect(callArgs[0].participants['participant_swVuvW'].fullName).to.eq('Mr. Legal Name');
// when we'll activate authenticated links expect(client.workflowInstances.getAuthenticatedLinkForStep.called).to.be.true;
expect(client.workflowInstances.getAuthenticatedLinkForStep.called).to.be.true;
expect(doc.requestStatus).to.eq(REQUESTED);

assert.callCount(sendMessageSpy, 1);
Expand Down

0 comments on commit b52e7ae

Please sign in to comment.