Filter deleted comments
The following script examples are related to filtering deleted comments from outbound notifications.
Understanding the JSON event data for a comment
JEMHC uses event data provided by Atlassian as JSON payload as the information necessary to render outbound notifications for Transport types such as Email, Slack, Telegram etc…
Example comment element from the comments array property
{
"self": "https://instance.example.com/rest/api/2/issue/10994/comment/11382",
"id": "11382",
"author":
{
"self": "https://instance.example.com/rest/api/2/user?accountId=exampleAccountId",
"accountId": "exampleAccountId",
"avatarUrls":
{
"48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/PE-4.png",
"24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/PE-4.png",
"16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/PE-4.png",
"32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/PE-4.png"
},
"displayName": "Example User",
"active": true,
"timeZone": "Europe/London",
"accountType": "atlassian"
},
"body": "internal note",
"updateAuthor":
{
"self": "https://instance.example.com/rest/api/2/user?accountId=exampleAccountId",
"accountId": "exampleAccountId",
"avatarUrls":
{
"48x48": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/PE-4.png",
"24x24": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/PE-4.png",
"16x16": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/PE-4.png",
"32x32": "https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/initials/PE-4.png"
},
"displayName": "Example User",
"active": true,
"timeZone": "Europe/London",
"accountType": "atlassian"
},
"created": "2025-01-08T10:44:02.453+0000",
"updated": "2025-01-08T10:44:02.453+0000",
"jsdPublic": false,
"deleted": true
}
Note the last few JSON properties above:
jsdPublic - indicates whether a comment is a private internal note or public comment values mean:
False - Private internal note
True - Public comment
deleted - indicates whether the comment was deleted
True - Comment was deleted
False/missing - Comment was created
By default JEMHC uses the first comments property to render Just added comments as per:
For pre-existing comment rendering examples can be found:
Existing Comments - Render All Comments from Issue :
## Iterating over the latest comments the recipient can see...
#foreach( $comment in $jemhUtils.filterRestrictedComments($context.comments))
##filter deleted
#if(!$comment.deleted)
## rendering the comment below is a simple example
$jemhUtils.wikiToHtml($comment.body.textValue())
## tagging processing telling the notification system that a comment has been rendered ...
$jemhUtils.setCommentRendered()
#end
#end