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
16 changes: 16 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/webapp/channels/src/packages/mattermost-redux/src/store/configureStore.ts @hmhealey
/server/channels/app/authentication.go @mattermost/product-security
/server/channels/app/authorization.go @mattermost/product-security

# Release-owned documentation. A review from either @mattermost/release-eng or
# @mattermost/release-managers is required for changes to these pages.
/docs/main/product-overview/*changelog.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/product-overview/*release*.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/product-overview/common-esr-support*.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/product-overview/deprecated-features.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/product-overview/server.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/product-overview/version-archive.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/administration-guide/upgrade/important-upgrade-notes.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/administration-guide/upgrade/open-source-components.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/administration-guide/upgrade/prepare-to-upgrade-mattermost.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/deployment-guide/software-hardware-requirements.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/deployment-guide/desktop/*install.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/deployment-guide/server/linux/deploy-rhel.mdx @mattermost/release-eng @mattermost/release-managers
/docs/main/deployment-guide/server/linux/deploy-tar.mdx @mattermost/release-eng @mattermost/release-managers
2 changes: 1 addition & 1 deletion api/server/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mattermost/mattermost/api/internal

go 1.26.4
go 1.26.7

require (
github.com/pb33f/libopenapi v0.36.4
Expand Down
6 changes: 3 additions & 3 deletions server/channels/api4/content_flagging.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func requireFlaggedPost(c *Context, postId string) {
return
}

_, appErr := c.App.GetPostContentFlaggingPropertyValue(postId, app.ContentFlaggingPropertyNameStatus)
_, appErr := c.App.GetPostContentFlaggingPropertyValue(c.AppContext, postId, app.ContentFlaggingPropertyNameStatus)
if appErr != nil {
c.Err = appErr
return
Expand Down Expand Up @@ -252,7 +252,7 @@ func getContentFlaggingFields(c *Context, w http.ResponseWriter, r *http.Request
return
}

mappedFields, appErr := c.App.GetContentFlaggingMappedFields(groupId)
mappedFields, appErr := c.App.GetContentFlaggingMappedFields(c.AppContext, groupId)
if appErr != nil {
c.Err = appErr
return
Expand Down Expand Up @@ -300,7 +300,7 @@ func getPostPropertyValues(c *Context, w http.ResponseWriter, r *http.Request) {
return
}

propertyValues, appErr := c.App.GetPostContentFlaggingPropertyValues(postId)
propertyValues, appErr := c.App.GetPostContentFlaggingPropertyValues(c.AppContext, postId)
if appErr != nil {
c.Err = appErr
return
Expand Down
4 changes: 2 additions & 2 deletions server/channels/app/access_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,7 @@ func (a *App) GetAccessControlPolicyAttributes(rctx request.CTX, channelID strin
for fieldName := range attributes {
// Read directly from the store so this security filter sees the raw
// access_mode, unaffected by property read hooks for the request caller.
field, fieldErr := a.Srv().Store().PropertyField().GetFieldByNameForObjectType(rctx.Context(), cpaGroup.ID, "", model.PropertyFieldObjectTypeUser, fieldName)
field, fieldErr := a.Srv().Store().PropertyField().GetFieldByNameForObjectType(rctx, cpaGroup.ID, "", model.PropertyFieldObjectTypeUser, fieldName)
if fieldErr != nil {
delete(attributes, fieldName)
continue
Expand Down Expand Up @@ -2518,7 +2518,7 @@ func (a *App) BuildAccessControlSubjectForSession(rctx request.CTX, channelID st
return nil, appErr
}

attrs, appErr := a.GetSessionAttributes(rctx.Session().Id)
attrs, appErr := a.GetSessionAttributes(rctx, rctx.Session().Id)
if appErr != nil {
return nil, appErr
}
Expand Down
66 changes: 33 additions & 33 deletions server/channels/app/content_flagging.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ func (a *App) FlagPost(rctx request.CTX, post *model.Post, teamId, reportingUser
return appErr
}

appErr = a.canFlagPost(groupId, post.Id, reportingUser.Locale)
appErr = a.canFlagPost(rctx, groupId, post.Id, reportingUser.Locale)
if appErr != nil {
return appErr
}

mappedFields, appErr := a.GetContentFlaggingMappedFields(groupId)
mappedFields, appErr := a.GetContentFlaggingMappedFields(rctx, groupId)
if appErr != nil {
return appErr
}
Expand Down Expand Up @@ -247,21 +247,21 @@ func (a *App) ContentFlaggingGroupId() (string, *model.AppError) {
return group.ID, nil
}

func (a *App) GetPostContentFlaggingPropertyValue(postId, propertyFieldName string) (*model.PropertyValue, *model.AppError) {
func (a *App) GetPostContentFlaggingPropertyValue(rctx request.CTX, postId, propertyFieldName string) (*model.PropertyValue, *model.AppError) {
groupId, err := a.ContentFlaggingGroupId()
if err != nil {
return nil, model.NewAppError("GetPostContentFlaggingPropertyValue", "app.data_spillage.get_group.error", nil, "", http.StatusInternalServerError).Wrap(err)
}

// Content flagging fields carry no object type, so the empty object type is
// their exact scope.
statusPropertyField, appErr := a.GetPropertyFieldByNameForObjectType(nil, groupId, "", "", propertyFieldName)
statusPropertyField, appErr := a.GetPropertyFieldByNameForObjectType(rctx, groupId, "", "", propertyFieldName)
if appErr != nil {
return nil, model.NewAppError("GetPostContentFlaggingPropertyValue", "app.data_spillage.get_status_property.app_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
}

searchOptions := model.PropertyValueSearchOpts{TargetIDs: []string{postId}, PerPage: CONTENT_FLAGGING_MAX_PROPERTY_VALUES, FieldID: statusPropertyField.ID}
propertyValues, appErr := a.SearchPropertyValues(nil, groupId, searchOptions)
propertyValues, appErr := a.SearchPropertyValues(rctx, groupId, searchOptions)
if appErr != nil {
return nil, model.NewAppError("GetPostContentFlaggingPropertyValue", "app.data_spillage.search_status_property.app_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
}
Expand All @@ -273,8 +273,8 @@ func (a *App) GetPostContentFlaggingPropertyValue(postId, propertyFieldName stri
return propertyValues[0], nil
}

func (a *App) canFlagPost(groupId, postId, userLocal string) *model.AppError {
status, appErr := a.GetPostContentFlaggingPropertyValue(postId, ContentFlaggingPropertyNameStatus)
func (a *App) canFlagPost(rctx request.CTX, groupId, postId, userLocal string) *model.AppError {
status, appErr := a.GetPostContentFlaggingPropertyValue(rctx, postId, ContentFlaggingPropertyNameStatus)
if appErr != nil {
if appErr.StatusCode == http.StatusNotFound {
return nil
Expand All @@ -299,8 +299,8 @@ func (a *App) canFlagPost(groupId, postId, userLocal string) *model.AppError {
return model.NewAppError("canFlagPost", reason, nil, "", http.StatusBadRequest)
}

func (a *App) CheckFlaggedPostActionable(where, postId string) (*model.PropertyValue, *model.AppError) {
status, appErr := a.GetPostContentFlaggingPropertyValue(postId, ContentFlaggingPropertyNameStatus)
func (a *App) CheckFlaggedPostActionable(rctx request.CTX, where, postId string) (*model.PropertyValue, *model.AppError) {
status, appErr := a.GetPostContentFlaggingPropertyValue(rctx, postId, ContentFlaggingPropertyNameStatus)
if appErr != nil {
return nil, appErr
}
Expand All @@ -313,8 +313,8 @@ func (a *App) CheckFlaggedPostActionable(where, postId string) (*model.PropertyV
return status, nil
}

func (a *App) GetContentFlaggingMappedFields(groupId string) (map[string]*model.PropertyField, *model.AppError) {
fields, appErr := a.SearchPropertyFields(nil, groupId, model.PropertyFieldSearchOpts{PerPage: CONTENT_FLAGGING_MAX_PROPERTY_FIELDS})
func (a *App) GetContentFlaggingMappedFields(rctx request.CTX, groupId string) (map[string]*model.PropertyField, *model.AppError) {
fields, appErr := a.SearchPropertyFields(rctx, groupId, model.PropertyFieldSearchOpts{PerPage: CONTENT_FLAGGING_MAX_PROPERTY_FIELDS})
if appErr != nil {
return nil, model.NewAppError("GetContentFlaggingMappedFields", "app.data_spillage.search_property_fields.app_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
}
Expand Down Expand Up @@ -387,7 +387,7 @@ func (a *App) createContentReviewPost(rctx request.CTX, flaggedPostId, teamId, r
FieldID: flaggedPostIdFieldId,
Value: json.RawMessage(fmt.Sprintf(`"%s"`, flaggedPostId)),
}
_, appErr = a.CreatePropertyValue(nil, propertyValue)
_, appErr = a.CreatePropertyValue(rctx, propertyValue)
if appErr != nil {
rctx.Logger().Error("Failed to create content review post property value in one of the channels", mlog.Err(appErr), mlog.String("channel_id", channel.Id), mlog.String("team_id", teamId), mlog.String("post_id", createdPost.Id))
}
Expand Down Expand Up @@ -560,13 +560,13 @@ func (a *App) IsUserTeamContentReviewer(userId, teamId string) (bool, *model.App
return slices.Contains(reviewers, userId), nil
}

func (a *App) GetPostContentFlaggingPropertyValues(postId string) ([]*model.PropertyValue, *model.AppError) {
func (a *App) GetPostContentFlaggingPropertyValues(rctx request.CTX, postId string) ([]*model.PropertyValue, *model.AppError) {
groupId, err := a.ContentFlaggingGroupId()
if err != nil {
return nil, model.NewAppError("GetPostContentFlaggingPropertyValues", "app.data_spillage.get_group.error", nil, "", http.StatusInternalServerError).Wrap(err)
}

propertyValues, appErr := a.SearchPropertyValues(nil, groupId, model.PropertyValueSearchOpts{TargetIDs: []string{postId}, PerPage: CONTENT_FLAGGING_MAX_PROPERTY_VALUES})
propertyValues, appErr := a.SearchPropertyValues(rctx, groupId, model.PropertyValueSearchOpts{TargetIDs: []string{postId}, PerPage: CONTENT_FLAGGING_MAX_PROPERTY_VALUES})
if appErr != nil {
return nil, model.NewAppError("GetPostContentFlaggingPropertyValues", "app.data_spillage.search_property_values.app_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
}
Expand All @@ -593,7 +593,7 @@ func (a *App) PermanentDeleteFlaggedPost(rctx request.CTX, actionRequest *model.
// generating unsafe JSON values
commentJsonValue := json.RawMessage(commentBytes)

status, appErr := a.CheckFlaggedPostActionable("PermanentlyRemoveFlaggedPost", flaggedPost.Id)
status, appErr := a.CheckFlaggedPostActionable(rctx, "PermanentlyRemoveFlaggedPost", flaggedPost.Id)
if appErr != nil {
return appErr
}
Expand All @@ -617,12 +617,12 @@ func (a *App) PermanentDeleteFlaggedPost(rctx request.CTX, actionRequest *model.
return appErr
}

mappedFields, appErr := a.GetContentFlaggingMappedFields(groupId)
mappedFields, appErr := a.GetContentFlaggingMappedFields(rctx, groupId)
if appErr != nil {
return appErr
}

existingComment, appErr := a.GetPostContentFlaggingPropertyValue(flaggedPost.Id, contentFlaggingPropertyNameActorComment)
existingComment, appErr := a.GetPostContentFlaggingPropertyValue(rctx, flaggedPost.Id, contentFlaggingPropertyNameActorComment)
if appErr != nil && appErr.StatusCode != http.StatusNotFound {
return appErr
}
Expand Down Expand Up @@ -877,7 +877,7 @@ func (a *App) KeepFlaggedPost(rctx request.CTX, actionRequest *model.FlagContent
// for keeping a flagged flaggedPost we need to-
// 1. Undelete the flaggedPost if it was deleted, that's it

status, appErr := a.CheckFlaggedPostActionable("KeepFlaggedPost", flaggedPost.Id)
status, appErr := a.CheckFlaggedPostActionable(rctx, "KeepFlaggedPost", flaggedPost.Id)
if appErr != nil {
return appErr
}
Expand All @@ -887,12 +887,12 @@ func (a *App) KeepFlaggedPost(rctx request.CTX, actionRequest *model.FlagContent
return model.NewAppError("KeepFlaggedPost", "app.data_spillage.get_group.error", nil, "", http.StatusInternalServerError).Wrap(err)
}

mappedFields, appErr := a.GetContentFlaggingMappedFields(groupId)
mappedFields, appErr := a.GetContentFlaggingMappedFields(rctx, groupId)
if appErr != nil {
return appErr
}

contentFlaggingManaged, appErr := a.GetPostContentFlaggingPropertyValue(flaggedPost.Id, contentFlaggingPropertyManageByContentFlagging)
contentFlaggingManaged, appErr := a.GetPostContentFlaggingPropertyValue(rctx, flaggedPost.Id, contentFlaggingPropertyManageByContentFlagging)
if appErr != nil && appErr.StatusCode != http.StatusNotFound {
return appErr
}
Expand Down Expand Up @@ -927,7 +927,7 @@ func (a *App) KeepFlaggedPost(rctx request.CTX, actionRequest *model.FlagContent
// generating unsafe JSON values
commentJsonValue := json.RawMessage(commentBytes)

existingComment, appErr := a.GetPostContentFlaggingPropertyValue(flaggedPost.Id, contentFlaggingPropertyNameActorComment)
existingComment, appErr := a.GetPostContentFlaggingPropertyValue(rctx, flaggedPost.Id, contentFlaggingPropertyNameActorComment)
if appErr != nil && appErr.StatusCode != http.StatusNotFound {
return appErr
}
Expand Down Expand Up @@ -958,13 +958,13 @@ func (a *App) KeepFlaggedPost(rctx request.CTX, actionRequest *model.FlagContent
})
}

_, appErr = a.CreatePropertyValues(nil, propertyValues)
_, appErr = a.CreatePropertyValues(rctx, propertyValues)
if appErr != nil {
return model.NewAppError("KeepFlaggedPost", "app.data_spillage.create_property_values.app_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
}

status.Value = json.RawMessage(fmt.Sprintf(`"%s"`, model.ContentFlaggingStatusRetained))
_, appErr = a.UpdatePropertyValue(nil, groupId, status)
_, appErr = a.UpdatePropertyValue(rctx, groupId, status)
if appErr != nil {
return model.NewAppError("KeepFlaggedPost", "app.data_spillage.keep_post.status_update.app_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
}
Expand Down Expand Up @@ -1147,7 +1147,7 @@ func (a *App) SearchReviewers(rctx request.CTX, term string, teamId string) ([]*
}

func (a *App) AssignFlaggedPostReviewer(rctx request.CTX, flaggedPostId, flaggedPostTeamId, reviewerId, assigneeId string) *model.AppError {
statusPropertyValue, appErr := a.GetPostContentFlaggingPropertyValue(flaggedPostId, ContentFlaggingPropertyNameStatus)
statusPropertyValue, appErr := a.GetPostContentFlaggingPropertyValue(rctx, flaggedPostId, ContentFlaggingPropertyNameStatus)
if appErr != nil {
return appErr
}
Expand All @@ -1159,7 +1159,7 @@ func (a *App) AssignFlaggedPostReviewer(rctx request.CTX, flaggedPostId, flagged
return model.NewAppError("AssignFlaggedPostReviewer", "app.data_spillage.get_group.error", nil, "", http.StatusInternalServerError).Wrap(err)
}

mappedFields, appErr := a.GetContentFlaggingMappedFields(groupId)
mappedFields, appErr := a.GetContentFlaggingMappedFields(rctx, groupId)
if appErr != nil {
return appErr
}
Expand Down Expand Up @@ -1263,8 +1263,8 @@ func (a *App) postKeepPostReviewerMessage(rctx request.CTX, flaggedPostId, actor
return a.postReviewerMessage(rctx, message, contentFlaggingGroupId, flaggedPostId, nil, "")
}

func (a *App) getReporterUserId(flaggedPostId, contentFlaggingGroupId string) (string, *model.AppError) {
mappedFields, appErr := a.GetContentFlaggingMappedFields(contentFlaggingGroupId)
func (a *App) getReporterUserId(rctx request.CTX, flaggedPostId, contentFlaggingGroupId string) (string, *model.AppError) {
mappedFields, appErr := a.GetContentFlaggingMappedFields(rctx, contentFlaggingGroupId)
if appErr != nil {
return "", appErr
}
Expand All @@ -1274,7 +1274,7 @@ func (a *App) getReporterUserId(flaggedPostId, contentFlaggingGroupId string) (s
return "", model.NewAppError("getReporterUserId", "app.data_spillage.missing_reporting_user_id_field.app_error", nil, "", http.StatusInternalServerError)
}

propertyValues, appErr := a.GetPostContentFlaggingPropertyValues(flaggedPostId)
propertyValues, appErr := a.GetPostContentFlaggingPropertyValues(rctx, flaggedPostId)
if appErr != nil {
return "", appErr
}
Expand Down Expand Up @@ -1321,7 +1321,7 @@ func (a *App) postContentReviewBotMessage(rctx request.CTX, message string, reci
}

func (a *App) postMessageToReporter(rctx request.CTX, contentFlaggingGroupId string, flaggedPost *model.Post, message string) (*model.Post, *model.AppError) {
userId, appErr := a.getReporterUserId(flaggedPost.Id, contentFlaggingGroupId)
userId, appErr := a.getReporterUserId(rctx, flaggedPost.Id, contentFlaggingGroupId)
if appErr != nil {
return nil, appErr
}
Expand All @@ -1330,7 +1330,7 @@ func (a *App) postMessageToReporter(rctx request.CTX, contentFlaggingGroupId str
}

func (a *App) postReviewerMessage(rctx request.CTX, message, contentFlaggingGroupId, flaggedPostId string, report *model.PostDeletionReport, reportFileName string) ([]*model.Post, *model.AppError) {
mappedFields, appErr := a.GetContentFlaggingMappedFields(contentFlaggingGroupId)
mappedFields, appErr := a.GetContentFlaggingMappedFields(rctx, contentFlaggingGroupId)
if appErr != nil {
return nil, appErr
}
Expand All @@ -1340,7 +1340,7 @@ func (a *App) postReviewerMessage(rctx request.CTX, message, contentFlaggingGrou
return nil, model.NewAppError("postReviewerMessage", "app.data_spillage.missing_flagged_post_id_field.app_error", nil, "", http.StatusInternalServerError)
}

postIds, appErr := a.getReviewerPostsForFlaggedPost(contentFlaggingGroupId, flaggedPostId, flaggedPostIdField.ID)
postIds, appErr := a.getReviewerPostsForFlaggedPost(rctx, contentFlaggingGroupId, flaggedPostId, flaggedPostIdField.ID)
if appErr != nil {
return nil, appErr
}
Expand Down Expand Up @@ -1414,7 +1414,7 @@ func (a *App) postReviewerMessage(rctx request.CTX, message, contentFlaggingGrou
return createdPosts, nil
}

func (a *App) getReviewerPostsForFlaggedPost(contentFlaggingGroupId, flaggedPostId, flaggedPostIdFieldId string) ([]string, *model.AppError) {
func (a *App) getReviewerPostsForFlaggedPost(rctx request.CTX, contentFlaggingGroupId, flaggedPostId, flaggedPostIdFieldId string) ([]string, *model.AppError) {
searchOptions := model.PropertyValueSearchOpts{
TargetType: model.PropertyValueTargetTypePost,
Value: json.RawMessage(fmt.Sprintf(`"%s"`, flaggedPostId)),
Expand All @@ -1426,7 +1426,7 @@ func (a *App) getReviewerPostsForFlaggedPost(contentFlaggingGroupId, flaggedPost
var propertyValues []*model.PropertyValue

for {
batch, appErr := a.SearchPropertyValues(nil, contentFlaggingGroupId, searchOptions)
batch, appErr := a.SearchPropertyValues(rctx, contentFlaggingGroupId, searchOptions)
if appErr != nil {
return nil, model.NewAppError("getReviewerPostsForFlaggedPost", "app.data_spillage.search_reviewer_posts.app_error", nil, "", http.StatusInternalServerError).Wrap(appErr)
}
Expand Down
6 changes: 3 additions & 3 deletions server/channels/app/content_flagging_exposure_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (a *App) ComputePostExposure(rctx request.CTX, postID string) (*model.PostE
return nil, model.NewAppError("ComputePostExposure", "app.data_spillage.exposure.unsupported_channel_type.app_error", nil, "", http.StatusBadRequest)
}

windowEnd, appErr := a.getPostFlagTime(post.Id)
windowEnd, appErr := a.getPostFlagTime(rctx, post.Id)
if appErr != nil {
return nil, appErr
}
Expand Down Expand Up @@ -131,8 +131,8 @@ func (a *App) ComputePostExposure(rctx request.CTX, postID string) (*model.PostE
return report, nil
}

func (a *App) getPostFlagTime(postID string) (int64, *model.AppError) {
value, appErr := a.GetPostContentFlaggingPropertyValue(postID, contentFlaggingPropertyNameReportingTime)
func (a *App) getPostFlagTime(rctx request.CTX, postID string) (int64, *model.AppError) {
value, appErr := a.GetPostContentFlaggingPropertyValue(rctx, postID, contentFlaggingPropertyNameReportingTime)
if appErr != nil {
if appErr.StatusCode == http.StatusNotFound {
return 0, model.NewAppError("getPostFlagTime", "app.data_spillage.exposure.missing_reporting_time.app_error", nil, "", http.StatusInternalServerError)
Expand Down
Loading
Loading