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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.