Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MI-2088]: Review fixes of #872 #10

Merged
merged 27 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
af819fa
[MI-2088]:Add Support for DM subscriptions for watchers and reporters
Nityanand13 Sep 1, 2022
9f2c461
[MI-2088]: Review Fixes
Nityanand13 Sep 2, 2022
0e1219e
[MI-2088]:Revieww fixes
Nityanand13 Sep 5, 2022
4a9c195
[MI-2088]: Review fixes done
Nityanand13 Sep 7, 2022
cecaaaa
[MI-2088]:fixed review fixes
Kshitij-Katiyar Sep 21, 2022
47d4196
[MI-2088]:fixed review fixes
Kshitij-Katiyar Sep 22, 2022
7c5d1a9
[MI-2088]:fixed review fixes
Kshitij-Katiyar Sep 22, 2022
b752323
[MI-2088]:Review fixes done
Nityanand13 Sep 28, 2022
5add692
Merge branch 'mm-507' of github.com:Brightscout/mattermost-plugin-jir…
Nityanand13 Sep 28, 2022
f6f0a2c
[MI-2088]: Review fixes done
Nityanand13 Sep 29, 2022
5e3ff1d
[MI-2088]: Review fixes done
Nityanand13 Oct 6, 2022
1ae8fe0
Resolved merge conflicts
Nityanand13 Oct 6, 2022
d93fa60
[MI-2088]: Review fixes done
Nityanand13 Oct 10, 2022
9cd26d5
[MI-2088]: Review fixes done
Nityanand13 Oct 10, 2022
2acc22c
[MI-2088]: Review fixes done
Nityanand13 Oct 11, 2022
2df6112
[MI-2088]: Fixes CI errors
Nityanand13 Oct 12, 2022
03e76ba
[MI-2088]: Review fixes done
Nityanand13 Oct 12, 2022
50637bd
[MI-2088]: Review fixes done
Nityanand13 Oct 13, 2022
842c34e
[MI-2088]: Review fixes done
Nityanand13 Oct 13, 2022
b6db2bf
[MI-2088]: Fixed CI errors
Nityanand13 Oct 14, 2022
9aed429
Merge branch 'mm-507' of github.com:Brightscout/mattermost-plugin-jir…
Nityanand13 Oct 14, 2022
2146e70
[MI-2088]: Review fixes done
Nityanand13 Oct 18, 2022
10d0a9f
[MI-2088]: Fixed CI errors
Nityanand13 Oct 19, 2022
4f07c55
Merge branch 'master' of github.com:mattermost/mattermost-plugin-jira…
Nityanand13 Oct 19, 2022
bf3a661
Merge branch 'mm-507' of github.com:Brightscout/mattermost-plugin-jir…
Nityanand13 Oct 19, 2022
bf09071
[MI-2088]: Review fixes done
Nityanand13 Oct 19, 2022
c29f160
[MI-2088]: Reivew fixes done
Nityanand13 Oct 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ import (
"github.com/mattermost/mattermost-plugin-jira/server/utils/types"
)

const commandTrigger = "jira"
const (
commandTrigger = "jira"
subCommandAssignee = "assignee"
subCommandMention = "mention"
subCommandReporter = "reporter"
subCommandWatching = "watching"
)

var jiraCommandHandler = CommandHandler{
handlers: map[string]CommandHandlerFunc{
Expand Down
8 changes: 4 additions & 4 deletions server/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,15 +529,15 @@ func (p *Plugin) httpGetJiraProjectMetadata(w http.ResponseWriter, r *http.Reque
Value: project.Key,
Label: project.Name,
}
issueTypes := make([]option, len(project.IssueTypes))
for index, issueType := range project.IssueTypes {
issueTypes := []option{}
for _, issueType := range project.IssueTypes {
if issueType.Subtasks {
continue
}
issueTypes[index] = option{
issueTypes = append(issueTypes, option{
Value: issueType.Id,
Label: issueType.Name,
}
})
}
issues[project.Key] = issueTypes
}
Expand Down
1 change: 0 additions & 1 deletion server/issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ func TestApplyReporterNotification(t *testing.T) {
}
})
}

}

func TestGetUserSetting(t *testing.T) {
Expand Down
21 changes: 11 additions & 10 deletions server/settings.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package main

import (
"strings"

"github.com/mattermost/mattermost-server/v6/model"
"golang.org/x/text/cases"
"golang.org/x/text/language"

"github.com/mattermost/mattermost-plugin-jira/server/utils/types"
)
Expand All @@ -14,14 +14,15 @@ const (

errStoreNewSettings = "Could not store new settings. Please contact your system administrator. Error: %v"
errConnectToJira = "Your account is not connected to Jira. Please type `/jira connect`. %v"
subCommandAssignee = "assignee"
subCommandMention = "mention"
subCommandReporter = "reporter"
subCommandWatching = "watching"

notificationRoleAssignee = "assignee"
notificationRoleMention = "mention"
Nityanand13 marked this conversation as resolved.
Show resolved Hide resolved
notificationRoleReporter = "reporter"
notificationRoleWatching = "watching"
)

func (connection *Connection) sendNotification(role string, hasNotification bool) bool {
if role != subCommandAssignee && role != subCommandMention && role != subCommandReporter && role != subCommandWatching {
func (connection *Connection) updateRolesForDMNotification(role string, hasNotification bool) bool {
if role != notificationRoleAssignee && role != notificationRoleMention && role != notificationRoleReporter && role != notificationRoleWatching {
return false
}
if connection.Settings.RolesForDMNotification == nil {
Expand Down Expand Up @@ -50,7 +51,7 @@ func (p *Plugin) settingsNotifications(header *model.CommandArgs, instanceID, ma
if connection.Settings == nil {
connection.Settings = &ConnectionSettings{}
}
if !connection.sendNotification(args[1], value) {
if !connection.updateRolesForDMNotification(args[1], value) {
return p.responsef(header, helpText)
}

Expand All @@ -69,5 +70,5 @@ func (p *Plugin) settingsNotifications(header *model.CommandArgs, instanceID, ma
notifications = settingOn
}

return p.responsef(header, "Settings updated.\n\t%s notifications %s.", strings.Title(args[1]), notifications)
return p.responsef(header, "Settings updated.\n\t%s notifications %s.", cases.Title(language.Und, cases.NoLower).String(args[1]), notifications)
manojmalik20 marked this conversation as resolved.
Show resolved Hide resolved
}
1 change: 1 addition & 0 deletions server/subscribe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,7 @@ func TestGetChannelsSubscribed(t *testing.T) {

r := bytes.NewReader(data)
bb, err := ioutil.ReadAll(r)

require.Nil(t, err)
wh, err := ParseWebhook(bb)
assert.Nil(t, err)
Expand Down
2 changes: 2 additions & 0 deletions server/webhook_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ func (ww webhookWorker) process(msg *webhookMessage) (err error) {
if err != nil {
return err
}

Nityanand13 marked this conversation as resolved.
Show resolved Hide resolved
v := wh.(*webhook)
if err = v.JiraWebhook.expandIssue(ww.p, msg.InstanceID); err != nil {
return err
}

ww.p.checkIssueWatchers(v, msg.InstanceID)
ww.p.applyReporterNotification(v, msg.InstanceID, v.Issue.Fields.Reporter)

Expand Down