diff --git a/go.sum b/go.sum index 76bea24aa..372493be0 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/server/constants/constants.go b/server/constants/constants.go index 6e832b9be..c2e9ab504 100644 --- a/server/constants/constants.go +++ b/server/constants/constants.go @@ -13,7 +13,7 @@ const ( OwnerQueryParam = "owner" RepoQueryParam = "repo" NumberQueryParam = "number" - PostIdQueryParam = "postId" + PostIDQueryParam = "postId" IssueStatus = "status" AssigneesForProps = "assignees" @@ -21,7 +21,7 @@ const ( DescriptionForProps = "description" TitleForProps = "title" IssueNumberForProps = "issue_number" - IssueUrlForProps = "issue_url" + IssueURLForProps = "issue_url" RepoOwnerForProps = "repo_owner" RepoNameForProps = "repo_name" @@ -33,7 +33,7 @@ const ( IssueClose = "closed" IssueOpen = "open" - //Actions of webhook events + // Actions of webhook events ActionOpened = "opened" ActionClosed = "closed" ActionReopened = "reopened" diff --git a/server/plugin/api.go b/server/plugin/api.go index 913e81e16..4ecbe06b7 100644 --- a/server/plugin/api.go +++ b/server/plugin/api.go @@ -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" ) @@ -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) @@ -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) } diff --git a/server/plugin/command.go b/server/plugin/command.go index e0e38de75..f95e925de 100644 --- a/server/plugin/command.go +++ b/server/plugin/command.go @@ -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" diff --git a/server/plugin/mm_34646_token_refresh.go b/server/plugin/mm_34646_token_refresh.go index ed931e710..adec22097 100644 --- a/server/plugin/mm_34646_token_refresh.go +++ b/server/plugin/mm_34646_token_refresh.go @@ -9,6 +9,7 @@ import ( "github.com/pkg/errors" "github.com/mattermost/mattermost-plugin-api/cluster" + "github.com/mattermost/mattermost-plugin-github/server/serializer" ) diff --git a/server/plugin/plugin.go b/server/plugin/plugin.go index b059c5a7a..0414be207 100644 --- a/server/plugin/plugin.go +++ b/server/plugin/plugin.go @@ -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" ) diff --git a/server/plugin/utils.go b/server/plugin/utils.go index a7628cb4b..8b5817827 100644 --- a/server/plugin/utils.go +++ b/server/plugin/utils.go @@ -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" ) @@ -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}) diff --git a/server/plugin/webhook.go b/server/plugin/webhook.go index ed9196556..c183d348f 100644 --- a/server/plugin/webhook.go +++ b/server/plugin/webhook.go @@ -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" ) @@ -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, diff --git a/webapp/src/client/client.js b/webapp/src/client/client.js index 5ebcdb510..fb331f53c 100644 --- a/webapp/src/client/client.js +++ b/webapp/src/client/client.js @@ -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) => {