dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20063
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9026: Made it possible to force send messages/emails. Useful e.g. when sending password restore messages.
------------------------------------------------------------
revno: 9026
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-11-14 14:11:10 +0100
message:
Made it possible to force send messages/emails. Useful e.g. when sending password restore messages.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageSender.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/EmailMessageSender.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/message/MockMessageSender.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageSender.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageSender.java 2012-03-09 11:46:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/message/MessageSender.java 2012-11-14 13:11:10 +0000
@@ -42,6 +42,7 @@
* @param subject the message subject.
* @param text the message text.
* @param users the users to send the message to.
+ * @param forceSend force sending the message despite potential user settings.
*/
- void sendMessage( String subject, String text, User sender, Set<User> users );
+ void sendMessage( String subject, String text, User sender, Set<User> users, boolean forceSend );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java 2012-11-07 09:08:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java 2012-11-14 13:11:10 +0000
@@ -273,7 +273,7 @@
{
for ( MessageSender messageSender : messageSenders )
{
- messageSender.sendMessage( subject, text, sender, users );
+ messageSender.sendMessage( subject, text, sender, users, false );
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/EmailMessageSender.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/EmailMessageSender.java 2012-10-29 20:17:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/EmailMessageSender.java 2012-11-14 13:11:10 +0000
@@ -89,7 +89,7 @@
*/
@Async
@Override
- public void sendMessage( String subject, String text, User sender, Set<User> users )
+ public void sendMessage( String subject, String text, User sender, Set<User> users, boolean forceSend )
{
String hostName = StringUtils.trimToNull( (String) systemSettingManager.getSystemSetting( KEY_EMAIL_HOST_NAME ) );
String username = StringUtils.trimToNull( (String) systemSettingManager.getSystemSetting( KEY_EMAIL_USERNAME ) );
@@ -119,8 +119,10 @@
for ( User user : users )
{
boolean emailNotification = settings.get( user ) != null && (Boolean) settings.get( user ) == true;
+
+ boolean doSend = forceSend || emailNotification;
- if ( emailNotification && user.getEmail() != null && !user.getEmail().trim().isEmpty() )
+ if ( doSend && user.getEmail() != null && !user.getEmail().trim().isEmpty() )
{
email.addBcc( user.getEmail() );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java 2012-10-31 05:41:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java 2012-11-14 13:11:10 +0000
@@ -145,8 +145,8 @@
String text1 = new VelocityManager().render( vars, "restore_message1" );
String text2 = new VelocityManager().render( vars, "restore_message2" );
- emailMessageSender.sendMessage( "User account restore confirmation (message 1 of 2)", text1, null, users );
- emailMessageSender.sendMessage( "User account restore confirmation (message 2 of 2)", text2, null, users );
+ emailMessageSender.sendMessage( "User account restore confirmation (message 1 of 2)", text1, null, users, true );
+ emailMessageSender.sendMessage( "User account restore confirmation (message 2 of 2)", text2, null, users, true );
return true;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/message/MockMessageSender.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/message/MockMessageSender.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/message/MockMessageSender.java 2012-11-14 13:11:10 +0000
@@ -35,7 +35,7 @@
implements MessageSender
{
@Override
- public void sendMessage( String subject, String text, User sender, Set<User> users )
+ public void sendMessage( String subject, String text, User sender, Set<User> users, boolean forceSend )
{
// Do nothing
}