Skip to content

Commit

Permalink
appmixer-fe ISS-3925: support for flowId parameter to trigger app eve…
Browse files Browse the repository at this point in the history
…nts in a specific flow
  • Loading branch information
DavidDurman committed Mar 11, 2024
1 parent 4cd8234 commit 57e2fd8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/appmixer/utils/appevents/OnAppEvent/OnAppEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {
const eventDataExampleJson = JSON.parse(eventDataExample);
schema = GenerateSchema.json('App Event Data', eventDataExampleJson);
} catch (err) {
context.log({ step: 'Generate output variables from Event Data Example.', err: err.message, eventDataExample });
// noop
}

const output = [
Expand Down
2 changes: 1 addition & 1 deletion src/appmixer/utils/appevents/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = async context => {
const lock = await context.lock('app-events-init');

try {
await require('./AppEventTriggerModel')(context).createIndex({ userId: 1, event: 1 });
await require('./AppEventTriggerModel')(context).createIndex({ userId: 1, event: 1, flowId: 1 });
} finally {
lock.unlock();
}
Expand Down
8 changes: 6 additions & 2 deletions src/appmixer/utils/appevents/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ module.exports = (context, options) => {

const event = req.params.event;
const data = req.payload;
const query = req.query || {};
const user = await context.http.auth.getUser(req);
const userId = user.getId();

const triggers = await AppEventTrigger.find({ event, userId });
const triggersQuery = { event, userId };
if (query.flowId) {
triggersQuery.flowId = query.flowId;
}
const triggers = await AppEventTrigger.find(triggersQuery);
if (!triggers || !triggers.length) {
return { triggers: [] };
}

const query = req.query || {};
// Use enqueueOnly=true in query to enqueue message to Appmixer ASAP without waiting
// for the entire receive() to finish.
query.enqueueOnly = true;
Expand Down

0 comments on commit 57e2fd8

Please sign in to comment.