Skip to content

Commit 70ae885

Browse files
authored
[MI-2736]: Done the review fixes of a github PR mattermost#636 (#20)
* [MI-2736]: Review fixes done 1. Improved code readability * [MI-2736]: Review fixes done 1. Fixed linting errors * [MI-2736]: Review fixes done 1. Fixed linting error
1 parent 20ab25d commit 70ae885

File tree

9 files changed

+21
-17
lines changed

9 files changed

+21
-17
lines changed

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
641641
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
642642
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
643643
github.com/google/go-github/v35 v35.2.0/go.mod h1:s0515YVTI+IMrDoy9Y4pHt9ShGpzHvHO8rZ7L7acgvs=
644-
github.com/google/go-github/v41 v41.0.0 h1:HseJrM2JFf2vfiZJ8anY2hqBjdfY1Vlj/K27ueww4gg=
645-
github.com/google/go-github/v41 v41.0.0/go.mod h1:XgmCA5H323A9rtgExdTcnDkcqp6S30AVACCBDOonIxg=
646644
github.com/google/go-github/v48 v48.2.0 h1:68puzySE6WqUY9KWmpOsDEQfDZsso98rT6pZcz9HqcE=
647645
github.com/google/go-github/v48 v48.2.0/go.mod h1:dDlehKBDo850ZPvCTK0sEqTCVWcrGl2LcDiajkYi89Y=
648646
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=

server/constants/constants.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ const (
1313
OwnerQueryParam = "owner"
1414
RepoQueryParam = "repo"
1515
NumberQueryParam = "number"
16-
PostIdQueryParam = "postId"
16+
PostIDQueryParam = "postId"
1717

1818
IssueStatus = "status"
1919
AssigneesForProps = "assignees"
2020
LabelsForProps = "labels"
2121
DescriptionForProps = "description"
2222
TitleForProps = "title"
2323
IssueNumberForProps = "issue_number"
24-
IssueUrlForProps = "issue_url"
24+
IssueURLForProps = "issue_url"
2525
RepoOwnerForProps = "repo_owner"
2626
RepoNameForProps = "repo_name"
2727

@@ -33,7 +33,7 @@ const (
3333
IssueClose = "closed"
3434
IssueOpen = "open"
3535

36-
//Actions of webhook events
36+
// Actions of webhook events
3737
ActionOpened = "opened"
3838
ActionClosed = "closed"
3939
ActionReopened = "reopened"

server/plugin/api.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import (
1616
"github.com/pkg/errors"
1717
"golang.org/x/oauth2"
1818

19-
"github.com/mattermost/mattermost-plugin-api/experimental/bot/logger"
20-
"github.com/mattermost/mattermost-plugin-api/experimental/flow"
2119
"github.com/mattermost/mattermost-plugin-github/server/constants"
2220
"github.com/mattermost/mattermost-plugin-github/server/serializer"
21+
22+
"github.com/mattermost/mattermost-plugin-api/experimental/bot/logger"
23+
"github.com/mattermost/mattermost-plugin-api/experimental/flow"
2324
"github.com/mattermost/mattermost-server/v6/model"
2425
"github.com/mattermost/mattermost-server/v6/plugin"
2526
)
@@ -97,7 +98,7 @@ func (p *Plugin) initializeAPI() {
9798
apiRouter.HandleFunc("/closeorreopenissue", p.checkAuth(p.attachUserContext(p.closeOrReopenIssue), ResponseTypePlain)).Methods(http.MethodPost)
9899
apiRouter.HandleFunc("/updateissue", p.checkAuth(p.attachUserContext(p.updateIssue), ResponseTypePlain)).Methods(http.MethodPost)
99100
apiRouter.HandleFunc("/editissuemodal", p.checkAuth(p.attachUserContext(p.openIssueEditModal), ResponseTypePlain)).Methods(http.MethodPost)
100-
apiRouter.HandleFunc("/closereopenissuemodal", p.checkAuth(p.attachUserContext(p.openCloseOrReopenIssueModal), ResponseTypePlain)).Methods(http.MethodPost)
101+
apiRouter.HandleFunc("/close_reopen_issue_modal", p.checkAuth(p.attachUserContext(p.openCloseOrReopenIssueModal), ResponseTypePlain)).Methods(http.MethodPost)
101102
apiRouter.HandleFunc("/attachcommentissuemodal", p.checkAuth(p.attachUserContext(p.openAttachCommentIssueModal), ResponseTypePlain)).Methods(http.MethodPost)
102103
apiRouter.HandleFunc("/createissuecomment", p.checkAuth(p.attachUserContext(p.createIssueComment), ResponseTypePlain)).Methods(http.MethodPost)
103104
apiRouter.HandleFunc("/mentions", p.checkAuth(p.attachUserContext(p.getMentions), ResponseTypePlain)).Methods(http.MethodGet)
@@ -1430,7 +1431,7 @@ func (p *Plugin) updateIssue(c *serializer.UserContext, w http.ResponseWriter, r
14301431
return
14311432
}
14321433

1433-
p.updatePost(post, issue, w)
1434+
p.updatePost(issue, w)
14341435
p.writeJSON(w, result)
14351436
}
14361437

server/plugin/command.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"strings"
77
"unicode"
88

9-
"github.com/mattermost/mattermost-plugin-api/experimental/command"
109
"github.com/mattermost/mattermost-plugin-github/server/constants"
1110
"github.com/mattermost/mattermost-plugin-github/server/serializer"
11+
12+
"github.com/mattermost/mattermost-plugin-api/experimental/command"
1213
"github.com/mattermost/mattermost-server/v6/model"
1314
"github.com/mattermost/mattermost-server/v6/plugin"
1415
"github.com/pkg/errors"

server/plugin/mm_34646_token_refresh.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/pkg/errors"
1010

1111
"github.com/mattermost/mattermost-plugin-api/cluster"
12+
1213
"github.com/mattermost/mattermost-plugin-github/server/serializer"
1314
)
1415

server/plugin/plugin.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ import (
1717
pluginapi "github.com/mattermost/mattermost-plugin-api"
1818
"github.com/mattermost/mattermost-plugin-api/experimental/bot/poster"
1919
"github.com/mattermost/mattermost-plugin-api/experimental/telemetry"
20-
"github.com/mattermost/mattermost-plugin-github/server/constants"
21-
"github.com/mattermost/mattermost-plugin-github/server/serializer"
2220
"github.com/mattermost/mattermost-server/v6/model"
2321
"github.com/mattermost/mattermost-server/v6/plugin"
2422
"github.com/pkg/errors"
2523
"golang.org/x/oauth2"
2624

25+
"github.com/mattermost/mattermost-plugin-github/server/constants"
26+
"github.com/mattermost/mattermost-plugin-github/server/serializer"
27+
2728
root "github.com/mattermost/mattermost-plugin-github"
2829
)
2930

server/plugin/utils.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ import (
1616
"strings"
1717
"unicode"
1818

19-
"github.com/google/go-github/v48/github"
2019
"github.com/mattermost/mattermost-plugin-github/server/constants"
2120
"github.com/mattermost/mattermost-plugin-github/server/serializer"
21+
22+
"github.com/google/go-github/v48/github"
2223
"github.com/mattermost/mattermost-server/v6/model"
2324
"github.com/pkg/errors"
2425
)
@@ -370,7 +371,7 @@ func (p *Plugin) validateIssueRequestForUpdation(issue *serializer.UpdateIssueRe
370371
return true
371372
}
372373

373-
func (p *Plugin) updatePost(post *model.Post, issue *serializer.UpdateIssueRequest, w http.ResponseWriter) {
374+
func (p *Plugin) updatePost(issue *serializer.UpdateIssueRequest, w http.ResponseWriter) {
374375
post, appErr := p.API.GetPost(issue.PostID)
375376
if appErr != nil {
376377
p.writeAPIError(w, &serializer.APIErrorResponse{ID: "", Message: fmt.Sprintf("failed to load the post %s", issue.PostID), StatusCode: http.StatusInternalServerError})

server/plugin/webhook.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import (
1313
"sync"
1414
"time"
1515

16-
"github.com/google/go-github/v48/github"
1716
"github.com/mattermost/mattermost-plugin-github/server/constants"
17+
18+
"github.com/google/go-github/v48/github"
1819
"github.com/mattermost/mattermost-server/v6/model"
1920
"github.com/microcosm-cc/bluemonday"
2021
)
@@ -556,7 +557,7 @@ func (p *Plugin) postIssueEvent(event *github.IssuesEvent) {
556557
post.Type = "custom_git_issue"
557558
post.Props = map[string]interface{}{
558559
constants.TitleForProps: *issue.Title,
559-
constants.IssueUrlForProps: *issue.HTMLURL,
560+
constants.IssueURLForProps: *issue.HTMLURL,
560561
constants.IssueNumberForProps: *issue.Number,
561562
constants.DescriptionForProps: description,
562563
constants.AssigneesForProps: assignees,

webapp/src/client/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class Client {
1212
}
1313

1414
closeOrReopenIssueModal = async (payload) => {
15-
return this.doPost(`${this.url}/closereopenissuemodal`, payload);
15+
return this.doPost(`${this.url}/close_reopen_issue_modal`, payload);
1616
}
1717

1818
attachCommentIssueModal = async (payload) => {

0 commit comments

Comments
 (0)