diff --git a/server/plugin/api.go b/server/plugin/api.go index 20746e87b..cf5652d9d 100644 --- a/server/plugin/api.go +++ b/server/plugin/api.go @@ -608,7 +608,7 @@ func (p *Plugin) getConnected(c *Context, w http.ResponseWriter, r *http.Request } info, err := p.getGitHubUserInfo(c.UserID) - if err != nil { + if err != nil && err.ID != apiErrorIDNotConnected { c.Log.WithError(err).Errorf("failed to get GitHub user info") p.writeAPIError(w, &APIErrorResponse{Message: fmt.Sprintf("failed to get GitHub user info. %s", err.Message), StatusCode: err.StatusCode}) return diff --git a/server/plugin/plugin.go b/server/plugin/plugin.go index 82ce05b6e..b2bce369a 100644 --- a/server/plugin/plugin.go +++ b/server/plugin/plugin.go @@ -1112,7 +1112,9 @@ func (p *Plugin) sendRefreshEvent(userID string) { info, apiErr := p.getGitHubUserInfo(context.UserID) if apiErr != nil { - p.client.Log.Warn("Failed to get github user info", "error", apiErr.Error()) + if apiErr.ID != apiErrorIDNotConnected { + p.client.Log.Debug("Failed to get github user info", "error", apiErr.Error()) + } return } diff --git a/server/plugin/webhook_test.go b/server/plugin/webhook_test.go index 1ef4d1043..aea818d16 100644 --- a/server/plugin/webhook_test.go +++ b/server/plugin/webhook_test.go @@ -509,7 +509,6 @@ func TestHandleCommentMentionNotification(t *testing.T) { mockAPI.On("GetDirectChannel", "otherUserID", "mockBotID").Return(&model.Channel{Id: "mockChannelID"}, nil).Times(1) mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1) mockAPI.On("LogWarn", "Error creating mention post", "error", "error creating post").Times(1) - mockAPI.On("LogWarn", "Failed to get github user info", "error", "Must connect user account to GitHub first.").Times(1) }, }, { @@ -526,7 +525,6 @@ func TestHandleCommentMentionNotification(t *testing.T) { })).Return(nil).Times(1) mockAPI.On("GetDirectChannel", "otherUserID", "mockBotID").Return(&model.Channel{Id: "mockChannelID"}, nil).Times(1) mockAPI.On("CreatePost", mock.Anything).Return(&model.Post{}, nil).Times(1) - mockAPI.On("LogWarn", "Failed to get github user info", "error", "Must connect user account to GitHub first.") }, }, } @@ -609,7 +607,6 @@ func TestHandleCommentAuthorNotification(t *testing.T) { })).Return(nil).Times(1) mockAPI.On("GetDirectChannel", "authorUserID", "mockBotID").Return(&model.Channel{Id: "mockChannelID"}, nil).Times(1) mockAPI.On("CreatePost", mock.Anything).Return(&model.Post{}, nil, &model.AppError{Message: "error creating post"}).Times(1) - mockAPI.On("LogWarn", "Failed to get github user info", "error", "Must connect user account to GitHub first.").Times(1) }, }, { @@ -628,7 +625,6 @@ func TestHandleCommentAuthorNotification(t *testing.T) { _, ok := val.(**GitHubUserInfo) return ok })).Return(nil).Times(1) - mockAPI.On("LogWarn", "Failed to get github user info", "error", "Must connect user account to GitHub first.").Times(1) mockAPI.On("GetDirectChannel", "authorUserID", "mockBotID").Return(&model.Channel{Id: "mockChannelID"}, nil).Times(1) mockAPI.On("CreatePost", mock.Anything).Return(&model.Post{}, nil).Times(1) }, @@ -774,7 +770,6 @@ func TestHandlePullRequestNotification(t *testing.T) { })).Return(nil).Times(1) mockAPI.On("GetDirectChannel", "authorUserID", "mockBotID").Return(&model.Channel{Id: "mockChannelID"}, nil) mockAPI.On("CreatePost", mock.Anything).Return(&model.Post{}, nil).Times(1) - mockAPI.On("LogWarn", "Failed to get github user info", "error", "Must connect user account to GitHub first.").Times(1) }, }, { @@ -806,7 +801,6 @@ func TestHandlePullRequestNotification(t *testing.T) { _, ok := val.(**GitHubUserInfo) return ok })).Return(nil).Times(1) - mockAPI.On("LogWarn", "Failed to get github user info", "error", "Must connect user account to GitHub first.").Times(1) }, }, { @@ -823,7 +817,6 @@ func TestHandlePullRequestNotification(t *testing.T) { _, ok := val.(**GitHubUserInfo) return ok })).Return(nil).Times(1) - mockAPI.On("LogWarn", "Failed to get github user info", "error", "Must connect user account to GitHub first.").Times(1) }, }, { @@ -990,7 +983,6 @@ func TestHandlePullRequestReviewNotification(t *testing.T) { _, ok := val.(**GitHubUserInfo) return ok })).Return(nil).Times(1) - mockAPI.On("LogWarn", "Failed to get github user info", "error", "Must connect user account to GitHub first.") }, }, }