Skip to content

Commit fbb3836

Browse files
Raghav AggarwalKshitij-Katiyarwiggin77
authored
[GH-802] Added config setting for getting notification for draft PRs (#804)
* [MM-594] Added config setting for getting notification for draft PRs * updated help text and display name for GetNotificationForDraftPRs config Co-authored-by: Doug Lauder <[email protected]> * improved logic * get notificaiton for readyForReview in all cases --------- Co-authored-by: kshitij katiyar <[email protected]> Co-authored-by: Doug Lauder <[email protected]> Co-authored-by: kshitij katiyar <[email protected]>
1 parent a755715 commit fbb3836

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

plugin.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@
127127
"type": "bool",
128128
"help_text": "In 'Pushes' event notification, show commit author instead of commit committer.",
129129
"default": false
130+
},
131+
{
132+
"key": "GetNotificationForDraftPRs",
133+
"display_name": "Get notifications for draft pull requests:",
134+
"type": "bool",
135+
"help_text": "When set to 'true' you will get a notification with less details when a draft pull request is created and a notification with complete details when they are marked as ready for review. When set to 'false' no notifications are delivered for draft pull requests.",
136+
"default": false
130137
}
131138
],
132139
"footer": "* To report an issue, make a suggestion or a contribution, [check the repository](https://github.com/mattermost/mattermost-plugin-github)."

server/plugin/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type Configuration struct {
4242
EnableWebhookEventLogging bool `json:"enablewebhookeventlogging"`
4343
UsePreregisteredApplication bool `json:"usepreregisteredapplication"`
4444
ShowAuthorInCommitNotification bool `json:"showauthorincommitnotification"`
45+
GetNotificationForDraftPRs bool `json:"getnotificationfordraftprs"`
4546
}
4647

4748
func (c *Configuration) ToMap() (map[string]interface{}, error) {

server/plugin/webhook.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,12 @@ func (p *Plugin) postPullRequestEvent(event *github.PullRequestEvent) {
502502
if action == actionOpened {
503503
prNotificationType := "newPR"
504504
if isPRInDraftState {
505+
if !p.configuration.GetNotificationForDraftPRs {
506+
return // Draft PR notifications are disabled
507+
}
505508
prNotificationType = "newDraftPR"
506509
}
510+
507511
newPRMessage, err := renderTemplate(prNotificationType, GetEventWithRenderConfig(event, sub))
508512
if err != nil {
509513
p.client.Log.Warn("Failed to render template", "error", err.Error())

0 commit comments

Comments
 (0)