Skip to content

Commit

Permalink
Respect user email preferences when sending 'user creation' emails (b…
Browse files Browse the repository at this point in the history
…sc#1214553) (#22550)

(cherry picked from commit 4c1e776)
  • Loading branch information
cbbayburt committed Sep 29, 2023
1 parent baf09e4 commit c43b0dd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
14 changes: 5 additions & 9 deletions java/code/src/com/redhat/rhn/frontend/events/NewUserAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.logging.log4j.Logger;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -94,14 +93,11 @@ public void execute(EventMessage msg) {


private String[] getEmails(NewUserEvent evt) {
List adminList = evt.getAdmins();
String[] adminEmails = new String[adminList.size()];
int index = 0;
for (Object oIn : adminList) {
adminEmails[index] = ((User) oIn).getEmail();
index++;
}
return adminEmails;
return evt.getAdmins().stream()
.filter(u -> !u.isDisabled())
.filter(u -> u.getEmailNotify() == 1)
.map(User::getEmail)
.toArray(String[]::new);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class NewUserEvent extends BaseEvent implements EventMessage {
private User accountCreator;
private String link;
private String domain;
private List adminList;
private List<User> adminList;

/**
* format this message as a string
Expand Down Expand Up @@ -142,13 +142,13 @@ public void setLink(String passwordIn) {
/**
* @return Returns the link.
*/
public List getAdmins() {
public List<User> getAdmins() {
return adminList;
}
/**
* @param admins Admins to set.
*/
public void setAdmins(List admins) {
public void setAdmins(List<User> admins) {
this.adminList = admins;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public ValidatorError[] validate() {
* might be encrypted, thus useless for this method
*/
public void publishNewUserEvent(User accountCreator,
List admins,
List<User> admins,
String domain,
String password) {
NewUserEvent userevt = new NewUserEvent();
Expand Down
1 change: 1 addition & 0 deletions java/spacewalk-java.changes.cbbayburt.bsc1214553
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Respect user email preferences when sending 'user creation' emails (bsc#1214553)

0 comments on commit c43b0dd

Please sign in to comment.