aboutsummaryrefslogtreecommitdiff
path: root/syncapi
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-08-05 14:27:27 +0200
committerGitHub <noreply@github.com>2022-08-05 14:27:27 +0200
commit3a156a434ac193781774c7acfd6bf1c594028f74 (patch)
treea55b42cd206ffc1ab2aa5a6bf2748111f060ff1e /syncapi
parent3efc646f2567ced52a3e9980490c463866691414 (diff)
Invalidate lazyLoadCache if we're doing an initial sync (#2623)
* Bypass lazyLoadCache if we're doing an initial sync * Make the linter happy again? * Revert "Make the linter happy again?" This reverts commit 52a5691ba3c17c05698bcc6a13092090f27ace63. * Try that again * Invalidate LazyLoadCache on initial syncs * Remove unneeded check * Add TODO * Rename Invalite -> InvalidateLazyLoadedUser * Thanks IDE
Diffstat (limited to 'syncapi')
-rw-r--r--syncapi/routing/messages.go9
-rw-r--r--syncapi/streams/stream_pdu.go13
-rw-r--r--syncapi/streams/streams.go1
3 files changed, 19 insertions, 4 deletions
diff --git a/syncapi/routing/messages.go b/syncapi/routing/messages.go
index 990ca55b..b4c9a542 100644
--- a/syncapi/routing/messages.go
+++ b/syncapi/routing/messages.go
@@ -20,6 +20,10 @@ import (
"net/http"
"sort"
+ "github.com/matrix-org/gomatrixserverlib"
+ "github.com/matrix-org/util"
+ "github.com/sirupsen/logrus"
+
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/internal/caching"
"github.com/matrix-org/dendrite/roomserver/api"
@@ -28,9 +32,6 @@ import (
"github.com/matrix-org/dendrite/syncapi/sync"
"github.com/matrix-org/dendrite/syncapi/types"
userapi "github.com/matrix-org/dendrite/userapi/api"
- "github.com/matrix-org/gomatrixserverlib"
- "github.com/matrix-org/util"
- "github.com/sirupsen/logrus"
)
type messagesReq struct {
@@ -262,7 +263,7 @@ func (m *messagesResp) applyLazyLoadMembers(
}
}
for _, evt := range membershipToUser {
- m.State = append(m.State, gomatrixserverlib.HeaderedToClientEvent(evt, gomatrixserverlib.FormatSync))
+ m.State = append(m.State, gomatrixserverlib.HeaderedToClientEvent(evt, gomatrixserverlib.FormatAll))
}
}
diff --git a/syncapi/streams/stream_pdu.go b/syncapi/streams/stream_pdu.go
index 1003208f..1ad3adc4 100644
--- a/syncapi/streams/stream_pdu.go
+++ b/syncapi/streams/stream_pdu.go
@@ -12,9 +12,12 @@ import (
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/syncapi/types"
userapi "github.com/matrix-org/dendrite/userapi/api"
+
"github.com/matrix-org/gomatrixserverlib"
"github.com/tidwall/gjson"
"go.uber.org/atomic"
+
+ "github.com/matrix-org/dendrite/syncapi/notifier"
)
// The max number of per-room goroutines to have running.
@@ -34,6 +37,7 @@ type PDUStreamProvider struct {
// userID+deviceID -> lazy loading cache
lazyLoadCache caching.LazyLoadCache
rsAPI roomserverAPI.SyncRoomserverAPI
+ notifier *notifier.Notifier
}
func (p *PDUStreamProvider) worker() {
@@ -100,6 +104,15 @@ func (p *PDUStreamProvider) CompleteSync(
req.Log.WithError(err).Error("unable to update event filter with ignored users")
}
+ // Invalidate the lazyLoadCache, otherwise we end up with missing displaynames/avatars
+ // TODO: This might be inefficient, when joined to many and/or large rooms.
+ for _, roomID := range joinedRoomIDs {
+ joinedUsers := p.notifier.JoinedUsers(roomID)
+ for _, sharedUser := range joinedUsers {
+ p.lazyLoadCache.InvalidateLazyLoadedUser(req.Device, roomID, sharedUser)
+ }
+ }
+
// Build up a /sync response. Add joined rooms.
var reqMutex sync.Mutex
var reqWaitGroup sync.WaitGroup
diff --git a/syncapi/streams/streams.go b/syncapi/streams/streams.go
index 1ca4ee8c..dbc053bd 100644
--- a/syncapi/streams/streams.go
+++ b/syncapi/streams/streams.go
@@ -34,6 +34,7 @@ func NewSyncStreamProviders(
StreamProvider: StreamProvider{DB: d},
lazyLoadCache: lazyLoadCache,
rsAPI: rsAPI,
+ notifier: notifier,
},
TypingStreamProvider: &TypingStreamProvider{
StreamProvider: StreamProvider{DB: d},