Skip to content

Commit

Permalink
Merge pull request #7657 from mcalmer/fix-notification-email-content
Browse files Browse the repository at this point in the history
fix notification messages email content
  • Loading branch information
mcalmer authored Oct 9, 2023
2 parents 4fac60b + 0a324bc commit 7f657d3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public static void storeForUsers(NotificationMessage notificationMessageIn, Set<
message += "\n\n" + data.getDetails();
}
MailHelper.withMailer(mailer)
.sendEmail(receipients, subject, message.replaceAll("<.+>", ""));
.sendEmail(receipients, subject, message.replaceAll("<[^>]*>", ""));
}
}
// Update Notification WebSocket Sessions right now
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.redhat.rhn.domain.notification.UserNotification;
import com.redhat.rhn.domain.notification.UserNotificationFactory;
import com.redhat.rhn.domain.notification.types.OnboardingFailed;
import com.redhat.rhn.domain.notification.types.StateApplyFailed;
import com.redhat.rhn.domain.role.RoleFactory;
import com.redhat.rhn.testing.BaseTestCaseWithUser;
import com.redhat.rhn.testing.TestUtils;
Expand Down Expand Up @@ -60,6 +61,23 @@ public final void testVisibilityForNoRoles() {
assertEquals(1, UserNotificationFactory.listUnreadByUser(user).size());
assertEquals(1, UserNotificationFactory.listAllByUser(user).size());
mailer.verify();
assertContains(mailer.getBody(), "minion1");
}

@Test
public final void testEmailContentStripHTML() {
mailer.setExpectedSendCount(1);
UserNotificationFactory.setMailer(mailer);
assertEquals(0, UserNotificationFactory.unreadUserNotificationsSize(user));
NotificationMessage msg = UserNotificationFactory.createNotificationMessage(
new StateApplyFailed("minion1", 10000010000L, 42L));
UserNotificationFactory.storeNotificationMessageFor(msg, Collections.emptySet(), empty());

assertEquals(1, UserNotificationFactory.unreadUserNotificationsSize(user));
assertEquals(1, UserNotificationFactory.listUnreadByUser(user).size());
assertEquals(1, UserNotificationFactory.listAllByUser(user).size());
mailer.verify();
assertContains(mailer.getBody(), "minion1");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- fix notification messages email content (bsc#1216041)

0 comments on commit 7f657d3

Please sign in to comment.