Skip to content

Commit

Permalink
FORMS-1561: add form metadata to event stream message
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Sherman <[email protected]>
  • Loading branch information
usingtechnology committed Oct 22, 2024
1 parent eaa9518 commit 42445bb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { form, isRTL } = storeToRefs(formStore);
const loading = ref(true);
const algorithms = ref([]);
const techdocsLink =
'https://developer.gov.bc.ca/docs/default/component/chefs-techdocs/Capabilities/Functionalities';
'https://developer.gov.bc.ca/docs/default/component/chefs-techdocs/Capabilities/Integrations/Event-Stream-Service/';
onMounted(async () => {
await fetchAlgorithms();
Expand Down
5 changes: 4 additions & 1 deletion app/src/components/eventStreamService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (WEBSOCKETS) {
const log = require('./log')(module.filename);

const { FormVersion, Form, FormEventStreamConfig } = require('../forms/common/models');

const formMetadataService = require('../forms/form/formMetadata/service');
const { featureFlags } = require('./featureFlags');
const { encryptionService } = require('./encryptionService');

Expand Down Expand Up @@ -215,6 +215,8 @@ class EventStreamService {
formId: formId,
formVersionId: formVersionId,
};
await formMetadataService.addAttribute(formId, meta);

if (evntStrmCfg.enablePrivateStream) {
const encPayload = encryptionService.encryptExternal(evntStrmCfg.encryptionKey.algorithm, evntStrmCfg.encryptionKey.key, form);
const privMsg = {
Expand Down Expand Up @@ -274,6 +276,7 @@ class EventStreamService {
submissionId: submission.id,
draft: draft,
};
await formMetadataService.addAttribute(formVersion.formId, meta);

if (evntStrmCfg.enablePrivateStream) {
const encPayload = encryptionService.encryptExternal(evntStrmCfg.encryptionKey.algorithm, evntStrmCfg.encryptionKey.key, submission);
Expand Down
5 changes: 5 additions & 0 deletions app/tests/unit/components/eventStreamService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const { Form, FormVersion, FormEventStreamConfig } = require('../../../src/forms
const FORM_EVENT_TYPES_COUNT = 2;
const SUBMISSION_EVENT_TYPES_COUNT = 3;

const formMetadataService = require('../../../src/forms/form/formMetadata/service');
jest.mock('../../../src/forms/form/formMetadata/service');

beforeEach(() => {
MockModel.mockReset();
jest.resetModules();
Expand Down Expand Up @@ -46,6 +49,8 @@ describe('eventStreamService', () => {
FormEventStreamConfig.withGraphFetched = jest.fn().mockReturnThis();
FormEventStreamConfig.first = jest.fn().mockReturnThis();
FormEventStreamConfig.throwIfNotFound = jest.fn().mockReturnThis();

formMetadataService.addAttribute = jest.fn().mockResolvedValueOnce({});
});

afterEach(() => {
Expand Down

0 comments on commit 42445bb

Please sign in to comment.