hubot-jira-bot icon indicating copy to clipboard operation
hubot-jira-bot copied to clipboard

Filter out notifications on Jira issues where comment author is watcher/assignee

Open vwbusguy opened this issue 7 years ago • 4 comments

Currently, a user receives a notification if they comment on a ticket that they are assigned on or watching. This is unnecessary noise, so I forked and modified the code so that users don't get notified for their own comments.

This code is currently working for us with slack+hubot.

vwbusguy avatar Aug 18 '17 23:08 vwbusguy

@vwbusguy also thanks for taking the time to make this PR

ndaversa avatar Aug 18 '17 23:08 ndaversa

That makes sense to have it in a common place in the DM context, however, it looks like that was added for 7.1 and as of 7.3.2 we were still getting notifications for comments. I see that comment.author is being passed https://github.com/ndaversa/hubot-jira-bot/blob/master/src/index.coffee#L165 and https://github.com/ndaversa/hubot-jira-bot/blob/master/src/index.coffee#L182 but I wonder if the validation is failing to equate the author object with the email address.

The schema given for the author by the Jira API doesn't include an email address: https://docs.atlassian.com/jira/REST/server/#api/2/issue-getComments

            "author": {
                "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
                "name": "fred",
                "displayName": "Fred F. User",
                "active": false
            },

This is why I ended up doing the condition check on name in the comment context.

vwbusguy avatar Aug 21 '17 16:08 vwbusguy

@vwbusguy

how about if here...

https://github.com/ndaversa/hubot-jira-bot/blob/356f50c441a5275e199ee38725329ed60e8e08d3/src/adapters/generic.coffee#L70-L71

we did something like this?

else if message.author?
  if user.profile?.email is message.author.emailAddress or message.author.name is user.name

In both cases you are passing the user object you want to check the name against, either watchers or assignee.

I haven't run the code to verify, but I think it should work?

ndaversa avatar Aug 24 '17 14:08 ndaversa

Sorry it took so long to respond. I pulled 7.4.0 and I'm still seeing notifications when I comment on an issue. I do not see the same behavior with my submitted PR.

vwbusguy avatar Jan 11 '18 19:01 vwbusguy