Harmony backports (#3581)

Backport a few things from Harmony.

### Pull Request Checklist

<!-- Please read
https://matrix-org.github.io/dendrite/development/contributing before
submitting your pull request -->

* [ ] I have added Go unit tests or [Complement integration
tests](https://github.com/matrix-org/complement) for this PR _or_ I have
justified why this PR doesn't need tests
* [x] Pull request includes a [sign off
below](https://element-hq.github.io/dendrite/development/contributing#sign-off)
_or_ I have already signed off privately

---------

Signed-off-by: Till Faelligen <2353100+S7evinK@users.noreply.github.com>
Co-authored-by: Kegan Dougal <7190048+kegsay@users.noreply.github.com>
This commit is contained in:
Till 2025-06-19 09:49:03 +02:00 committed by GitHub
parent c133596baf
commit 331a6f221b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 11 deletions

View file

@ -92,6 +92,7 @@ func (s *accountDataStatements) SelectAccountDataInRange(
accountDataEventFilter *synctypes.EventFilter,
) (data map[string][]string, pos types.StreamPosition, err error) {
data = make(map[string][]string)
pos = r.Low()
rows, err := sqlutil.TxStmt(txn, s.selectAccountDataInRangeStmt).QueryContext(
ctx, userID, r.Low(), r.High(),
@ -122,7 +123,7 @@ func (s *accountDataStatements) SelectAccountDataInRange(
pos = id
}
}
if pos == 0 {
if len(data) == 0 {
pos = r.High()
}
return data, pos, rows.Err()

View file

@ -84,6 +84,8 @@ func (s *accountDataStatements) SelectAccountDataInRange(
filter *synctypes.EventFilter,
) (data map[string][]string, pos types.StreamPosition, err error) {
data = make(map[string][]string)
pos = r.Low()
stmt, params, err := prepareWithFilters(
s.db, txn, selectAccountDataInRangeSQL,
[]interface{}{
@ -119,7 +121,7 @@ func (s *accountDataStatements) SelectAccountDataInRange(
pos = id
}
}
if pos == 0 {
if len(data) == 0 {
pos = r.High()
}
return data, pos, rows.Err()