From 2fd7b02fb8346acce828440574be18c76122d1d7 Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Mon, 12 Dec 2022 20:03:31 -0800 Subject: [PATCH 01/15] Add catch --- src/extensions/contact-loaders/s3-pull/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/extensions/contact-loaders/s3-pull/index.js b/src/extensions/contact-loaders/s3-pull/index.js index 5fd74ac98..25361839d 100644 --- a/src/extensions/contact-loaders/s3-pull/index.js +++ b/src/extensions/contact-loaders/s3-pull/index.js @@ -187,7 +187,9 @@ export async function loadContactS3PullProcessFile(jobEvent, contextVars) { return { alreadyComplete: 1 }; } - await r.knex.batchInsert("campaign_contact", insertRows); + await r.knex.batchInsert("campaign_contact", insertRows).catch(e => { + console.log("Error with S3 pull batch insertion for campaign", campaign_id, e); + }); } if (fileIndex < manifestData.entries.length - 1) { From 99aee7fc361a86c875a8cdb43448f90fbfe992bb Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Wed, 21 Dec 2022 15:35:22 -0800 Subject: [PATCH 02/15] Change console.log to console.error --- src/extensions/contact-loaders/s3-pull/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/contact-loaders/s3-pull/index.js b/src/extensions/contact-loaders/s3-pull/index.js index 25361839d..c78e29174 100644 --- a/src/extensions/contact-loaders/s3-pull/index.js +++ b/src/extensions/contact-loaders/s3-pull/index.js @@ -188,7 +188,7 @@ export async function loadContactS3PullProcessFile(jobEvent, contextVars) { } await r.knex.batchInsert("campaign_contact", insertRows).catch(e => { - console.log("Error with S3 pull batch insertion for campaign", campaign_id, e); + console.error("Error with S3 pull batch insertion for campaign", campaign_id, e); }); } From bb47f9ffdfa97a2c2f90bc41c1790946f86e32c9 Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Wed, 22 Mar 2023 17:24:47 -0700 Subject: [PATCH 03/15] Update bug_report.md --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 653166a42..32416c351 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -27,7 +27,7 @@ If applicable, add screenshots to help explain your problem. - OS: [e.g. iOS] - Browser [e.g. chrome, safari] - Desktop or Mobile? - - Version [e.g. 22] + - Spoke Version: [e.g. 13.0.0] **Additional context** Add any other context about the problem here. From 40095d94c34a1b04c44a377deed974726c048a76 Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Fri, 29 Sep 2023 16:49:06 -0700 Subject: [PATCH 04/15] Get contactTimezones when not caching --- src/server/models/cacheable_queries/campaign.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/models/cacheable_queries/campaign.js b/src/server/models/cacheable_queries/campaign.js index 8311586ee..41bd19c79 100644 --- a/src/server/models/cacheable_queries/campaign.js +++ b/src/server/models/cacheable_queries/campaign.js @@ -206,7 +206,9 @@ const load = async (id, opts) => { } } - return await Campaign.get(id); + const campaign = await Campaign.get(id) + campaign.contactTimezones = await dbContactTimezones(id); + return campaign; }; const campaignCache = { From 27fef9321c5a8ea62e1dbd04f2aa709ef0f45d9d Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Fri, 6 Oct 2023 14:48:43 -0700 Subject: [PATCH 05/15] Grant permission to public schema --- dev-tools/create-test-database | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dev-tools/create-test-database b/dev-tools/create-test-database index 693dd00db..a27b07a96 100755 --- a/dev-tools/create-test-database +++ b/dev-tools/create-test-database @@ -6,3 +6,7 @@ docker-compose exec -T postgres psql -h localhost -p 5432 -U spoke spokedev < Date: Sun, 8 Oct 2023 17:33:04 -0700 Subject: [PATCH 06/15] bulk send batch progress UI --- .eslintrc | 8 +- package.json | 3 + .../AssignmentTexter/BulkSendButton.jsx | 162 +++++++++++++----- 3 files changed, 125 insertions(+), 48 deletions(-) diff --git a/.eslintrc b/.eslintrc index a6796f1ec..2f45ceb40 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,11 @@ { "extends": ["airbnb", "prettier"], "parser": "@babel/eslint-parser", - "env": { "jest": true, "node": true, "browser": true, "jasmine": true } + "env": { "jest": true, "node": true, "browser": true, "jasmine": true }, + "rules": { + "no-console": [ + "warn", + { "allow": ["warn", "error", "info", "time", "timeEnd"] } + ] + } } diff --git a/package.json b/package.json index 98e05264d..f3a43d301 100644 --- a/package.json +++ b/package.json @@ -232,5 +232,8 @@ "react-tooltip": "^4.2.13", "recompose": "^0.30.0", "webpack-cli": "^4.7.2" + }, + "browser": { + "crypto": false } } diff --git a/src/components/AssignmentTexter/BulkSendButton.jsx b/src/components/AssignmentTexter/BulkSendButton.jsx index a73b22581..5ddca8660 100644 --- a/src/components/AssignmentTexter/BulkSendButton.jsx +++ b/src/components/AssignmentTexter/BulkSendButton.jsx @@ -1,73 +1,141 @@ import PropTypes from "prop-types"; -import React, { Component } from "react"; +import React, { useState, useEffect } from "react"; import { StyleSheet, css } from "aphrodite"; import Button from "@material-ui/core/Button"; - +import LinearProgress from "@material-ui/core/LinearProgress"; +import Typography from '@material-ui/core/Typography'; +import Snackbar from '@material-ui/core/Snackbar'; +import Alert from '@material-ui/lab/Alert'; + // This is because the Toolbar from material-ui seems to only apply the correct margins if the // immediate child is a Button or other type it recognizes. Can get rid of this if we remove material-ui const styles = StyleSheet.create({ container: { - display: "block", - width: "25ex", - marginLeft: "auto", - marginRight: "auto" + display: "flex", + flexFlow: "column", + alignItems: "center", + width: "30%", + maxWidth: 300, + height: "100%", + marginTop: 10, + marginRight: "auto", + marginLeft: "auto" + }, + progressContainer: { + width: "100%" + }, + progressText: { + position: "relative", + textAlign: "center", + color: "white" + }, + progressBarRoot: { + height: 10, + borderRadius: 5 } }); -export default class BulkSendButton extends Component { - state = { - isSending: false - }; +function BulkSendButton({ + assignment, setDisabled, bulkSendMessages, refreshData, onFinishContact +}) { + const totalChunkSize = window.BULK_SEND_CHUNK_SIZE; + const [isSending, setIsSending] = useState(false); + const [totalSentMessages, setTotalSentMessages] = useState(0); + const [progress, setProgress] = useState(0); + const [errorMessage, setErrorMessage] = useState(''); - sendMessages = async () => { - let sentMessages = 0; + const sendMessages = async () => { + try { + const { data } = await bulkSendMessages(assignment.id); + const sentMessages = data.bulkSendMessages.length; + const updatedTotalSent = totalSentMessages + sentMessages; - this.setState({ isSending: true }); - this.props.setDisabled(true); + if (!sentMessages) { + /* end sending if no messages were left to send */ + setProgress(100); + } else { + setTotalSentMessages(updatedTotalSent); + setProgress((updatedTotalSent / totalChunkSize) * 100); + } + } catch (err) { + console.error(err); + setErrorMessage(err.message); + } + } - console.log(`Start bulk sending messages ${new Date()}`); - while (sentMessages < window.BULK_SEND_CHUNK_SIZE) { - const res = await this.props.bulkSendMessages(this.props.assignment.id); + const handleEndSend = () => { + refreshData(); + setErrorMessage(''); + setIsSending(false); + setProgress(0); + setTotalSentMessages(0); + setDisabled(false); + onFinishContact(); + } - // Check if all messages have been sent - if (!res.data.bulkSendMessages.length) { - break; + useEffect(() => { + if (isSending) { + /* sendMessages will be called the first time when isSending is set to true + and only called again when the progress state is updated and not complete */ + if (progress < 100) { + sendMessages(); + } else { + /* display "sent all" message for half a sec */ + setTimeout(handleEndSend, 500); } - - // Print progress to console - sentMessages += res.data.bulkSendMessages.length; - console.log(`Bulk sent ${sentMessages} messages ${new Date()}`); } - this.props.refreshData(); - console.log(`Finish bulk sending messages ${new Date()}`); - - this.setState({ isSending: false }); - this.props.setDisabled(false); - this.props.onFinishContact(); - }; + }, [isSending, progress]); - render() { - return ( -
+ return ( +
+ {isSending ? ( +
+
+ + {progress === 100 + ? 'Sent all messages!' + : `Sent ${totalSentMessages} of ${totalChunkSize} messages...`} + +
+ +
+ ) : ( -
- ); - } + )} + + + {errorMessage} + + +
+ ); } BulkSendButton.propTypes = { - assignment: PropTypes.object, - onFinishContact: PropTypes.func, - bulkSendMessages: PropTypes.func, - refreshData: PropTypes.func, - setDisabled: PropTypes.func + assignment: PropTypes.shape({ id: PropTypes.number }).isRequired, + onFinishContact: PropTypes.func.isRequired, + bulkSendMessages: PropTypes.func.isRequired, + refreshData: PropTypes.func.isRequired, + setDisabled: PropTypes.func.isRequired }; + +export default BulkSendButton; From 9b6ae4cd2d5dbb765731a4dac5367582da261947 Mon Sep 17 00:00:00 2001 From: Cody Gordon Date: Mon, 9 Oct 2023 10:15:35 -0700 Subject: [PATCH 07/15] remove package.json browser crypto fix --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index f3a43d301..98e05264d 100644 --- a/package.json +++ b/package.json @@ -232,8 +232,5 @@ "react-tooltip": "^4.2.13", "recompose": "^0.30.0", "webpack-cli": "^4.7.2" - }, - "browser": { - "crypto": false } } From f2b1689d78b7cb252dcf803c09c8cf3d70efd55b Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Fri, 13 Oct 2023 14:54:03 -0700 Subject: [PATCH 08/15] Update HOWTO-configure-auth0.md --- docs/HOWTO-configure-auth0.md | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/HOWTO-configure-auth0.md b/docs/HOWTO-configure-auth0.md index 6e01eb44d..9760064da 100644 --- a/docs/HOWTO-configure-auth0.md +++ b/docs/HOWTO-configure-auth0.md @@ -21,14 +21,25 @@ variables. + **Allowed Logout URLs** - `https://yourspoke.example.com/logout-callback` + **Allowed Origins (CORS)** - `https://yourspoke.example.com` 5. In Advanced Settings, under the OAuth section, turn off 'OIDC Conformant'. -6. Add a [new empty rule](https://manage.auth0.com/#/rules/create) in Auth0: +6. Navigate to [Actions Library](https://manage.auth0.com/#/actions/library). +7. Click "Build Custom". +8. Enter the following fields: + * Name: `Spoke Action` + * Trigger: `Login / Post Login` + * Runtime: `` +9. Click "Create". +10. In the code block of the Actions Code Editor, update the `exports.onExecutePostLogin` code as follows: ```javascript -function (user, context, callback) { -context.idToken["https://spoke/user_metadata"] = user.user_metadata; -callback(null, user, context); -} +exports.onExecutePostLogin = async (event, api) => { + api.idToken.setCustomClaim("https://spoke/user_metadata", event.user.user_metadata); +}; ``` -7. Update the Auth0 [Universal Landing page](https://manage.auth0.com/#/login_page), click on the `Customize Login Page` toggle, and copy and paste following code in the drop down into the `Default Templates` space: +11. Click `Deploy`. +12. Navigate to [Actions Flows](https://manage.auth0.com/#/actions/flows). +13. Click "Login". +14. Add "Spoke Action" to the Login flow. +15. Click "Apply". +16. Update the Auth0 [Universal Landing page](https://manage.auth0.com/#/login_page), click on the `Customize Login Page` toggle, and copy and paste following code in the drop down into the `Default Templates` space:
Code to paste into Auth0 @@ -125,4 +136,4 @@ callback(null, user, context); ```
-8. Replace `YOUR_TOS_LINK_HERE` with the link to your Terms of Service and replace `YOUR_PRIVACY_POLICY_LINK_HERE` with the link to your Privacy Policy +17. Replace `YOUR_TOS_LINK_HERE` with the link to your Terms of Service and replace `YOUR_PRIVACY_POLICY_LINK_HERE` with the link to your Privacy Policy From 7e6cdf2ebbdaa36386762990158bef43785f043c Mon Sep 17 00:00:00 2001 From: Cody Gordon Date: Fri, 27 Oct 2023 14:05:37 -0700 Subject: [PATCH 09/15] increase actions test timeouts to 15 min --- .github/workflows/cypress-tests.yaml | 2 +- .github/workflows/jest-tests.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cypress-tests.yaml b/.github/workflows/cypress-tests.yaml index 02e8f3273..82f773c6c 100644 --- a/.github/workflows/cypress-tests.yaml +++ b/.github/workflows/cypress-tests.yaml @@ -5,7 +5,7 @@ on: [push] jobs: test: runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 15 strategy: matrix: node-version: [16.x] diff --git a/.github/workflows/jest-tests.yaml b/.github/workflows/jest-tests.yaml index 76f5df1ca..d1eb44003 100644 --- a/.github/workflows/jest-tests.yaml +++ b/.github/workflows/jest-tests.yaml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: test: runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 15 strategy: matrix: node-version: [14.x, 15.x, 16.x] @@ -41,7 +41,7 @@ jobs: run: yarn test test-rediscache-contactcache: runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 15 services: redis: image: redis @@ -74,7 +74,7 @@ jobs: run: yarn test-rediscache-contactcache test-rediscache: runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 15 services: redis: image: redis @@ -107,7 +107,7 @@ jobs: run: yarn test-rediscache test-sqlite: runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 15 services: redis: image: redis From 27b6f29fa6943ca9a8612411c6c438618644b184 Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Fri, 8 Dec 2023 15:03:01 -0800 Subject: [PATCH 10/15] Update release notes --- README.md | 4 ++-- docs/RELEASE_NOTES.md | 11 +++++++++++ package.json | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8b1a48417..53631431a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Spoke is an open source text-distribution tool for organizations to mobilize sup Spoke was created by Saikat Chakrabarti and Sheena Pakanati, and is now maintained by MoveOn.org. -The latest version is [13.1.0](https://github.com/StateVoicesNational/Spoke/tree/13.1.0) (see [release notes](https://github.com/StateVoicesNational/Spoke/blob/main/docs/RELEASE_NOTES.md#v1310)) +The latest version is [13.2.0](https://github.com/StateVoicesNational/Spoke/tree/13.2.0) (see [release notes](https://github.com/StateVoicesNational/Spoke/blob/main/docs/RELEASE_NOTES.md#v1320)) ## Setting up Spoke @@ -29,7 +29,7 @@ Want to know more? ### Quick Start with Heroku This version of Spoke suitable for testing and, potentially, for small campaigns. This won't cost any money and will not support production(aka large-scale) usage. It's a great way to practice deploying Spoke or see it in action. - + Deploy diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index db23fc126..6e2d507df 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -1,5 +1,16 @@ # Release Notes +## v13.2.0 +_December 2023_ Version 13.2.0 + +13.2.0 is a minor release. + +### Improvements +* Additional error catching + +### Appreciations +* [Arique Aguilar](https://github.com/Arique1104), [Cody Gordon](https://github.com/codygordon), [Kathy Nguyen](https://github.com/crayolakat), and Harold Travis for QA. + ## v13.1.0 _October 2023_ Version 13.1.0 diff --git a/package.json b/package.json index 480488034..542938e22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spoke", - "version": "13.1.0", + "version": "13.2.0", "description": "Spoke", "main": "src/server", "engines": { From 1c0eba3e7644f39156b6dbfdd4457ee161a78636 Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Fri, 8 Dec 2023 15:05:53 -0800 Subject: [PATCH 11/15] Update RELEASE_NOTES.md --- docs/RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 6e2d507df..5edcb4de0 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -7,6 +7,7 @@ _December 2023_ Version 13.2.0 ### Improvements * Additional error catching +* Update bug report template ### Appreciations * [Arique Aguilar](https://github.com/Arique1104), [Cody Gordon](https://github.com/codygordon), [Kathy Nguyen](https://github.com/crayolakat), and Harold Travis for QA. From 9555186b25679aec2bfa8b79969bea7fddce4cfb Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Fri, 8 Dec 2023 15:07:50 -0800 Subject: [PATCH 12/15] Update RELEASE_NOTES.md --- docs/RELEASE_NOTES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 5edcb4de0..956673dcf 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -5,6 +5,9 @@ _December 2023_ Version 13.2.0 13.2.0 is a minor release. +### Bug Fixes +* Set contactTimeszones for campaign when Redis is disabled + ### Improvements * Additional error catching * Update bug report template From 4d3b134f3543742f2649797b576151d52bd3123b Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Fri, 8 Dec 2023 15:09:23 -0800 Subject: [PATCH 13/15] Update RELEASE_NOTES.md --- docs/RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 956673dcf..4591480ba 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -11,6 +11,7 @@ _December 2023_ Version 13.2.0 ### Improvements * Additional error catching * Update bug report template +* Indicate progress in UI for bulk send ### Appreciations * [Arique Aguilar](https://github.com/Arique1104), [Cody Gordon](https://github.com/codygordon), [Kathy Nguyen](https://github.com/crayolakat), and Harold Travis for QA. From 30c56fc8f59ec40481ac212c2868eaf364fcd720 Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Fri, 8 Dec 2023 15:11:06 -0800 Subject: [PATCH 14/15] Update RELEASE_NOTES.md --- docs/RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 4591480ba..c74264125 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -12,6 +12,7 @@ _December 2023_ Version 13.2.0 * Additional error catching * Update bug report template * Indicate progress in UI for bulk send +* Support for PostgreSQL 15 ### Appreciations * [Arique Aguilar](https://github.com/Arique1104), [Cody Gordon](https://github.com/codygordon), [Kathy Nguyen](https://github.com/crayolakat), and Harold Travis for QA. From c822e8d46909db72059a8ea83ce9502dc79d2a49 Mon Sep 17 00:00:00 2001 From: Kathy Nguyen Date: Fri, 8 Dec 2023 15:12:28 -0800 Subject: [PATCH 15/15] Update RELEASE_NOTES.md --- docs/RELEASE_NOTES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index c74264125..5cf197b57 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -6,13 +6,14 @@ _December 2023_ Version 13.2.0 13.2.0 is a minor release. ### Bug Fixes -* Set contactTimeszones for campaign when Redis is disabled +* Set contactTimezones for campaign when Redis is disabled ### Improvements * Additional error catching * Update bug report template * Indicate progress in UI for bulk send * Support for PostgreSQL 15 +* Update Auth0 instructions ### Appreciations * [Arique Aguilar](https://github.com/Arique1104), [Cody Gordon](https://github.com/codygordon), [Kathy Nguyen](https://github.com/crayolakat), and Harold Travis for QA.