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

How to sanitize mentions when synchronizing issues

(I'm Francis - product manager for Exalate - an issue synchronisation solution)

 

Challenge

Last week, we got following request -

 

Hi Francis,

 

We are using a competing issue synchronisation solution.  One of the problems we encounter is that whenever we synchronise a comment, the mentions in that comment are also synchronised - triggering confusing notifications - especially when there are overlapping user id's

 

Ie. For instance you have @peter in the comment.  The comment gets synchronised to the other instance, which triggers a 'You have been mentioned' notification to a complete different Peter (who happens to have the same userid)

 

How would Exalate deal with it.

 

Challenge accepted!

 

Ideally, all the mentions in comments sent to the other side are replaced with the name of the person mentioned.  So what should happen

 

Whenever composing the outgoing synchronization message (aka the data filter)

  • For every comment
    • For every mention in the comment
      • Look up the user being mentioned
      • Replace the mention with the name of the mentioned person

 

With the groovy based scripting engine, it is pretty straightforward to have it done

mentionsanitizer2.png

 

  • Line 18 - iterate over all the issue comments
  • Line 21 - RegEx which collects all the mentions in the comment body
    A mention is stored as [~<userid>]
  • Line 24 - Iterate over all the mentions found in the body
  • Line 25 - Look up the mentioned user object using the nodeHelper.getUser
    • If the user is found, set target to display name
    • if the user is not found, set target to the userid of the user
  • Line 26 - Replace all the mentions for this specific user to the constructed target
  • Line 29 - Assign the new comment body to the comment

(The code snippet above can be found here)

What is the effect

Now whenever someone creates a comment on the source like following message

result1.png

 

 

The piece of groovy code will replace the mentions of Peter and Angie with their Full Name, and send this over to the other side, resulting in 

result2.png

 

 

Other use cases

 

This is just an example of what the flexibility provided by Exalate allows to do. 
You can imagine that you want to filter out the names of the people (for security or GDPR reasons) or map the mentioned users from the source user to the target user.

 

Many more use cases can be implemented.  We are looking forward to solving your synchronization challenges.  Welcome to book a meeting here

 

 

 

 

4 comments

sebastien_pastor January 12, 2021

Hi @francis , 

Thanks for this use case, really helpful.

Related challenge: How would you assign a ticket to a user then given it is not in the source system ? 

 

Thank you,

francis
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
January 17, 2021

What is the logic behind it.  You can always look up the right assignee using the nodeHelper.getUserByEmail  method (or similar), and set the assignee accordingly

 

btw - Checkout the exalate community there are many similar cases being discussed.

Semi Ajibola February 3, 2021

I haven't had much luck with this and have a few questions.

Is the [~<userid>] format unique to how exalate packages the data during the outgoing sync?  I don't think that format holds up on the Jira side for user mentions.

Is this meant to be configured in the outgoing sync rule of the source cloud project?

Are there any considerations for the incoming sync rules on the target server project?

 

Thanks.

Nutanix_Jira-admin March 4, 2021

Hi @Semi Ajibola ,

I am not sure if I understand your question but let me give it a try. In our connection Cloud <-> Server, I have modified the script in outgoing sync of the cloud project, so that it can change the format of user mention from cloud to server format. Below is the script

{code}

replica.comments = issue.comments.collect {
comment ->

def matcher = comment.body =~ /\[~accountid:(\w+)\]/
def newCommentBody = comment.body

matcher.each {
target = nodeHelper.getUser(it[1])?.email?: it[1]
String[] name = target.split("@")
String mention = "[~"+name[0]+"]"
newCommentBody = newCommentBody.replace(it[0],mention)
}

comment.body = newCommentBody
comment
}

{code}

TAGS
AUG Leaders

Atlassian Community Events