How to Impersonate a Comment in Jira Cloud

    Note: It is not possible to impersonate comments in Basic connections.

    By default, Exalate adds a comment, received from the other side on behalf of the proxy user.

    The comment looks like the following:

    Source side

    Outgoing sync 

    To send comments to the destination instance use the following script:

    replica.comments = issue.comments

    Destination side

    1. Modify the comment body on each received comment to add the comment author via helper methods

    With the help of commentHelper methods, you can manipulate comments and define how to apply received comments on the local issue.

    Incoming sync

    // Format each remote comment - add the author
     
    issue.comments = commentHelper.mergeComments(issue, replica,                     
                        {
                           comment ->
                           comment.body =
                              "[" + comment.author.displayName +
                                      "| email: " + comment.author.email + "]" +
                                      " commented: \n" +
                              comment.body + "\n"
                        }
    )

    2. Assign the original comment author if exists in the local system, use the proxy user if not found

    This method works for Jira Server and Jira Cloud.

    Incoming sync

    • Change the comment executor from the proxy user to the original comment author
    • If the author does not exist in the local JIRA, use the proxy user as an author
    replica.addedComments.each { it.executor = nodeHelper.getUserByEmail(it.author?.email) }
    replica.changedComments.each { it.executor = nodeHelper.getUserByEmail(it.updateAuthor?.email) }
    issue.comments = commentHelper.mergeComments(issue, replica, { it })

    Result

    The first comment was created by the proxy user, while the second comment was impersonated and the local administrator is the comment executor.