Fixed a whole lot of brokenness in Inbox SMS/Email notifications
WebGUI::Inbox::Message::create now passes isInbox flag to WebGUI::Mail::Send::create so that per-user notification settings get used SMS Gateway setting field is now 'text' instead of 'email' so that user can enter a properly formed value (such as 'myemailgateway.com', which is not an email address). Added SMS notification template as distinct from email notification template because SMSs should not be HTML and in general you will want to make your SMS notification message a lot shorter than your html email notification message (160 char limits in many countries). As a result, SMSs are now sent as separate emails to gateway rather than being CCd on email notification. Added smsGatewaySubject setting because many SMS Gateways use email subject for authentication. For consistency, also added Email notification email subject. Fixed handling of different combinations of site-wide sendInboxNotificationsOnly with per-user receiveInboxEmailNotifications and receiveInboxSmsEmailNotifications. * sendInboxNotificationsOnly && receiveInboxEmailNotifications = email notification * sendInboxNotificationsOnly && !receiveInboxEmailNotifications = no email * !sendInboxNotificationsOnly = ignore receiveInboxEmailNotifications * In all cases, SMS is optional and only dependent on receiveInboxSmsEmailNotifications Updated tests and i18n
This commit is contained in:
parent
3cc02af6bb
commit
388a0b1267
12 changed files with 264 additions and 109 deletions
|
|
@ -42,7 +42,7 @@ if ( $@ ) { diag( "Can't prepare mail server: $@" ) }
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 18; # Increment this number for each test you create
|
||||
plan tests => 16; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test create
|
||||
|
|
@ -274,7 +274,6 @@ $emailUser->profileField('email', 'heywood@shawshank.gov');
|
|||
my $lonelyUser = WebGUI::User->create($session);
|
||||
WebGUI::Test->usersToDelete($lonelyUser);
|
||||
$lonelyUser->profileField('receiveInboxEmailNotifications', 0);
|
||||
$lonelyUser->profileField('receiveInboxSmsNotifications', 0);
|
||||
$lonelyUser->profileField('email', 'jake@shawshank.gov');
|
||||
|
||||
my $inboxGroup = WebGUI::Group->new($session, 'new');
|
||||
|
|
@ -300,45 +299,6 @@ SKIP: {
|
|||
|
||||
# Test the mail
|
||||
is($received->{to}->[0], '<ellis_boyd_redding@shawshank.gov>', 'send, toUser with email address');
|
||||
|
||||
$inboxUser->profileField('receiveInboxEmailNotifications', 0);
|
||||
$inboxUser->profileField('receiveInboxSmsNotifications', 1);
|
||||
|
||||
# Send the mail
|
||||
$mail = WebGUI::Mail::Send->create( $session, {
|
||||
toUser => $inboxUser->userId,
|
||||
},
|
||||
'fromInbox',
|
||||
);
|
||||
$mail->addText( 'sent via SMS' );
|
||||
|
||||
$mail->send;
|
||||
my $received = WebGUI::Test->getMail;
|
||||
|
||||
# Test the mail
|
||||
is($received->{to}->[0], '<55555@textme.com>', 'send, toUser with SMS address');
|
||||
|
||||
$inboxUser->profileField('receiveInboxEmailNotifications', 1);
|
||||
$inboxUser->profileField('receiveInboxSmsNotifications', 1);
|
||||
|
||||
# Send the mail
|
||||
$mail = WebGUI::Mail::Send->create( $session, {
|
||||
toUser => $inboxUser->userId,
|
||||
},
|
||||
'fromInbox',
|
||||
);
|
||||
$mail->addText( 'sent via SMS' );
|
||||
|
||||
$mail->send;
|
||||
my $received = WebGUI::Test->getMail;
|
||||
|
||||
# Test the mail
|
||||
cmp_bag(
|
||||
$received->{to},
|
||||
['<55555@textme.com>', '<ellis_boyd_redding@shawshank.gov>',],
|
||||
'send, toUser with SMS and email addresses'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -377,7 +337,7 @@ cmp_bag(
|
|||
\@emailAddresses,
|
||||
[
|
||||
'heywood@shawshank.gov'."\n",
|
||||
'ellis_boyd_redding@shawshank.gov,55555@textme.com'."\n",
|
||||
'ellis_boyd_redding@shawshank.gov'."\n",
|
||||
],
|
||||
'send: when the original is sent, new messages are created for each user in the group, following their user profile settings'
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue