Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Why if a user is referred to in an Insight comment, no notification is sent?

In an insight object, if a user refers to another jira user with @Name, one would expect an  email notification to be sent. I can't see anything in Insight or Jira settings that support or prevent this notification. I've looked at the automation, and it doesn't seem to be configurable there either. Any guidance or ideas? 

2 answers

1 accepted

0 votes
Answer accepted

I ended up writing a messy groovy script. Take this with a grain of salt. 

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.user.util.UserManager
import com.atlassian.crowd.embedded.api.CrowdService
import com.atlassian.crowd.embedded.api.User
import com.atlassian.crowd.embedded.api.UserWithAttributes
import com.atlassian.crowd.embedded.impl.ImmutableUser
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.user.util.UserUtil
import java.util.regex.Pattern
import java.util.regex.Matcher
import com.atlassian.jira.mail.Email;
import com.atlassian.mail.queue.SingleMailQueueItem;
import com.atlassian.mail.server.MailServerManager;
import com.atlassian.mail.server.SMTPMailServer;
/* Custom field for the organisation */
CustomField insightObjectCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10000);

if (insightObjectCF == null) {
return false;
MailServerManager mailServerManager = ComponentAccessor.getMailServerManager();

def currentUserEmail = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getEmailAddress();

/* The object facade class */
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)
def objectKey = object.getObjectKey()
def insightObject = objectFacade.loadObjectBean(objectKey)
int objectId = insightObject.getId()

def commentList = objectFacade.findCommentBeans(objectId);
def commentLast = commentList.last();
def commentID = commentLast.getId();
def comment = commentLast.getComment();
/*def s1 = comment.substring(comment.indexOf("[")+1);
def userName = s1.replaceAll("[^a-zA-Z0-9]", ""); */
UserUtil userUtil = ComponentAccessor.userUtil
CrowdService crowdService = ComponentAccessor.crowdService
UserService userService = ComponentAccessor.getComponent(UserService.class)

def subject = "New Insight Comment from Object " + objectId
def objectUrl = ""+objectId
def body = "New comment from issue \n <br>" + objectUrl + "\n <br> "+ comment

/* Log the Insight object */"Insight object of key: " + objectId);"Logged in user " + currentUserEmail);
//"User " + user + " "+ emailAddr );"Comment " + body );


/* Pattern match to get email addresses*/
String myRegex=/(?<=\~)([\w.]+)/
String myInput = comment;

String ResultString
Pattern regex
Matcher regexMatcher

regex = Pattern.compile(myRegex, Pattern.DOTALL);

regexMatcher = regex.matcher(myInput);

List<String> matchList = new ArrayList<String>();
List<String> emails = new ArrayList<String>();

while (regexMatcher.find()) {

for(int i=0;i<matchList.size();i++)
myInput=myInput.replaceAll( matchList[i], '')
def user = ComponentAccessor.userManager.getUserByKey(matchList[i])
emails[i]= user.getEmailAddress();[i] +" " + emails[i])

/*Send email*/
def sendEmail(String emailAddr, String subject, String body, String currentUserEmail) {
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer();
if (mailServer) {
Email email = new Email(emailAddr);
mailServer.send(email);"Mail sent " +emailAddr)
} else {"Problem getting the mail server from JIRA configuration, log this error")

for(int i=0;i<emails.size();i++)
sendEmail( emails[i], subject, body, currentUserEmail)

return true;

I can't see anything in Insight or Jira settings that support or prevent this notification. I've looked at the automation, and it doesn't seem to be configurable there either. Any guidance or ideas? 

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events