Cleanup usage of global logger (#26835)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
92a6c6517d
Коммит
30d450c4d8
@@ -99,7 +99,7 @@ func (a *App) CreatePostMissingChannel(c request.CTX, post *model.Post, triggerW
|
||||
}
|
||||
|
||||
// deduplicateCreatePost attempts to make posting idempotent within a caching window.
|
||||
func (a *App) deduplicateCreatePost(post *model.Post) (foundPost *model.Post, err *model.AppError) {
|
||||
func (a *App) deduplicateCreatePost(rctx request.CTX, post *model.Post) (foundPost *model.Post, err *model.AppError) {
|
||||
// We rely on the client sending the pending post id across "duplicate" requests. If there
|
||||
// isn't one, we can't deduplicate, so allow creation normally.
|
||||
if post.PendingPostId == "" {
|
||||
@@ -135,13 +135,13 @@ func (a *App) deduplicateCreatePost(post *model.Post) (foundPost *model.Post, er
|
||||
return nil, model.NewAppError("deduplicateCreatePost", "api.post.deduplicate_create_post.failed_to_get", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
mlog.Debug("Deduplicated create post", mlog.String("post_id", actualPost.Id), mlog.String("pending_post_id", post.PendingPostId))
|
||||
rctx.Logger().Debug("Deduplicated create post", mlog.String("post_id", actualPost.Id), mlog.String("pending_post_id", post.PendingPostId))
|
||||
|
||||
return actualPost, nil
|
||||
}
|
||||
|
||||
func (a *App) CreatePost(c request.CTX, post *model.Post, channel *model.Channel, triggerWebhooks, setOnline bool) (savedPost *model.Post, err *model.AppError) {
|
||||
foundPost, err := a.deduplicateCreatePost(post)
|
||||
foundPost, err := a.deduplicateCreatePost(c, post)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -588,7 +588,7 @@ func (a *App) UpdateEphemeralPost(c request.CTX, userID string, post *model.Post
|
||||
|
||||
sanitizedPost, appErr := a.SanitizePostMetadataForUser(c, post, userID)
|
||||
if appErr != nil {
|
||||
mlog.Error("Failed to sanitize post metadata for user", mlog.String("user_id", userID), mlog.Err(appErr))
|
||||
c.Logger().Error("Failed to sanitize post metadata for user", mlog.String("user_id", userID), mlog.Err(appErr))
|
||||
|
||||
// If we failed to sanitize the post, we still want to remove the metadata.
|
||||
sanitizedPost = post.Clone()
|
||||
@@ -607,7 +607,7 @@ func (a *App) UpdateEphemeralPost(c request.CTX, userID string, post *model.Post
|
||||
return post
|
||||
}
|
||||
|
||||
func (a *App) DeleteEphemeralPost(userID, postID string) {
|
||||
func (a *App) DeleteEphemeralPost(rctx request.CTX, userID, postID string) {
|
||||
post := &model.Post{
|
||||
Id: postID,
|
||||
UserId: userID,
|
||||
@@ -619,7 +619,7 @@ func (a *App) DeleteEphemeralPost(userID, postID string) {
|
||||
message := model.NewWebSocketEvent(model.WebsocketEventPostDeleted, "", "", userID, nil, "")
|
||||
postJSON, jsonErr := post.ToJSON()
|
||||
if jsonErr != nil {
|
||||
mlog.Warn("Failed to encode post to JSON", mlog.Err(jsonErr))
|
||||
rctx.Logger().Warn("Failed to encode post to JSON", mlog.Err(jsonErr))
|
||||
}
|
||||
message.Add("post", postJSON)
|
||||
a.Publish(message)
|
||||
@@ -2137,7 +2137,7 @@ func (a *App) GetEditHistoryForPost(postID string) ([]*model.Post, *model.AppErr
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (a *App) SetPostReminder(postID, userID string, targetTime int64) *model.AppError {
|
||||
func (a *App) SetPostReminder(rctx request.CTX, postID, userID string, targetTime int64) *model.AppError {
|
||||
// Store the reminder in the DB
|
||||
reminder := &model.PostReminder{
|
||||
PostId: postID,
|
||||
@@ -2185,12 +2185,12 @@ func (a *App) SetPostReminder(postID, userID string, targetTime int64) *model.Ap
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WebsocketEventEphemeralMessage, "", ephemeralPost.ChannelId, userID, nil, "")
|
||||
ephemeralPost = a.PreparePostForClientWithEmbedsAndImages(request.EmptyContext(a.Log()), ephemeralPost, true, false, true)
|
||||
ephemeralPost = a.PreparePostForClientWithEmbedsAndImages(rctx, ephemeralPost, true, false, true)
|
||||
ephemeralPost = model.AddPostActionCookies(ephemeralPost, a.PostActionCookieSecret())
|
||||
|
||||
postJSON, jsonErr := ephemeralPost.ToJSON()
|
||||
if jsonErr != nil {
|
||||
mlog.Warn("Failed to encode post to JSON", mlog.Err(jsonErr))
|
||||
rctx.Logger().Warn("Failed to encode post to JSON", mlog.Err(jsonErr))
|
||||
}
|
||||
message.Add("post", postJSON)
|
||||
a.Publish(message)
|
||||
|
||||
Ссылка в новой задаче
Block a user