Skip to content

[pull] master from mattermost:master#204

Merged
pull[bot] merged 3 commits into
code:masterfrom
mattermost:master
Aug 25, 2025
Merged

[pull] master from mattermost:master#204
pull[bot] merged 3 commits into
code:masterfrom
mattermost:master

Conversation

@pull

@pull pull Bot commented Aug 25, 2025

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.3)

Can you help keep this open source service alive? 💖 Please sponsor : )

pvev and others added 3 commits August 25, 2025 17:24
Co-authored-by: Mattermost Build <build@mattermost.com>
…ll loading (#33607)

* Implement differentiated page sizes for post loading

Add perPage parameter to loadPosts function to optimize loading performance
based on context:
- User scroll: 30 posts per request (responsive UX)
- Auto-loading: 200 posts per request (efficient for sparse channels)

Changes:
- Make perPage required parameter in LoadPostsParameters interface
- Add USER_SCROLL_POSTS_PER_PAGE (30) and AUTO_LOAD_POSTS_PER_PAGE (200) constants
- Create separate getPostsBeforeAutoLoad() method for high-volume auto-loading
- Update canLoadMorePosts() to use auto-load method for maximum efficiency

This reduces server round-trips by 6.7x when auto-loading content in
channels with heavy join/leave message activity while maintaining
responsive user-initiated scrolling.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* drop pages to 20

* drop pages to 30

* lint fixes

* lint fixes, add tests

* more fixes

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
* Index all public channels when a user joins a team

* Precompute team members for indexChannelsForTeam

* Refactor RequestContextWithMaster to store package

This way, we can import it from both the sqlstore and the searchlayer
packages. The alternative for this is duplicating the code in those two
packages, but that will *not* work:

The context package expects custom types for the keys stored in it, so
that different packages never clash with each other when trying to
register a new key. See the docs for the WithValue function:
https://pkg.go.dev/context#WithValue

If we try to duplicate the storeContextKey type in both the sqlstore and
searchlayer packages, although they *look* the same, they are not, and
HasMaster will fail to get the value of the storeContextKey(useMaster)
key if it's from the other package.

* Use master in call to GetTeamMembersForChannel

In GetTeamMembersForChannel, use the DB from the newly passed context,
which will be the receiving context everywhere except in the call done
from indexChannelsForTeam, to avoid the read after write issue when
saving a team member.

* Fix GetPublicChannelsForTeam paging

We were using the page and perPage arguments as is in the call to
GetPublicChannelsForTeam, but that function expects and offset and a
limit as understood by SQL. Although perPage and limit are
interchangeable, offset is not equal to page, but to page * perPage.

* Add a synchronous bulk indexer for Opensearch

* Implement Opensearch's SyncBulkIndexChannels

* Add a synchronous bulk indexer for Elasticsearch

* Implement Elasticsearch's SynkBulkIndexChannels

* Test SyncBulkIndexChannels

* make mocks

* Bulk index channels on indexChannelsForTeam

* Handle error from SyncBulkIndexChannels

* Fix style

* Revert indexChannelWithTeamMembers refactor

* Remove defensive code on sync bulk processor

* Revert "Add a synchronous bulk indexer for Opensearch"

This reverts commit bfe4671.

* Revert "Add a synchronous bulk indexer for Elasticsearch"

This reverts commit 6643ae3.

* Refactor bulk indexers with a common interface

* Test all the different implementations

Assisted by Claude

* Remove debug statements

* Refactor common code into _stop

* Rename getUserIDsFor{,Private}Channel

* Wrap error

* Make perPage a const

* Fix typos

* Call GetTeamsForUser only if needed

* Differentiate errors for sync/async processors

---------

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
@pull pull Bot locked and limited conversation to collaborators Aug 25, 2025
@pull pull Bot added the ⤵️ pull label Aug 25, 2025
@pull pull Bot merged commit 553f996 into code:master Aug 25, 2025
15 of 17 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants