Skip to content

Commit

Permalink
Highfive shouldn't notify if author is a watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
wafflespeanut committed Aug 9, 2016
1 parent a78eec0 commit 6d9841f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
8 changes: 7 additions & 1 deletion handlers/label_watchers/__init__.py
Expand Up @@ -32,8 +32,14 @@ def on_issue_labeled(self, api, payload):
return # No watchers

mentions = []
creator = None
if 'issue' in payload:
creator = payload['issue']['user']['login']
elif 'pull_request' in payload:
creator = payload['pull_request']['user']['login']

for (watcher, watched_labels) in watchers:
if watcher == payload['sender']['login']:
if watcher == payload['sender']['login'] or watcher == creator:
continue

watched_labels = watched_labels.split(' ')
Expand Down
Expand Up @@ -18,7 +18,10 @@
},
"action": "labeled",
"issue": {
"number": 84
"number": 84,
"user": {
"login": "nox"
}
}
}
}
}
27 changes: 27 additions & 0 deletions handlers/label_watchers/tests/dont_notify_creator.json
@@ -0,0 +1,27 @@
{
"expected": {
"comments": 0
},
"initial": {},
"payload": {
"issue": {
"number": 123,
"user": {
"login": "wafflespeanut"
}
},
"sender": {
"login": "jdm"
},
"repository": {
"owner": {
"login": "servo"
},
"name": "servo"
},
"label": {
"name": "L-python"
},
"action": "labeled"
}
}
7 changes: 5 additions & 2 deletions handlers/label_watchers/tests/new_pr.json
Expand Up @@ -18,7 +18,10 @@
},
"action": "labeled",
"issue": {
"number": 84
"number": 84,
"user": {
"login": "highfive"
}
}
}
}
}
7 changes: 5 additions & 2 deletions handlers/label_watchers/tests/not_watched.json
Expand Up @@ -18,7 +18,10 @@
},
"action": "labeled",
"issue": {
"number": 84
"number": 84,
"user": {
"login": "Wafflespeanut"
}
}
}
}
}

0 comments on commit 6d9841f

Please sign in to comment.