How to check comment permissions for a user in email template?

Hi everyone,

I've made a post-function on a workflow transition to send an email notification. I need to include the last comment but only if the reporter (to whom I am sending this notification) has permission to see it.

I have found this class 

com.atlassian.jira.issue.comments.DefaultCommentPermissionManager

which has a function to do exactly that I believe

hasBrowsePermission(User user, Comment comment)

but trying to get in in the groovy template gives errors. The constructor requires a load of other elements (and going further recursively) and I haven't found a way to get this object in the template.

This said, I have two questions:

  • is there a way to check the user's permissions to see a comment in the groovy email template and if so, how can I do that?
  • if the above mentioned class is the solution, how can I possibly get the object in the template?

Thanks a lot, it's a real blocker.

Update: which comment does actually get the reporter? I look at a preview with lastComment for one issue and it automatically skips the last comment if it is internal and gives me last public. On a different issue it gives me last even if internal. If by chance the preview content depends on who's previewing, what does then go to the user?

1 answer

1 accepted

Resolved. It is enough to get a list of all the comments on a particular issue that the user is allowed to see

componentManager.getCommentManager().getCommentsForUser(issue, issue.getReporter())

If you have a comment, get its ID and check if it's among the IDs of the comments in the list above.

Update: This will never work with Service Desk, which uses a completely different system of comment visibility management. Currently, Service Desk support proclaims it impossible to get the information by a script in any way.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,316 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot