I need to modify MailListener.java (for Jira version 7.0.10) to NOT send out email if the current logged-in user is <some-userid>.
Here's the code snippet of MailListener.java :
........... import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.user.ApplicationUser; .............. private static final ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(); ...... @EventListener public void handleIssueEventBundle(final IssueEventBundle bundle) { if (currentUser == null) { log.error("Cannot determine current logged-in user"); // <<<<--------- this error shows up in the log return; } if (currentUser.getUsername().equals(specialUser)) { log.debug("1. Ignore sending email notification because user=[" + currentUser.getUsername() + "]"); return; } issueEventBundleMailHandler.handle(bundle); }
In the atlassian-jira.log, i see:
[c.a.j.e.listeners.mail.MailListener] Cannot determine current logged-in user
What is the correct way to get the current logged-in user in MailListener.java ?
Hi @Andrew L ,
I don't understand what is mailListener, both mail handlers and listeners are executed by system and not by a specific user. This should be reason why you can't retrieve the current ulogged user.
Fabio
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.