Converting user mentions in the cloud format when there is an incoming sync from the DC/Server

Originally asked by Eshwar Palem on 18 March 2021 (original question)


Hi there,

Can someone help me in modifying the script, so that when there is incoming sync of comments from Server/DC to cloud Jira it should convert user mentions in the cloud format so that it updates properly in the comments?

I have managed to do this on Server/DC Jira when there is incoming sync from the cloud. However, I am facing difficulties while doing the same for the cloud.

Please help me with this.

Thanks,

Eshwar.


Comments:

Serhiy Onyshchenko commented on 19 March 2021

Hey, Eshwar Palem, might I ask you to share your Outgoing sync script from on-prem
and your incoming sync script for cloud (maybe just the parts concerning comments)?

Answer by Serhiy Onyshchenko on 19 March 2021

Also have you seen this article?
https://community.atlassian.com/t5/Agile-articles/How-to-sanitize-mentions-when-synchronizing-issues/ba-p/1141139
you could replace every mention sent from server with email:

/*
** This code snippet illustrates how mentions can be replaced with the actual name of the mentionee
** Use this in a data filter
*/


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

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

              matcher.each {
                  target = "[~$nodeHelper.getUser(it[1])?.email]"
                  newCommentBody = newCommentBody.replace(it[0], target)
              }

              comment.body = newCommentBody
              comment
}

And then use similar logic on cloud to lookup a user using email
Please, let me know if this helps