Stop the notification Compose form from defaulting to "email everyone"
The Compose form's "Send to" radio group had "All active users" checked by default with no confirmation before Send -- anyone opening the Dashboard to see how the feature works, typing a test subject/message, and clicking Send would broadcast to every active user. Remove the default (a target must now be explicitly chosen) and require a confirm step before actually sending to "all" or "all_active". Also add a hard safety net in models/email.js: Mail.send is a no-op under NODE_ENV=test, so the automated test suite (which exercises the real notification/password-reset/invite/OTP-by-email routes with NODE_ENV=test) can never deliver real mail regardless of what recipient list a test resolves. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,16 @@ const conf = require('@simpleworkjs/conf');
|
||||
var Mail = {};
|
||||
|
||||
Mail.send = function(to, subject, message, from){
|
||||
// Never let the automated test suite deliver real mail — tests run against
|
||||
// this app's real routes (notification broadcast, password reset, invite,
|
||||
// OTP-by-email, …) with NODE_ENV=test, and any of them resolving a real
|
||||
// recipient list must not actually hit SMTP. Tests already tolerate this
|
||||
// (see e.g. tests/misc.test.js: "SMTP failure is non-fatal") since none
|
||||
// assert on real delivery.
|
||||
if(conf.environment === 'test'){
|
||||
return Promise.resolve({accepted: [], rejected: [], response: 'skipped: NODE_ENV=test'});
|
||||
}
|
||||
|
||||
return new Promise(function(resolve, reject){
|
||||
var transportOpts = {
|
||||
host: conf.smtp.host || 'localhost',
|
||||
|
||||
Reference in New Issue
Block a user