Skip to content

Commit 36e72f4

Browse files
Merge branch 'master' of github.com:mattermost/mattermost-plugin-github into release-bump-2.2.0
2 parents fb518c0 + 2608197 commit 36e72f4

File tree

7 files changed

+76
-28
lines changed

7 files changed

+76
-28
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ require (
8080
github.com/wiggin77/srslog v1.0.1 // indirect
8181
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
8282
github.com/yuin/goldmark v1.4.13 // indirect
83-
golang.org/x/crypto v0.14.0 // indirect
83+
golang.org/x/crypto v0.17.0 // indirect
8484
golang.org/x/net v0.17.0 // indirect
85-
golang.org/x/sys v0.13.0 // indirect
86-
golang.org/x/text v0.13.0 // indirect
85+
golang.org/x/sys v0.15.0 // indirect
86+
golang.org/x/text v0.14.0 // indirect
8787
google.golang.org/appengine v1.6.7 // indirect
8888
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
8989
google.golang.org/grpc v1.56.3 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
291291
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
292292
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
293293
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
294-
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
295-
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
294+
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
295+
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
296296
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
297297
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
298298
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -345,17 +345,17 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc
345345
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
346346
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
347347
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
348-
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
349-
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
348+
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
349+
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
350350
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
351351
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
352352
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
353353
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
354354
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
355355
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
356356
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
357-
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
358-
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
357+
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
358+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
359359
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
360360
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
361361
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

server/plugin/configuration_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ func TestSetDefaults(t *testing.T) {
6363
for _, testCase := range []struct {
6464
description string
6565
isCloud bool
66-
config Configuration
66+
config *Configuration
6767

6868
shouldChange bool
6969
outputCheck func(*testing.T, *Configuration)
7070
errMsg string
7171
}{
7272
{
7373
description: "noop",
74-
config: Configuration{
74+
config: &Configuration{
7575
EncryptionKey: "abcd",
7676
WebhookSecret: "efgh",
7777
},
@@ -82,7 +82,7 @@ func TestSetDefaults(t *testing.T) {
8282
},
8383
}, {
8484
description: "set encryption key",
85-
config: Configuration{
85+
config: &Configuration{
8686
EncryptionKey: "",
8787
},
8888
shouldChange: true,
@@ -91,7 +91,7 @@ func TestSetDefaults(t *testing.T) {
9191
},
9292
}, {
9393
description: "set webhook key",
94-
config: Configuration{
94+
config: &Configuration{
9595
WebhookSecret: "",
9696
},
9797
shouldChange: true,
@@ -100,7 +100,7 @@ func TestSetDefaults(t *testing.T) {
100100
},
101101
}, {
102102
description: "set webhook and encryption key",
103-
config: Configuration{
103+
config: &Configuration{
104104
EncryptionKey: "",
105105
WebhookSecret: "",
106106
},
@@ -112,7 +112,7 @@ func TestSetDefaults(t *testing.T) {
112112
}, {
113113
description: "Should not set UsePreregisteredApplication in on-prem",
114114
isCloud: false,
115-
config: Configuration{
115+
config: &Configuration{
116116
EncryptionKey: "abcd",
117117
WebhookSecret: "efgh",
118118
UsePreregisteredApplication: false,
@@ -125,7 +125,7 @@ func TestSetDefaults(t *testing.T) {
125125
}, {
126126
description: "Should set UsePreregisteredApplication in cloud if no OAuth secret is configured",
127127
isCloud: true,
128-
config: Configuration{
128+
config: &Configuration{
129129
EncryptionKey: "abcd",
130130
WebhookSecret: "efgh",
131131
UsePreregisteredApplication: false,
@@ -140,7 +140,7 @@ func TestSetDefaults(t *testing.T) {
140140
}, {
141141
description: "Should set not UsePreregisteredApplication in cloud if OAuth secret is configured",
142142
isCloud: true,
143-
config: Configuration{
143+
config: &Configuration{
144144
EncryptionKey: "abcd",
145145
WebhookSecret: "efgh",
146146
UsePreregisteredApplication: false,
@@ -160,7 +160,7 @@ func TestSetDefaults(t *testing.T) {
160160
changed, err := testCase.config.setDefaults(testCase.isCloud)
161161

162162
assert.Equal(t, testCase.shouldChange, changed)
163-
testCase.outputCheck(t, &testCase.config)
163+
testCase.outputCheck(t, testCase.config)
164164

165165
if testCase.errMsg != "" {
166166
require.Error(t, err)

server/plugin/graphql/lhs_query.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ type (
1515
Login githubv4.String
1616
}
1717

18+
labelNode struct {
19+
Name githubv4.String
20+
Color githubv4.String
21+
}
22+
1823
prSearchNodes struct {
1924
PullRequest struct {
2025
Body githubv4.String
@@ -27,6 +32,12 @@ type (
2732
Title githubv4.String
2833
Author authorQuery
2934
URL githubv4.URI
35+
Labels struct {
36+
Nodes []labelNode
37+
} `graphql:"labels(first:100)"`
38+
Milestone struct {
39+
Title githubv4.String
40+
}
3041
} `graphql:"... on PullRequest"`
3142
}
3243
)
@@ -44,6 +55,12 @@ type (
4455
Title githubv4.String
4556
Author authorQuery
4657
URL githubv4.URI
58+
Labels struct {
59+
Nodes []labelNode
60+
} `graphql:"labels(first:100)"`
61+
Milestone struct {
62+
Title githubv4.String
63+
}
4764
} `graphql:"... on Issue"`
4865

4966
PullRequest struct {
@@ -57,6 +74,12 @@ type (
5774
Title githubv4.String
5875
Author authorQuery
5976
URL githubv4.URI
77+
Labels struct {
78+
Nodes []labelNode
79+
} `graphql:"labels(first:100)"`
80+
Milestone struct {
81+
Title githubv4.String
82+
}
6083
} `graphql:"... on PullRequest"`
6184
}
6285
)

server/plugin/graphql/lhs_request.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (c *Client) GetLHSData(ctx context.Context) ([]*github.Issue, []*github.Iss
6464
if !allAssignmentsFetched {
6565
for i := range mainQuery.Assignments.Nodes {
6666
resp := mainQuery.Assignments.Nodes[i]
67-
issue := getIssue(&resp)
67+
issue := newIssueFromAssignmentResponse(&resp)
6868
resultAssignee = append(resultAssignee, issue)
6969
}
7070

@@ -95,21 +95,38 @@ func (c *Client) GetLHSData(ctx context.Context) ([]*github.Issue, []*github.Iss
9595

9696
func getPR(prResp *prSearchNodes) *github.Issue {
9797
resp := prResp.PullRequest
98+
labels := getGithubLabels(resp.Labels.Nodes)
9899

99-
return getGithubIssue(resp.Number, resp.Title, resp.Author.Login, resp.Repository.URL, resp.URL, resp.CreatedAt, resp.UpdatedAt)
100+
return newGithubIssue(resp.Number, resp.Title, resp.Author.Login, resp.Repository.URL, resp.URL, resp.CreatedAt, resp.UpdatedAt, labels, resp.Milestone.Title)
100101
}
101102

102-
func getIssue(assignmentResp *assignmentSearchNodes) *github.Issue {
103+
func newIssueFromAssignmentResponse(assignmentResp *assignmentSearchNodes) *github.Issue {
103104
resp := assignmentResp.PullRequest
105+
labels := getGithubLabels(resp.Labels.Nodes)
104106

105-
return getGithubIssue(resp.Number, resp.Title, resp.Author.Login, resp.Repository.URL, resp.URL, resp.CreatedAt, resp.UpdatedAt)
107+
return newGithubIssue(resp.Number, resp.Title, resp.Author.Login, resp.Repository.URL, resp.URL, resp.CreatedAt, resp.UpdatedAt, labels, resp.Milestone.Title)
106108
}
107109

108-
func getGithubIssue(prNumber githubv4.Int, title, login githubv4.String, repositoryURL, htmlURL githubv4.URI, createdAt, updatedAt githubv4.DateTime) *github.Issue {
110+
func getGithubLabels(labels []labelNode) []*github.Label {
111+
githubLabels := []*github.Label{}
112+
for _, label := range labels {
113+
name := (string)(label.Name)
114+
color := (string)(label.Color)
115+
githubLabels = append(githubLabels, &github.Label{
116+
Color: &color,
117+
Name: &name,
118+
})
119+
}
120+
121+
return githubLabels
122+
}
123+
124+
func newGithubIssue(prNumber githubv4.Int, title, login githubv4.String, repositoryURL, htmlURL githubv4.URI, createdAt, updatedAt githubv4.DateTime, labels []*github.Label, milestone githubv4.String) *github.Issue {
109125
number := int(prNumber)
110126
repoURL := repositoryURL.String()
111127
issuetitle := string(title)
112-
userLogin := (string)(login)
128+
userLogin := string(login)
129+
milestoneTitle := string(milestone)
113130
url := htmlURL.String()
114131
createdAtTime := createdAt.Time
115132
updatedAtTime := updatedAt.Time
@@ -123,6 +140,10 @@ func getGithubIssue(prNumber githubv4.Int, title, login githubv4.String, reposit
123140
User: &github.User{
124141
Login: &userLogin,
125142
},
143+
Milestone: &github.Milestone{
144+
Title: &milestoneTitle,
145+
},
126146
HTMLURL: &url,
147+
Labels: labels,
127148
}
128149
}

server/plugin/plugin.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,11 @@ func (p *Plugin) storeGitHubToUserIDMapping(githubUsername, userID string) error
642642

643643
func (p *Plugin) getGitHubToUserIDMapping(githubUsername string) string {
644644
var data []byte
645-
_ = p.client.KV.Get(githubUsername+githubUsernameKey, data)
645+
err := p.client.KV.Get(githubUsername+githubUsernameKey, &data)
646+
if err != nil {
647+
p.API.LogWarn("Error occurred while getting the user ID from KV store using the Github username", "Error", err.Error())
648+
return ""
649+
}
646650

647651
return string(data)
648652
}
@@ -748,7 +752,7 @@ func (p *Plugin) StoreDailySummaryText(userID, summaryText string) error {
748752

749753
func (p *Plugin) GetDailySummaryText(userID string) (string, error) {
750754
var summaryByte []byte
751-
err := p.client.KV.Get(userID+dailySummary, summaryByte)
755+
err := p.client.KV.Get(userID+dailySummary, &summaryByte)
752756
if err != nil {
753757
return "", err
754758
}

webapp/src/components/sidebar_right/github_items.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function GithubItems(props: GithubItemsProps) {
167167
}
168168

169169
let milestone: JSX.Element | null = null;
170-
if (item.milestone) {
170+
if (item.milestone?.title) {
171171
milestone = (
172172
<span
173173
title={item.milestone.title}
@@ -372,7 +372,7 @@ function getGithubLabels(labels: Label[]) {
372372
return labels.map((label) => {
373373
return (
374374
<Badge
375-
key={label.id}
375+
key={label.name}
376376
aria-label={label.name}
377377
role={'note'}
378378
style={{...itemStyle, ...{backgroundColor: `#${label.color}`, color: getLabelFontColor(label.color)}}}

0 commit comments

Comments
 (0)