Removed private channels from search - #272
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR changes the backend search behavior for messages by shifting channel filtering responsibility from the controller to the persistence layer and tightening the SQL joins to require a slack_channel match.
Changes:
- Removed the controller-side filter that previously dropped non-public channel IDs from
/messagesresults. - Updated the search SQL to remove the
message.channel LIKE 'C%'condition, switchslack_channelfromLEFT JOINtoINNER JOIN, and selectslack_channel.namedirectly aschannelName. - Updated/added unit tests to assert the new SQL join and controller pass-through behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/backend/src/search/search.persistence.service.ts | Alters SQL construction for message search (conditions, join type, selected channelName). |
| packages/backend/src/search/search.persistence.service.spec.ts | Updates assertions and adds a test reflecting the new SQL join expectations. |
| packages/backend/src/search/search.controller.ts | Removes controller-side filtering of messages by channel ID prefix. |
| packages/backend/src/search/search.controller.spec.ts | Updates test expectations to match controller pass-through behavior. |
Comments suppressed due to low confidence (2)
packages/backend/src/search/search.controller.spec.ts:74
- This test now asserts that private-channel (G…) and DM (D…) messages are returned unchanged. That contradicts the PR title (“Removed private channels from search”) and removes regression coverage that previously ensured only public channels were returned. Either restore an assertion that only public-channel messages are returned, or update the PR title/requirements to reflect the new behavior.
it('returns messages exactly as provided by persistence', async () => {
searchMessagesMock.mockResolvedValue({
messages: [
{ id: 1, message: 'public', name: 'alice', channel: 'C111' },
{ id: 2, message: 'private', name: 'bob', channel: 'G222' },
packages/backend/src/search/search.persistence.service.spec.ts:97
- This new test enforces that the query requires a matching
slack_channelrow via INNER JOIN. That requirement can unintentionally hide valid messages ifslack_channelis not fully populated (and it still doesn't guarantee private channels are excluded). If the intent is privacy (exclude G…/D…), add a test that asserts a public-channel filter and consider keepingslack_channelas a LEFT JOIN with COALESCE for resilience.
it('requires channel to exist in slack_channel via INNER JOIN', async () => {
query.mockResolvedValueOnce([{ total: 0 }]).mockResolvedValueOnce([]);
await service.searchMessages({ teamId: 'T1' });
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.