Skip to content

Commit

Permalink
[MI-3338]:Fixed issue mattermost#954 'DM comment notifications not wo…
Browse files Browse the repository at this point in the history
…rking' (#61)

* [MI-3338]:Fixed issue mattermost#954 'DM comment notifications not working'

* [MI-3338]:Fixed CI
  • Loading branch information
Kshitij-Katiyar authored Jul 31, 2023
1 parent 1766506 commit 45996ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
20 changes: 10 additions & 10 deletions server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,25 @@ func (p *Plugin) CreateBotDMtoMMUserID(mattermostUserID, format string, args ...

func (p *Plugin) replaceJiraAccountIds(instanceID types.ID, body string) string {
result := body

for _, uname := range parseJIRAUsernamesFromText(body) {
if !strings.HasPrefix(uname, "accountid:") {
continue
jiraUserIDOrName := ""
if strings.HasPrefix(uname, "accountid:") {
jiraUserIDOrName = uname[len("accountid:"):]
} else {
jiraUserIDOrName = uname
}

jiraUserID := uname[len("accountid:"):]
mattermostUserID, err := p.userStore.LoadMattermostUserID(instanceID, jiraUserID)
mattermostUserID, err := p.userStore.LoadMattermostUserID(instanceID, jiraUserIDOrName)
if err != nil {
continue
}
c, err := p.userStore.LoadConnection(instanceID, mattermostUserID)
if err != nil {

user, appErr := p.API.GetUser(string(mattermostUserID))
if appErr != nil {
continue
}

if c.DisplayName != "" {
result = strings.ReplaceAll(result, uname, c.DisplayName)
}
result = strings.ReplaceAll(result, uname, user.Username)
}

return result
Expand Down
3 changes: 3 additions & 0 deletions server/webhook_http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,9 @@ func TestWebhookHTTP(t *testing.T) {
}
model.ParseSlackAttachment(rPost, rAttachments)
api.On("CreatePost", mock.AnythingOfType("*model.Post")).Return(rPost, nil)
api.On("GetUser", mock.AnythingOfType("string")).Return(&model.User{
Username: "test-username",
}, nil)

p := Plugin{}
p.updateConfig(func(conf *config) {
Expand Down

0 comments on commit 45996ec

Please sign in to comment.