diff --git a/server/channels/app/file_test.go b/server/channels/app/file_test.go index b92885ebc1e..e13f43b393a 100644 --- a/server/channels/app/file_test.go +++ b/server/channels/app/file_test.go @@ -996,7 +996,9 @@ func TestFilterFilesByChannelPermissions(t *testing.T) { func TestFilterFilesByChannelPermissions_ABAC(t *testing.T) { mainHelper.Parallel(t) - th := Setup(t).InitBasic(t) + th := SetupConfig(t, func(cfg *model.Config) { + cfg.FeatureFlags.PermissionPolicies = true + }).InitBasic(t) post := th.CreatePost(t, th.BasicChannel) diff --git a/server/channels/app/web_broadcast_hooks.go b/server/channels/app/web_broadcast_hooks.go index d0307dc3583..ed6465b6ed2 100644 --- a/server/channels/app/web_broadcast_hooks.go +++ b/server/channels/app/web_broadcast_hooks.go @@ -204,7 +204,7 @@ func (h *permalinkBroadcastHook) Process(msg *platform.HookedWebSocketEvent, web (len(permalinkPreviewedPost.Post.FileIds) > 0 || (permalinkPreviewedPost.Post.Metadata != nil && len(permalinkPreviewedPost.Post.Metadata.Files) > 0)) { session := webConn.GetSession() - if session != nil && webConn.Platform.Config().FeatureFlags.PermissionPolicies { + if session != nil { rctxWithSession := rctx.WithSession(session) if !webConn.Suite.HasPermissionToFileAction(rctxWithSession, webConn.UserId, session.Roles, permalinkPreviewedPost.Post.ChannelId, model.AccessControlPolicyActionDownloadFileAttachment) { postCopy := permalinkPreviewedPost.Post.Clone() diff --git a/server/channels/app/web_broadcast_hooks_test.go b/server/channels/app/web_broadcast_hooks_test.go index 35c06c22846..9a1130256e8 100644 --- a/server/channels/app/web_broadcast_hooks_test.go +++ b/server/channels/app/web_broadcast_hooks_test.go @@ -634,9 +634,9 @@ func TestPermalinkBroadcastHook_AbacFileStripping(t *testing.T) { gotJSON, _ := msg.Get("post").(string) assert.NotContains(t, gotJSON, fileID, "file ID should be cleared") - // RedactedFileCount is 0 because Files was nil (len(nil) == 0). - // With JSON omitempty, a zero value is omitted from the output. - assert.NotContains(t, gotJSON, `"redacted_file_count"`, "zero redacted count is omitted by omitempty") + // RedactedFileCount falls back to len(FileIds) when Metadata.Files is nil, + // so the placeholder count is 1 even though Files was already cleared upstream. + assert.Contains(t, gotJSON, `"redacted_file_count":1`, "file count falls back to FileIds length") }) t.Run("no file stripping when embed has no files", func(t *testing.T) {