Hello,
Could not find the related question to my problem, sorry if it is duplicates.
I am using default script listner "Send custom email" to send notification to all watchers about adding new comment to issue. But customers complained that they recieve own comment after adding one.
Is there any wat to add a condition on field "To issue fields" to exclude comment.author? I am not very experienced in java and haven`t written own listner - if it is the only way to solve the situation, any hints where I should start fromwill be highly appreciated!
Thanks in advance!
Community moderators have prevented the ability to post new answers.
Upd:
I ve changed the method getAddressesFromFields, condition f=="watchers":
Set getAddressesFromFields(Issue issue, String toConfig) {
Set addresses = new HashSet()
if (! toConfig) {
return addresses
}
// for testing: "reporter,assignee, watchers, customfield_10020, customfield_10040, customfield_10041, customfield_10042, customfield_10043, group:"a b""
String patStr = /([^\s]*"[^"]*")|([^\s"']+)/
Matcher matcher = toConfig =~ patStr
log.debug("toConfig: \"$toConfig\"")
if (matcher.getCount() == 0) {
return []
}
for (int i in 0..matcher.getCount()-1) {
String f = matcher[i][0]
if (f) {
f = f.trim()
log.debug ("field f: \"$f\"")
if(['reporter', 'assignee'].contains(f)) {
addresses.add((issue.getAt(f) as User)?.emailAddress)
}
else if (f == "watchers") {
watcherManager.getCurrentWatcherUsernames(issue.genericValue).each {String username -> if (componentManager.getCommentManager().getComments(issue).last().author != user.util.getUser(username))
addresses.add(userUtil.getUser(username).emailAddress)
}
}
I checked it in script console, validation went well. But I got stuck with adding my custom listner... I found related question https://answers.atlassian.com/questions/90489/where-to-add-the-groovy-file-for-a-custom-listener but it couldnt help
I added my file to atlassian-jira\WEB-INF\classes\custom\listeners\SendCustomEmailTest.groovy
image2015-3-6 15:14:45.png
After publishing I thought that there is a source of "Send custom email" listner and all I need is changing next part of code by adding condition for author comment:
List getAllToAddresses(Issue issue, Map params) {
String toUserFields = params[FIELD_TO_USER_FIELDS]
Set addresses = getAddressesFromFields(issue, toUserFields)
addresses.addAll(getTextAddresses(params[FIELD_TO_ADDRESSES] as String))
addresses.toList()
}
Am I on the right way?
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.