I have multiple workflows and listeners send custom emails. Why do deactivated users continue to receive custom emails? How can I stop this? Is there a condition I should be checking for?
You can check whether a user is active or not by the isActive() method in the ApplicaitonUser class. If a user is inactive, you should not send a email.
I have put the following in the Condition and Configuration section of the Send a Custom Email Listener. Still emailing inactive users.
import com.atlassian.jira.component.ComponentAccessor
def locale = ComponentAccessor.getLocaleManager().getLocalefor(currentUser)
def approversCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Approvers")
def watchers = ComponentAccessor.getWatcherManager().getWatchers(issue,locale)
def validUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().isActive()
def recipientsTo = issue.getCustomFieldValue(approversCF)?.findAll {validUser}?.collect {it.emailAddress}?.join(";")
mail.setTo(recipientsTo)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.