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
|
|
@ -704,30 +704,55 @@ sub getId {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getInboxAddresses ( )
|
||||
=head2 getInboxNotificationAddresses ( )
|
||||
|
||||
Return a string with addresses that the user wants to receive Inbox
|
||||
notifications. If the user does not want Inbox notifications, then
|
||||
the string will be empty.
|
||||
|
||||
This is called by L<WebGUI::Mail::Send>, and has the effect that if
|
||||
the site C<sendInboxNotificationsOnly> setting is on and the user
|
||||
has turned off C<receiveInboxEmailNotifications>, no email at all is
|
||||
sent.
|
||||
|
||||
=cut
|
||||
|
||||
sub getInboxAddresses {
|
||||
sub getInboxNotificationAddresses {
|
||||
my $self = shift;
|
||||
my $emails = '';
|
||||
if ( $self->profileField('receiveInboxEmailNotifications')
|
||||
&& $self->profileField('email')) {
|
||||
$emails = $self->profileField('email');
|
||||
}
|
||||
if ( $self->profileField('receiveInboxSmsNotifications')
|
||||
&& $self->profileField('cellPhone')
|
||||
&& $self->session->setting->get('smsGateway')) {
|
||||
$emails .= ',' if $emails;
|
||||
my $phoneNumber = $self->profileField('cellPhone');
|
||||
$phoneNumber =~ tr/0-9//dc; ##remove nonnumbers
|
||||
$emails = join '', $emails, $phoneNumber, '@', $self->session->setting->get('smsGateway');
|
||||
}
|
||||
return $emails;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getInboxSmsNotificationAddress ( )
|
||||
|
||||
Return the email address that SMS notifications will be sent to for
|
||||
this user, constructed as:
|
||||
|
||||
cellPhone@smsGateway
|
||||
|
||||
=cut
|
||||
|
||||
sub getInboxSmsNotificationAddress {
|
||||
my $self = shift;
|
||||
|
||||
return unless $self->profileField('receiveInboxSmsNotifications');
|
||||
|
||||
my $smsGateway = $self->session->setting->get('smsGateway');
|
||||
return unless $smsGateway;
|
||||
|
||||
my $cellPhone = $self->profileField('cellPhone');
|
||||
return unless $cellPhone;
|
||||
|
||||
# Remove non-numbers from cellPhone
|
||||
$cellPhone =~ tr/0-9//dc;
|
||||
|
||||
return join q{}, $cellPhone, '@', $smsGateway;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue