Skip to content

Commit

Permalink
[MI-2736]: Done the review fixes of a github PR mattermost#636 (#20)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
Nityanand13 authored Feb 9, 2023
1 parent 20ab25d commit 70ae885
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 17 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,6 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-github/v35 v35.2.0/go.mod h1:s0515YVTI+IMrDoy9Y4pHt9ShGpzHvHO8rZ7L7acgvs=
github.com/google/go-github/v41 v41.0.0 h1:HseJrM2JFf2vfiZJ8anY2hqBjdfY1Vlj/K27ueww4gg=
github.com/google/go-github/v41 v41.0.0/go.mod h1:XgmCA5H323A9rtgExdTcnDkcqp6S30AVACCBDOonIxg=
github.com/google/go-github/v48 v48.2.0 h1:68puzySE6WqUY9KWmpOsDEQfDZsso98rT6pZcz9HqcE=
github.com/google/go-github/v48 v48.2.0/go.mod h1:dDlehKBDo850ZPvCTK0sEqTCVWcrGl2LcDiajkYi89Y=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
Expand Down
6 changes: 3 additions & 3 deletions server/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ const (
OwnerQueryParam = "owner"
RepoQueryParam = "repo"
NumberQueryParam = "number"
PostIdQueryParam = "postId"
PostIDQueryParam = "postId"

IssueStatus = "status"
AssigneesForProps = "assignees"
LabelsForProps = "labels"
DescriptionForProps = "description"
TitleForProps = "title"
IssueNumberForProps = "issue_number"
IssueUrlForProps = "issue_url"
IssueURLForProps = "issue_url"
RepoOwnerForProps = "repo_owner"
RepoNameForProps = "repo_name"

Expand All @@ -33,7 +33,7 @@ const (
IssueClose = "closed"
IssueOpen = "open"

//Actions of webhook events
// Actions of webhook events
ActionOpened = "opened"
ActionClosed = "closed"
ActionReopened = "reopened"
Expand Down
9 changes: 5 additions & 4 deletions server/plugin/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import (
"github.com/pkg/errors"
"golang.org/x/oauth2"

"github.com/mattermost/mattermost-plugin-api/experimental/bot/logger"
"github.com/mattermost/mattermost-plugin-api/experimental/flow"
"github.com/mattermost/mattermost-plugin-github/server/constants"
"github.com/mattermost/mattermost-plugin-github/server/serializer"

"github.com/mattermost/mattermost-plugin-api/experimental/bot/logger"
"github.com/mattermost/mattermost-plugin-api/experimental/flow"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
)
Expand Down Expand Up @@ -97,7 +98,7 @@ func (p *Plugin) initializeAPI() {
apiRouter.HandleFunc("/closeorreopenissue", p.checkAuth(p.attachUserContext(p.closeOrReopenIssue), ResponseTypePlain)).Methods(http.MethodPost)
apiRouter.HandleFunc("/updateissue", p.checkAuth(p.attachUserContext(p.updateIssue), ResponseTypePlain)).Methods(http.MethodPost)
apiRouter.HandleFunc("/editissuemodal", p.checkAuth(p.attachUserContext(p.openIssueEditModal), ResponseTypePlain)).Methods(http.MethodPost)
apiRouter.HandleFunc("/closereopenissuemodal", p.checkAuth(p.attachUserContext(p.openCloseOrReopenIssueModal), ResponseTypePlain)).Methods(http.MethodPost)
apiRouter.HandleFunc("/close_reopen_issue_modal", p.checkAuth(p.attachUserContext(p.openCloseOrReopenIssueModal), ResponseTypePlain)).Methods(http.MethodPost)
apiRouter.HandleFunc("/attachcommentissuemodal", p.checkAuth(p.attachUserContext(p.openAttachCommentIssueModal), ResponseTypePlain)).Methods(http.MethodPost)
apiRouter.HandleFunc("/createissuecomment", p.checkAuth(p.attachUserContext(p.createIssueComment), ResponseTypePlain)).Methods(http.MethodPost)
apiRouter.HandleFunc("/mentions", p.checkAuth(p.attachUserContext(p.getMentions), ResponseTypePlain)).Methods(http.MethodGet)
Expand Down Expand Up @@ -1430,7 +1431,7 @@ func (p *Plugin) updateIssue(c *serializer.UserContext, w http.ResponseWriter, r
return
}

p.updatePost(post, issue, w)
p.updatePost(issue, w)
p.writeJSON(w, result)
}

Expand Down
3 changes: 2 additions & 1 deletion server/plugin/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"strings"
"unicode"

"github.com/mattermost/mattermost-plugin-api/experimental/command"
"github.com/mattermost/mattermost-plugin-github/server/constants"
"github.com/mattermost/mattermost-plugin-github/server/serializer"

"github.com/mattermost/mattermost-plugin-api/experimental/command"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
"github.com/pkg/errors"
Expand Down
1 change: 1 addition & 0 deletions server/plugin/mm_34646_token_refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/pkg/errors"

"github.com/mattermost/mattermost-plugin-api/cluster"

"github.com/mattermost/mattermost-plugin-github/server/serializer"
)

Expand Down
5 changes: 3 additions & 2 deletions server/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ import (
pluginapi "github.com/mattermost/mattermost-plugin-api"
"github.com/mattermost/mattermost-plugin-api/experimental/bot/poster"
"github.com/mattermost/mattermost-plugin-api/experimental/telemetry"
"github.com/mattermost/mattermost-plugin-github/server/constants"
"github.com/mattermost/mattermost-plugin-github/server/serializer"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
"github.com/pkg/errors"
"golang.org/x/oauth2"

"github.com/mattermost/mattermost-plugin-github/server/constants"
"github.com/mattermost/mattermost-plugin-github/server/serializer"

root "github.com/mattermost/mattermost-plugin-github"
)

Expand Down
5 changes: 3 additions & 2 deletions server/plugin/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import (
"strings"
"unicode"

"github.com/google/go-github/v48/github"
"github.com/mattermost/mattermost-plugin-github/server/constants"
"github.com/mattermost/mattermost-plugin-github/server/serializer"

"github.com/google/go-github/v48/github"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -370,7 +371,7 @@ func (p *Plugin) validateIssueRequestForUpdation(issue *serializer.UpdateIssueRe
return true
}

func (p *Plugin) updatePost(post *model.Post, issue *serializer.UpdateIssueRequest, w http.ResponseWriter) {
func (p *Plugin) updatePost(issue *serializer.UpdateIssueRequest, w http.ResponseWriter) {
post, appErr := p.API.GetPost(issue.PostID)
if appErr != nil {
p.writeAPIError(w, &serializer.APIErrorResponse{ID: "", Message: fmt.Sprintf("failed to load the post %s", issue.PostID), StatusCode: http.StatusInternalServerError})
Expand Down
5 changes: 3 additions & 2 deletions server/plugin/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
"sync"
"time"

"github.com/google/go-github/v48/github"
"github.com/mattermost/mattermost-plugin-github/server/constants"

"github.com/google/go-github/v48/github"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/microcosm-cc/bluemonday"
)
Expand Down Expand Up @@ -556,7 +557,7 @@ func (p *Plugin) postIssueEvent(event *github.IssuesEvent) {
post.Type = "custom_git_issue"
post.Props = map[string]interface{}{
constants.TitleForProps: *issue.Title,
constants.IssueUrlForProps: *issue.HTMLURL,
constants.IssueURLForProps: *issue.HTMLURL,
constants.IssueNumberForProps: *issue.Number,
constants.DescriptionForProps: description,
constants.AssigneesForProps: assignees,
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class Client {
}

closeOrReopenIssueModal = async (payload) => {
return this.doPost(`${this.url}/closereopenissuemodal`, payload);
return this.doPost(`${this.url}/close_reopen_issue_modal`, payload);
}

attachCommentIssueModal = async (payload) => {
Expand Down

0 comments on commit 70ae885

Please sign in to comment.