Note
We've packed up and moved from Confluence to Discourse to bring you a better, more interactive space. Out of courtesy we didn't migrate your user account so - you will have to signup again
The Exalate team will be on holiday for the coming days - returning Jan 4
Enjoy & stay safe
Hi dear Exalate Community,
I have a question regarding comments sync. We want to impersonate the author on the respective remote side and at the same time sanatize the mentions in the comment body. Stand alone both works using the following script snippets.
Impersonate comment author:
replica.addedComments.each
{ it.executor = nodeHelper.getUserByFullName(it.author.displayName) }
replica.changedComments.each
{ it.executor = nodeHelper.getUserByFullName(it.updateAuthor.displayName) }
issue.comments = commentHelper.mergeComments(issue, replica,
{it}
)
Sanatize Comment Mention:
def mentionFormat = replica.comments.collect {
comment ->
def matcher = comment.body =~ /{([^\}]*)}/
def newCommentBody = comment.body
matcher.each
{ target = nodeHelper.getUserByFullName(it[1])?.username ?: it[1] targetTarget = "[~$target]" newCommentBody = newCommentBody.replace(it[0],targetTarget) }
comment.body = newCommentBody
comment
}
As said this works great stand alone but when both are active depending on which comes first in the script only one function is applied.
We have tried the following in different variations but I don't seem to be able to get it work:
issue.comments = commentHelper.mergeComments(issue, replica, {
if (it.author) it.executor = it.author
else it.executor = nodeHelper.getUserByEmail(it.author.displayName);
replica.comments.collect {
comment ->
def matcher = comment.body =~ /{([^\}]*)}/
def newCommentBody = comment.body
matcher.each
{ target = nodeHelper.getUserByFullName(it[1])?.username ?: it[1] targetTarget = "[~$target]" newCommentBody = newCommentBody.replace(it[0],targetTarget) }
comment.body = newCommentBody
comment
})
I know this would be a good addition to the community but I really need this to work by Friday and I am running out of time. It would be great if someone could help.
Cheers
Max