[MM-60689] Add Webhook ID in the logs (#28846)

* add webhook id to logs

* Move hook_id context to api level from app level.

* pass errCtx to other references of same app-error-id

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Vishal
2024-11-21 13:53:10 +05:30
коммит произвёл GitHub
родитель c98f2e75fb
Коммит 746eb70e01
10 изменённых файлов: 88 добавлений и 69 удалений

Просмотреть файл

@@ -118,12 +118,13 @@ func (a *App) CreatePostAsUser(c request.CTX, post *model.Post, currentSessionId
func (a *App) CreatePostMissingChannel(c request.CTX, post *model.Post, triggerWebhooks bool, setOnline bool) (*model.Post, *model.AppError) {
channel, err := a.Srv().Store().Channel().Get(post.ChannelId, true)
if err != nil {
errCtx := map[string]any{"channel_id": post.ChannelId}
var nfErr *store.ErrNotFound
switch {
case errors.As(err, &nfErr):
return nil, model.NewAppError("CreatePostMissingChannel", "app.channel.get.existing.app_error", nil, "", http.StatusNotFound).Wrap(err)
return nil, model.NewAppError("CreatePostMissingChannel", "app.channel.get.existing.app_error", errCtx, "", http.StatusNotFound).Wrap(err)
default:
return nil, model.NewAppError("CreatePostMissingChannel", "app.channel.get.find.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
return nil, model.NewAppError("CreatePostMissingChannel", "app.channel.get.find.app_error", errCtx, "", http.StatusInternalServerError).Wrap(err)
}
}
@@ -573,7 +574,7 @@ func (a *App) handlePostEvents(c request.CTX, post *model.Post, user *model.User
if triggerWebhooks {
a.Srv().Go(func() {
if err := a.handleWebhookEvents(c, post, team, channel, user); err != nil {
c.Logger().Error("Failed to handle webhook event", mlog.Err(err))
c.Logger().Error("Failed to handle webhook event", mlog.String("user_id", user.Id), mlog.String("post_id", post.Id), mlog.Err(err))
}
})
}