Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I stop disabled users receiving custom notifications

Eric Collins
Contributor
May 15, 2018

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? 

1 answer

1 vote
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 15, 2018

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.

Eric Collins
Contributor
May 16, 2018

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)

Suggest an answer

Log in or Sign up to answer