missing notifications

Issue #28 resolved
DataCenter Stokrotka created an issue

Hello.

  1. The listener synchronizes the comments with the service account (has all permissions) from project X to Z
  2. User A is authorized to projects X and Z
  3. User B is only authorized to project X.
  4. A comment added by user A in project X triggers customer notifications to the reporter in project Z.
  5. The comment added by user B in project X does not trigger a notification in project Z.

It seems that despite providing a service account to operate the Listener, the authorization is performed by the operating user.
Jira's support referred us to the seller.

Comments (26)

  1. Yury Oboz repo owner

    I see you created listener to sync issues from “MSD“ project to linked issues. You will need create second listener for sync from other project to MSD or add second project to source projects

  2. DataCenter Stokrotka reporter

    Hello
    Why create a second listener? in this case MSD is source project, (X project) and target is Z, via linked issues.

  3. Yury Oboz repo owner

    Sorry, I misunderstood the problem.

    I tried to reproduce this case - but I got all the notifications.

    What version of Jira and jira-sync-fields app?

    Author of synced comment in project Z is “SERVICE USER“?

    Can you try add comment in project Z from “SERVICE USER“ directly? Notifications will be sended?

  4. DataCenter Stokrotka reporter

    Jira Service Deskl 4.13.8
    Jira Software 8.13.8
    Jira Core 8.13.8
    Sync Fields 8.0.5
    Author of synced comment in project Z is “SERVICE USER“? - Yes, in both examples from issue description (point 2 and point 3)
    Can you try add comment in project Z from “SERVICE USER“ directly? - No - for security reasons as service account, nobody can log in into.

  5. Yury Oboz repo owner

    I setup Jira 8.13.8 with jira-sync-field-8.0.5

    • created 2 project XP and ZP
    • user A, B, C and “sync“ added to project XP
    • user A, C and “sync“ added to ZP project
    • created link between XP-1 and ZP-1
    • user "sync" added to watchers in XP-1 and ZP-1

    User “B“ do not have access to project ZP. I create comment from “B“ in XP-1 and received email from “sync“ user like “Sync user commeted ZP-1“

    1. A comment added by user A in project X triggers customer notifications to the reporter in project Z.

    Do customers receive notifications from "SERVICE USER"?

  6. DataCenter Stokrotka reporter

    If the comment is not related to the "resolution" of the report, the notification does not even attempt to be sent. Project settings (XP) → Customer notifications → Public comment added → Audit log.
    There are entries with success - in case comment with change status/resolution - customers does receive notifications from SERVICE USER in this case
    There are entries with not executed - in case comment is not public (internal)
    There is no entry related with missing notifications

  7. DataCenter Stokrotka reporter

    We have similar - dev instance. There working well - so we need some tips how to debug listener itself, or how listener sending “trigger” for notifications

  8. Yury Oboz repo owner

    Listener don’t call trigger directly. For create comment uses this method: https://docs.atlassian.com/software/jira/docs/api/8.20.0/com/atlassian/jira/issue/comments/CommentManager.html#create-com.atlassian.jira.issue.Issue-com.atlassian.jira.user.ApplicationUser-java.lang.String-java.lang.String-java.lang.Long-java.util.Date-java.util.Map-boolean-

    Code fragment:

    Comment m = commentManager.create(targetIssue, syncUser, comment, null, null, new Date(), properties, config.isCommentEvent());
    

    config.isCommentEvent() - “Call listener on comment sync“ checkbox from settings

    from jira docs:

    dispatchEvent - if true then an event of type EventType.ISSUE_COMMENTED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.

  9. DataCenter Stokrotka reporter

    Hello
    Where should I look for information whether the event is actually triggered when the listner is executed?

  10. Yury Oboz repo owner

    The event is fired if a comment has been created. Jira call this event automatically.

  11. DataCenter Stokrotka reporter

    Hello
    I understand how the listener works, unfortunately the problem exists, so we have created this thread. Jira's support redirected us to the developer of the add-on.
    Therefore, we need instructions on how to debug the event call by the Issue Sync add-on.

  12. Yury Oboz repo owner

    Hello

    • What value of Comment Visibility property (Go to System->General Configuration)?
    • User B adding comment from SD portal or directly from issue page?
    • The comment has any restrictions for visible?

  13. DataCenter Stokrotka reporter
    • What value of Comment Visibility property (Go to System->General Configuration)? Answer: Project Roles Only
    • User B adding comment from SD portal or directly from issue page? Answer: From issue page, not from customer portal
    • The comment has any restrictions for visible? Answer: No

  14. Yury Oboz repo owner

    I still can't reproduce the problem.

    What you want debug? Listener call JIRA API method for create comment and nothing more

    You can run this fragment with scriptrunner or “mygroovy” console

    import java.util.HashMap
    import com.atlassian.jira.user.UserUtils
    import com.atlassian.jira.issue.comments.Comment
    import com.atlassian.jira.component.ComponentAccessor
    import com.atlassian.jira.issue.comments.CommentManager
    import com.atlassian.jira.issue.Issue
    
    Issue issue = ComponentAccessor.getIssueManager().getIssueObject("AAA-1") // Change AAA-1 to issue from project Z
    CommentManager cm = ComponentAccessor.getCommentManager()
    
    // Change "admin" to "SERVICE USER" login
    Comment comment = cm.create(issue, UserUtils.getUser("admin"), "comment body", null, null, new Date(), new HashMap(), true);
    

    Then you must see new comment in target issue. Will be notification sent?

  15. DataCenter Stokrotka reporter

    Hello

    By running the above code snippet, I can confirm that the notification is working. The fact may help:
    executing this code I get an error, not originally related to calling trigger itself.
    We have a separate code related to the comments function. The text of the error indicates that it is not invoked by service.user, but by the account which I am calling the code through scriptrunner.
    Below there is a screenshot with the error.

  16. Yury Oboz repo owner

    By running the above code snippet, I can confirm that the notification is working.

    The same code is used in the addon.

    Can you fix this listener so that it doesn't throw an error because the chain of calls to other listeners can be broken due to this error?

    I can add code to change current user like this:

    import com.atlassian.jira.user.ApplicationUser
    import com.atlassian.jira.security.JiraAuthenticationContext
    import java.util.HashMap
    import com.atlassian.jira.user.UserUtils
    import com.atlassian.jira.issue.comments.Comment
    import com.atlassian.jira.component.ComponentAccessor
    import com.atlassian.jira.issue.comments.CommentManager
    import com.atlassian.jira.issue.Issue
    
    Issue issue = ComponentAccessor.getIssueManager().getIssueObject("AAA-1") // Change AAA-1 to issue from project Z
    CommentManager cm = ComponentAccessor.getCommentManager()
    JiraAuthenticationContext ac = ComponentAccessor.getJiraAuthenticationContext()
    
    // Change "admin" to "SERVICE USER" login
    ApplicationUser user = UserUtils.getUser("admin")
    ApplicationUser prevUser = ac.getLoggedInUser()
    ac.setLoggedInUser(user) // set current user
    Comment comment = cm.create(issue, user, "comment body2", null, null, new Date(), new HashMap(), true);
    ac.setLoggedInUser(prevUser) // revert current user
    

  17. DataCenter Stokrotka reporter

    Now after execution your new code in error from another listener shows “service.user” not current user - so it seems work better.

    How can we modify your plugin to try use this 2nd version?

  18. DataCenter Stokrotka reporter

    Procedure for install patch?
    Just put jar file in the same path as original and restart jira?

  19. DataCenter Stokrotka reporter

    I tried to find in attlassian-jira.log but i failed 😕
    Manual upload and restart Jira end with success. In first test seems this patch solved problem, but, ill confirm that on production in next week, so please don’t close ticket yet.

  20. Log in to comment