Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/plugin/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func (p *Plugin) createPost(channelID, userID, message string) error {
}

if err := p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error while creating post", "post", post, "error", err.Error())
p.client.Log.Warn("Error while creating post", "channel_id", post.ChannelId, "error", err.Error())
return err
}

Expand Down
6 changes: 3 additions & 3 deletions server/plugin/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ func TestCreatePost(t *testing.T) {
name: "Error creating a post",
setup: func() {
mockAPI.On("CreatePost", post).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error while creating post", "post", post, "error", "error creating post").Times(1)
mockAPI.On("LogWarn", "Error while creating post", "channel_id", mock.Anything, "error", "error creating post").Times(1)
},
assertions: func(t *testing.T, err error) {
assert.EqualError(t, err, "error creating post")
Expand Down Expand Up @@ -1179,7 +1179,7 @@ func TestHandleUnsubscribe(t *testing.T) {
mockAPI.On("GetUser", MockUserID).Return(&model.User{Username: MockUsername}, nil).Times(1)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
post.Message = "@mockUsername unsubscribed this channel from [owner](https://github.com/owner)"
mockAPI.On("LogWarn", "Error while creating post", "post", post, "error", "error creating post").Times(1)
mockAPI.On("LogWarn", "Error while creating post", "channel_id", mock.Anything, "error", "error creating post").Times(1)
mockKVStore.EXPECT().SetAtomicWithRetries(SubscriptionsKey, gomock.Any()).Return(nil).Times(1)
},
assertions: func(result string) {
Expand Down Expand Up @@ -1217,7 +1217,7 @@ func TestHandleUnsubscribe(t *testing.T) {
mockAPI.On("GetUser", MockUserID).Return(&model.User{Username: MockUsername}, nil).Times(1)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
post.Message = "@mockUsername Unsubscribed this channel from [owner/repo](https://github.com/owner/repo)\n Please delete the [webhook](https://github.com/owner/repo/settings/hooks) for this subscription unless it's required for other subscriptions."
mockAPI.On("LogWarn", "Error while creating post", "post", post, "error", "error creating post").Times(1)
mockAPI.On("LogWarn", "Error while creating post", "channel_id", mock.Anything, "error", "error creating post").Times(1)
mockKVStore.EXPECT().SetAtomicWithRetries(SubscriptionsKey, gomock.Any()).Return(nil).Times(1)
},
assertions: func(result string) {
Expand Down
2 changes: 1 addition & 1 deletion server/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ func (p *Plugin) CreateBotDMPost(userID, message, postType string) {
}

if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Failed to create DM post", "userID", userID, "post", post, "error", err.Error())
p.client.Log.Warn("Failed to create DM post", "user_id", userID, "channel_id", post.ChannelId, "error", err.Error())
return
}
}
Expand Down
30 changes: 15 additions & 15 deletions server/plugin/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func (p *Plugin) postPullRequestEvent(event *github.PullRequestEvent) {

post.ChannelId = sub.ChannelID
if err := p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "post", post, "error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -624,7 +624,7 @@ func (p *Plugin) handlePRDescriptionMentionNotification(event *github.PullReques
post.ChannelId = channel.Id

if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "post", post, "error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}

p.sendRefreshEvent(userID)
Expand Down Expand Up @@ -725,7 +725,7 @@ func (p *Plugin) postIssueEvent(event *github.IssuesEvent) {

post.ChannelId = sub.ChannelID
if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "post", post, "error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -768,7 +768,7 @@ func (p *Plugin) postPushEvent(event *github.PushEvent) {

post.ChannelId = sub.ChannelID
if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "post", post, "error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -809,7 +809,7 @@ func (p *Plugin) postCreateEvent(event *github.CreateEvent) {

post.ChannelId = sub.ChannelID
if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "post", post, "error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -851,7 +851,7 @@ func (p *Plugin) postDeleteEvent(event *github.DeleteEvent) {
post := p.makeBotPost(newDeleteMessage, "custom_git_delete")
post.ChannelId = sub.ChannelID
if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "post", post, "error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -922,7 +922,7 @@ func (p *Plugin) postIssueCommentEvent(event *github.IssueCommentEvent) {
post.ChannelId = sub.ChannelID

if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "post", post, "error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -1011,7 +1011,7 @@ func (p *Plugin) postPullRequestReviewEvent(event *github.PullRequestReviewEvent

post.ChannelId = sub.ChannelID
if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "post", post, "error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -1072,7 +1072,7 @@ func (p *Plugin) postPullRequestReviewCommentEvent(event *github.PullRequestRevi

post.ChannelId = sub.ChannelID
if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "post", post, "error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -1470,7 +1470,7 @@ func (p *Plugin) postStarEvent(event *github.StarEvent) {

post.ChannelId = sub.ChannelID
if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "post", post, "error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -1510,7 +1510,7 @@ func (p *Plugin) postWorkflowJobEvent(event *github.WorkflowJobEvent) {
}

if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "Post", post, "Error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -1563,7 +1563,7 @@ func (p *Plugin) postWorkflowRunEvent(event *github.WorkflowRunEvent) {
}

if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "Post", post, "Error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -1607,7 +1607,7 @@ func (p *Plugin) postReleaseEvent(event *github.ReleaseEvent) {
}

if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error webhook post", "Post", post, "Error", err.Error())
p.client.Log.Warn("Error webhook post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -1645,7 +1645,7 @@ func (p *Plugin) postDiscussionEvent(event *github.DiscussionEvent) {
post.AddProp(postPropGithubObjectType, "discussion")
post.ChannelId = sub.ChannelID
if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error creating discussion notification post", "Post", post, "Error", err.Error())
p.client.Log.Warn("Error creating discussion notification post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
Expand Down Expand Up @@ -1683,7 +1683,7 @@ func (p *Plugin) postDiscussionCommentEvent(event *github.DiscussionCommentEvent

post.ChannelId = sub.ChannelID
if err = p.client.Post.CreatePost(post); err != nil {
p.client.Log.Warn("Error creating discussion comment post", "Post", post, "Error", err.Error())
p.client.Log.Warn("Error creating discussion comment post", "channel_id", post.ChannelId, "error", err.Error())
}
}
}
22 changes: 11 additions & 11 deletions server/plugin/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestPostPushEvent(t *testing.T) {
setup: func(mockAPI *plugintest.API, mockKVStore *mocks.MockKvStore) {
mockSubscription(mockKVStore)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error webhook post", "post", mock.Anything, "error", "error creating post")
mockAPI.On("LogWarn", "Error webhook post", "channel_id", mock.Anything, "error", "error creating post")
},
},
{
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestPostCreateEvent(t *testing.T) {
setup: func(mockAPI *plugintest.API, mockKVStore *mocks.MockKvStore) {
mockSubscription(mockKVStore)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error webhook post", "post", mock.Anything, "error", "error creating post")
mockAPI.On("LogWarn", "Error webhook post", "channel_id", mock.Anything, "error", "error creating post")
},
},
{
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestPostDeleteEvent(t *testing.T) {
setup: func(mockAPI *plugintest.API, mockKVStore *mocks.MockKvStore) {
mockSubscription(mockKVStore)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error webhook post", "post", mock.Anything, "error", "error creating post")
mockAPI.On("LogWarn", "Error webhook post", "channel_id", mock.Anything, "error", "error creating post")
},
},
{
Expand Down Expand Up @@ -282,7 +282,7 @@ func TestPostIssueCommentEvent(t *testing.T) {
setup: func(mockAPI *plugintest.API, mockKVStore *mocks.MockKvStore) {
mockSubscription(mockKVStore)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error webhook post", "post", mock.Anything, "error", "error creating post").Times(1)
mockAPI.On("LogWarn", "Error webhook post", "channel_id", mock.Anything, "error", "error creating post").Times(1)
},
},
{
Expand Down Expand Up @@ -450,7 +450,7 @@ func TestPostPullRequestReviewEvent(t *testing.T) {
setup: func(mockAPI *plugintest.API, mockKVStore *mocks.MockKvStore) {
mockSubscription(mockKVStore)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error webhook post", "post", mock.Anything, "error", "error creating post").Times(1)
mockAPI.On("LogWarn", "Error webhook post", "channel_id", mock.Anything, "error", "error creating post").Times(1)
},
},
{
Expand Down Expand Up @@ -499,7 +499,7 @@ func TestPostPullRequestReviewCommentEvent(t *testing.T) {
setup: func(mockAPI *plugintest.API, mockKVStore *mocks.MockKvStore) {
mockSubscription(mockKVStore)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error webhook post", "post", mock.Anything, "error", "error creating post").Times(1)
mockAPI.On("LogWarn", "Error webhook post", "channel_id", mock.Anything, "error", "error creating post").Times(1)
},
},
{
Expand Down Expand Up @@ -1305,7 +1305,7 @@ func TestPostStarEvent(t *testing.T) {
},
})).Times(1)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error webhook post", "post", mock.Anything, "error", "error creating post")
mockAPI.On("LogWarn", "Error webhook post", "channel_id", mock.Anything, "error", "error creating post")
},
},
{
Expand Down Expand Up @@ -1375,7 +1375,7 @@ func TestPostReleaseEvent(t *testing.T) {
},
})).Times(1)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error webhook post", "Post", mock.Anything, "Error", "error creating post")
mockAPI.On("LogWarn", "Error webhook post", "channel_id", mock.Anything, "error", "error creating post")
},
},
{
Expand Down Expand Up @@ -1440,7 +1440,7 @@ func TestPostDiscussionEvent(t *testing.T) {
},
})).Times(1)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error creating discussion notification post", "Post", mock.Anything, "Error", "error creating post")
mockAPI.On("LogWarn", "Error creating discussion notification post", "channel_id", mock.Anything, "error", "error creating post")
},
},
{
Expand Down Expand Up @@ -1593,7 +1593,7 @@ func TestPostWorkflowRunEvent(t *testing.T) {
},
})).Times(1)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error webhook post", "Post", mock.Anything, "Error", "error creating post")
mockAPI.On("LogWarn", "Error webhook post", "channel_id", mock.Anything, "error", "error creating post")
},
},
{
Expand Down Expand Up @@ -1702,7 +1702,7 @@ func TestPostDiscussionCommentEvent(t *testing.T) {
},
})).Times(1)
mockAPI.On("CreatePost", mock.Anything).Return(nil, &model.AppError{Message: "error creating post"}).Times(1)
mockAPI.On("LogWarn", "Error creating discussion comment post", "Post", mock.Anything, "Error", "error creating post")
mockAPI.On("LogWarn", "Error creating discussion comment post", "channel_id", mock.Anything, "error", "error creating post")
},
},
{
Expand Down
Loading