How to sync author in a comment between GitHub and Jira

Originally asked by Ben Paz on 24 January 2022 (original question)


The built-in script sync uses an Exalate username in GitHub and Exalate email in Jira for an author’s name. The actual author’s displayName is prepended in the comment.

With the implementation above, is the following possible? Can a mapping be added in the scripts between username and email (in both directions)? Does the author’s key need to be removed from a comment since the author’s key is currently set to the Exalate account in the respective system? Or does the author’s key need to be replaced with the actual author’s key in issue.comments?

I do not understand how the mapping between comments is maintained as there does not appear to be a field in common between the two systems. Is the existing mapping done via examining the body of the comment?

Below is a synced comment example without mapping the actual user. If a mapping solution is possible using the replicas, please identify the changes for each side of the sync according to the example.

Jira replica side:

{
        "id": "<Jira id for comment>",
        "author": {
          "key": "<Jira Exalate account key>",
          "active": true,
          "email": "com.exalate.jiranode@connect.atlassian.com",
          "displayName": "Exalate"
        },
        "updateAuthor": {
          "key": "<Jira Exalate account key>",
          "active": true,
          "email": "com.exalate.jiranode@connect.atlassian.com",
          "displayName": "Exalate"
        },
        "body": "<displayName from GitHub> commented: one, two, three...",
        "created": 1642803714316,
        "updated": 1642803714316,
        "internal": false,
        "restrictSync": false
      }  
  
GitHub replica side:
      {
        "id": "<GitHub id for comment>",
        "author": {
          "key": "<username key from GitHub>",
          "active": false,
          "displayName": "<displayName from GitHub>",
          "username": "<username from GitHub>"
        },
        "body": "one, two, three...",
        "internal": true,
        "restrictSync": false
      }