diff --git a/services/app-api/email/stateWithdrawalReceipt.js b/services/app-api/email/stateWithdrawalReceipt.js index 46ab50ed3..2337a6e9b 100644 --- a/services/app-api/email/stateWithdrawalReceipt.js +++ b/services/app-api/email/stateWithdrawalReceipt.js @@ -1,38 +1,33 @@ import dynamoDb from "../libs/dynamodb-lib"; -import { USER_ROLE, USER_STATUS, Workflow } from "cmscommonlib"; +import { USER_STATUS, Workflow } from "cmscommonlib"; export const getAllActiveStateUserEmailAddresses = async (territory) => { - const stateSubmittingUserRoles = [ - USER_ROLE.STATE_SUBMITTER, - USER_ROLE.STATE_SYSTEM_ADMIN, - ]; - const stateSubmittingUsers = []; - - await Promise.all( - stateSubmittingUserRoles.map(async (role) => { - const qParams = { - TableName: process.env.oneMacTableName, - IndexName: "GSI2", - KeyConditionExpression: "GSI2pk = :pk and GSI2sk = :sk", - ExpressionAttributeValues: { - ":pk": `${role}#${territory}`, - ":sk": USER_STATUS.ACTIVE, - }, - ProjectionExpression: "email, fullName", - }; - try { - const results = await dynamoDb.query(qParams); - stateSubmittingUsers.push( - results.Items.map(({ fullName, email }) => `${fullName} <${email}>`) - ); - } catch (e) { - console.log("query error: ", e.message); - } - }) - ); - const returnUsers = stateSubmittingUsers.flat(); + const qParams = { + TableName: process.env.oneMacTableName, + IndexName: "GSI1", + KeyConditionExpression: "GSI1pk = :pk", + FilterExpression: "#status = :status and territory = :territory", + ExpressionAttributeNames: { + "#status": "status", + }, + ExpressionAttributeValues: { + ":pk": "USER", + ":territory": territory, + ":status": USER_STATUS.ACTIVE, + }, + ProjectionExpression: "email, fullName", + }; - return returnUsers; + try { + const results = await dynamoDb.query(qParams); + const returnUsers = results.Items.map( + ({ fullName, email }) => `${fullName} <${email}>` + ); + return returnUsers; + } catch (e) { + console.log("query error: ", e.message); + return []; + } }; /** diff --git a/services/one-stream/package/buildAnyPackage.js b/services/one-stream/package/buildAnyPackage.js index db7dd357a..a7a9aeaa9 100644 --- a/services/one-stream/package/buildAnyPackage.js +++ b/services/one-stream/package/buildAnyPackage.js @@ -82,8 +82,11 @@ export const buildAnyPackage = async (packageId, config) => { let adminChanges = []; result.Items.forEach((anEvent) => { - // we ignore all other v's (for now) - if (anEvent.sk.substring(0, 1) === "v") { + // we ignore all other v's (for now) and any email events + if ( + anEvent.sk.substring(0, 1) === "v" || + anEvent.sk.startsWith("Email") + ) { console.log("ignoring: ", anEvent.sk); return; }