mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 19:51:39 +00:00
Don't send account data or receipts for left/forgotten rooms (#2382)
* Only include account data and receipts for rooms in a complete sync that we care about * Fix global account data
This commit is contained in:
parent
66b397b3c6
commit
dca4afd2f0
@ -53,6 +53,12 @@ func (p *AccountDataStreamProvider) IncrementalSync(
|
|||||||
|
|
||||||
// Iterate over the rooms
|
// Iterate over the rooms
|
||||||
for roomID, dataTypes := range dataTypes {
|
for roomID, dataTypes := range dataTypes {
|
||||||
|
// For a complete sync, make sure we're only including this room if
|
||||||
|
// that room was present in the joined rooms.
|
||||||
|
if from == 0 && roomID != "" && !req.IsRoomPresent(roomID) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Request the missing data from the database
|
// Request the missing data from the database
|
||||||
for _, dataType := range dataTypes {
|
for _, dataType := range dataTypes {
|
||||||
dataReq := userapi.QueryAccountDataRequest{
|
dataReq := userapi.QueryAccountDataRequest{
|
||||||
|
@ -62,6 +62,12 @@ func (p *ReceiptStreamProvider) IncrementalSync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for roomID, receipts := range receiptsByRoom {
|
for roomID, receipts := range receiptsByRoom {
|
||||||
|
// For a complete sync, make sure we're only including this room if
|
||||||
|
// that room was present in the joined rooms.
|
||||||
|
if from == 0 && !req.IsRoomPresent(roomID) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
jr := *types.NewJoinResponse()
|
jr := *types.NewJoinResponse()
|
||||||
if existing, ok := req.Response.Rooms.Join[roomID]; ok {
|
if existing, ok := req.Response.Rooms.Join[roomID]; ok {
|
||||||
jr = existing
|
jr = existing
|
||||||
|
@ -25,6 +25,23 @@ type SyncRequest struct {
|
|||||||
IgnoredUsers IgnoredUsers
|
IgnoredUsers IgnoredUsers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *SyncRequest) IsRoomPresent(roomID string) bool {
|
||||||
|
membership, ok := r.Rooms[roomID]
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
switch membership {
|
||||||
|
case gomatrixserverlib.Join:
|
||||||
|
return true
|
||||||
|
case gomatrixserverlib.Invite:
|
||||||
|
return true
|
||||||
|
case gomatrixserverlib.Peek:
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type StreamProvider interface {
|
type StreamProvider interface {
|
||||||
Setup()
|
Setup()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user