How to get information about Jira comment reactions

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

The steps outlined on this article are provided AS-IS. This means we've had reports of them working for some customers — under certain circumstances — yet are not officially supported, nor can we guarantee they'll work for your specific scenario.

You may follow through and validate them on your own non-prod environments prior to production or fall back to supported alternatives if they don't work out.

We also invite you to reach out to our Community for matters that fall beyond Atlassian's scope of support!

Summary

Jira Comment reactions were released as part of Jira Software 8.18.x release. The "Comment Reactions" feature is available to the users through the Jira UI, but there are no available reports for this particular feature out of the box. This article aims to provide you with a few different options on how to obtain the relevant information.

Environment

Jira Core

Solution

The emoticons are stored with their Unicode value. As of today, we have the following values:

THUMBS_UP ("1f44d")
THUMBS_DOWN ("1f44e")
FIRE ("1f525")
HEART_EYES ("1f60d")
JOY ("1f602")
CRY ("1f622")

In the following sections, we will explore different options on how to obtain these emoticons for issue comments:

Jira Database

The information about the Jira issue comments and reactions can be found in the following tables:

  • jiraaction - This table stores comments.
  • comment_reaction - This table stores comment reactions.

To get the list of comments we will do a simple join. The following SQL statement will work for all supported database engines:

select 
concat(p.pkey, '-', ji.issuenum) as issue_key,
ja.id as comment_id,
cu.display_name as comment_author,
ja.actionbody as comment_body,
case
when cr.emoticon = '1f44d' then 'THUMBS_UP'
when cr.emoticon = '1f44e' then 'THUMBS_DOWN'
when cr.emoticon = '1f525' then 'FIRE'
when cr.emoticon = '1f60d' then 'HEART_EYES'
when cr.emoticon = '1f602' then 'JOY'
when cr.emoticon = '1f622' then 'CRY'
when cr.emoticon is null then 'N/A'
end reaction
from comment_reaction cr
join jiraaction ja on ja.id = cr.comment_id
join jiraissue ji on ja.issueid = ji.id
join project p on ji.project = p.id
left join app_user au on ja.author = au.user_key
left join cwd_user cu on au.lower_user_name = cu.lower_user_name;
select 
p.pkey ||'-'|| ji.issuenum as issue_key,
ja.id as comment_id,
cu.display_name as comment_author,
ja.actionbody as comment_body,
case
when cr.emoticon = '1f44d' then 'THUMBS_UP'
when cr.emoticon = '1f44e' then 'THUMBS_DOWN'
when cr.emoticon = '1f525' then 'FIRE'
when cr.emoticon = '1f60d' then 'HEART_EYES'
when cr.emoticon = '1f602' then 'JOY'
when cr.emoticon = '1f622' then 'CRY'
when cr.emoticon is null then 'N/A'
end reaction
from comment_reaction cr
join jiraaction ja on ja.id = cr.comment_id
join jiraissue ji on ja.issueid = ji.id
join project p on ji.project = p.id
left join app_user au on ja.author = au.user_key
left join cwd_user cu on au.lower_user_name = cu.lower_user_name;
select 
concat(p.pkey, '-', ji.issuenum) as issue_key,
ja.id as comment_id,
cu.display_name as comment_author,
ja.actionbody as comment_body,
case
when cr.emoticon = '1f44d' then 'THUMBS_UP'
when cr.emoticon = '1f44e' then 'THUMBS_DOWN'
when cr.emoticon = '1f525' then 'FIRE'
when cr.emoticon = '1f60d' then 'HEART_EYES'
when cr.emoticon = '1f602' then 'JOY'
when cr.emoticon = '1f622' then 'CRY'
when cr.emoticon is null then 'N/A'
end reaction
from comment_reaction cr
join jiraaction ja on ja.id = cr.comment_id
join jiraissue ji on ja.issueid = ji.id
join project p on ji.project = p.id
left join app_user au on ja.author = au.user_key
left join cwd_user cu on au.lower_user_name = cu.lower_user_name;
select 
concat(p.pkey, '-', ji.issuenum) as issue_key,
ja.id as comment_id,
cu.display_name as comment_author,
ja.actionbody as comment_body,
case
when cr.emoticon = '1f44d' then 'THUMBS_UP'
when cr.emoticon = '1f44e' then 'THUMBS_DOWN'
when cr.emoticon = '1f525' then 'FIRE'
when cr.emoticon = '1f60d' then 'HEART_EYES'
when cr.emoticon = '1f602' then 'JOY'
when cr.emoticon = '1f622' then 'CRY'
when cr.emoticon is null then 'N/A'
end reaction
from comment_reaction cr
join jiraaction ja on ja.id = cr.comment_id
join jiraissue ji on ja.issueid = ji.id
join project p on ji.project = p.id
left join app_user au on ja.author = au.user_key
left join cwd_user cu on au.lower_user_name = cu.lower_user_name;

Java API

We do have JAVA API classes that you can use if you are looking to get this information through Java API. For this feature, relevant classes are:

Here is the sample Groovy Script that helps demonstrate what are the available options.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.reactions.CommentReactionsService
import com.atlassian.jira.issue.comments.reactions.CommentReactionManager

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def commentReactionsService = ComponentAccessor.getComponent(CommentReactionsService)
def commentReactionManager =  ComponentAccessor.getComponent(CommentReactionManager)

def issue = Issues.getByKey("KANBAN-2")
def sampleEmoji = "1f525" //fire emoji
def comments = ComponentAccessor.commentManager.getComments(issue)
def commentIds = comments.collect() {comment -> comment.getId()}

//get reaction from comment id list using commentReactionsService
log.warn(commentReactionsService.getReactions(user,commentIds).get())

//get detailed reaction from comment list for individual emoji using commentReactionsService
comments.each { comment ->
    log.warn(commentReactionsService.getDetailedReaction(user, comment.getId(), sampleEmoji).get())
}

//example getting reaction count from comment and emoji using CommentReactionManager
comments.each { comment ->
    log.warn(commentReactionManager.getReactionCount(comment.getId(),sampleEmoji))
}

REST API

We do not have an official public REST API for comment reactions or any public documentation. However, we do have internal endpoints that are used by Jira products that make this feature functional. We can do a bit of reverse engineering and find the relevant information using the browser developer tools. The following endpoint that can be used to get reactions for a list of comments.

Request URL:: https://myjira/jira/rest/internal/2/reactions/view
Request Method: POST
payload:
{
	"commentIds": [
		10200,
		10020
	]
}

Here is the curl example:

curl -u user:password -H "Content-Type: application/json" -d '{"commentIds":[10200,10020]}' -X POST https://myjira/jira/rest/internal/2/reactions/view

And this would be the sample response:

[
    {
        "commentId": 10200,
        "emojiId": "1f622",
        "count": 1,
        "reacted": true,
        "users": [
            "admin"
        ]
    },
    {
        "commentId": 10200,
        "emojiId": "1f525",
        "count": 2,
        "reacted": true,
        "users": [
            "Test 1",
            "admin"
        ]
    },
    {
        "commentId": 10020,
        "emojiId": "1f525",
        "count": 1,
        "reacted": false,
        "users": [
            "Test 1"
        ]
    },
    {
        "commentId": 10020,
        "emojiId": "1f44e",
        "count": 1,
        "reacted": true,
        "users": [
            "admin"
        ]
    },
    {
        "commentId": 10020,
        "emojiId": "1f44d",
        "count": 1,
        "reacted": true,
        "users": [
            "admin"
        ]
    }
]

The detailed list of emojis can be obtained from the rest/internal/2/reactions/emojis REST API endpoint. Here is the curl example:

 curl -u user:password -H "Content-Type: application/json" -X GET https://myjira/jira/rest/internal/2/reactions/emojis

Here is the sample response.

{
  "emojis": [
    {
      "id": "1f44d",
      "name": "thumbs up",
      "fallback": "��",
      "type": "STANDARD",
      "category": "PEOPLE",
      "order": 1,
      "representation": {
        "x": 0,
        "y": 0,
        "height": 64,
        "width": 64,
        "xIndex": 0,
        "yIndex": 0,
        "spriteRef": "https://myjira/jira/s/vwp74x/9100001/1dlckms/9.10.1/_/download/resources/com.atlassian.jira.jira-frontend-plugin:comment-reactions-emoji/reactions-sprite.png"
      },
      "ascii": [
        "(y)"
      ],
      "searchable": true,
      "shortName": ":thumbsup:"
    },
    {
      "id": "1f44e",
      "name": "thumbs down",
      "fallback": "��",
      "type": "STANDARD",
      "category": "PEOPLE",
      "order": 2,
      "representation": {
        "x": 64,
        "y": 0,
        "height": 64,
        "width": 64,
        "xIndex": 1,
        "yIndex": 0,
        "spriteRef": "https://myjira/jira/s/vwp74x/9100001/1dlckms/9.10.1/_/download/resources/com.atlassian.jira.jira-frontend-plugin:comment-reactions-emoji/reactions-sprite.png"
      },
      "searchable": true,
      "shortName": ":thumbsdown:"
...
omitted the rest of the response
...

Jira Server - REST API

If you need more information to get started with Jira REST API, read the reference documentation: Jira Server platform REST API and Atlassian Developer - Rest API.
The Jira Software and Jira Service Management applications have REST APIs for their application-specific features, like sprints (Jira Software) or customer requests (Jira Service Management).



Last modified on Dec 28, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.