Syncing comment with limited visibility while using other comment functions

Originally asked by Jillani Fazal on 14 July 2022 (original question)


I am trying to sync comments with limited visibility ( E.g. when you limit the visibility of a comment to Administrators) to another instance. My understanding is that I should be able to do that with the following code for outgoing sync:

replica.comment = issue.comments.findAll

However, I am currently using the following code block in the outgoing sync to hide account IDs:

replica.comments = issue.comments.collect {
    comment ->
     
    def matcher  = comment.body =~ /\[~([\w:-]+)\]/
    def newCommentBody = comment.body
     
    matcher.each {
 
        target = nodeHelper.getUser(it[1])?.displayName ?: "Mentioned User"
        newCommentBody = newCommentBody.replace(it[0],target)
    }
 
    comment.body = newCommentBody
    comment
} 

Is there a way to sync comments with limited visibility while preserving the function I am currently using to hide account IDs?

  
  
  


Comments:

Ariel Aguilar commented on 14 July 2022

You may do the following:

replica.comments = issue.comments.collect {
    comment ->
     
    def matcher  = comment.body =~ /\[~([\w:-]+)\]/
    def newCommentBody = comment.body
     
    matcher.each {
 
        target = nodeHelper.getUser(it[1])?.displayName ?: "Mentioned User"
        newCommentBody = newCommentBody.replace(it[0],target)
    }
 
    comment.body = newCommentBody
    comment.roleLevel = "team"
    comment
} 

Kind regards,

Ariel