Questions for Confluence license has expired.

Please purchase a new license to continue using Questions for Confluence.

Account for internal comments when using mentions handling

 
1
0
-1

I am currently synchronising a Jira Service Desk instance with a Jira Software instance. To sync comments I am using the following outgoing sync

replica.comments = issue.comments.findAll{!it.internal}


I want to to sanitize mentions when synchronizing issues as shown here:

https://community.atlassian.com/t5/Agile-articles/How-to-sanitize-mentions-when-synchronizing-issues/ba-p/1141139


How do I add internal comments handling to the following code block in our outgoing sync?

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

I need to ensure that I am not sending any internal comments, I tried the following, but that introduced a NULL exception:

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

    You may try the following:

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

    Kind regards,

    Ariel

  2. Waleed Al-Dabbas

    Hi Ariel,

    My understanding is this would make all comments sync (including internal comments). What I am want to do is to ensure that I do not send internal comments.


    Thank you and kind regards,

    Waleed

  3. Ariel Aguilar

    I see..

    Try this:

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

    Kind regards,

    Ariel

CommentAdd your comment...