From 04fcae0675ccf4278c74dd8e8de38e3991110634 Mon Sep 17 00:00:00 2001 From: bflynn-cms Date: Fri, 5 Jul 2024 10:28:57 -0500 Subject: [PATCH 1/2] ignore email records in package builder (#1481) --- services/one-stream/package/buildAnyPackage.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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; } From 056227e377df603caba728b461027bc08ea0f311 Mon Sep 17 00:00:00 2001 From: bflynn-cms Date: Wed, 10 Jul 2024 14:29:22 -0500 Subject: [PATCH 2/2] oy2-29084 - state withdrawal emails to include all active state users from territory --- .../app-api/email/stateWithdrawalReceipt.js | 57 +++++++++---------- 1 file changed, 26 insertions(+), 31 deletions(-) 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 []; + } }; /**