mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 03:13:11 -06:00
Fix sync position with partial info used as complete one in syncserver and notifier
Signed-off-by: Alex Chen <minecnly@gmail.com>
This commit is contained in:
parent
55219aa746
commit
2a9dab21f8
|
|
@ -331,7 +331,8 @@ func (d *SyncServerDatasource) IncrementalSync(
|
||||||
fromPos, toPos types.SyncPosition,
|
fromPos, toPos types.SyncPosition,
|
||||||
numRecentEventsPerRoom int,
|
numRecentEventsPerRoom int,
|
||||||
) (*types.Response, error) {
|
) (*types.Response, error) {
|
||||||
res := types.NewResponse(toPos)
|
nextBatchPos := fromPos.WithUpdates(toPos)
|
||||||
|
res := types.NewResponse(nextBatchPos)
|
||||||
|
|
||||||
var joinedRoomIDs []string
|
var joinedRoomIDs []string
|
||||||
var err error
|
var err error
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ func (n *Notifier) OnNewEvent(ev *gomatrixserverlib.Event, roomID string, userID
|
||||||
// This needs to be done PRIOR to waking up users as they will read this value.
|
// This needs to be done PRIOR to waking up users as they will read this value.
|
||||||
n.streamLock.Lock()
|
n.streamLock.Lock()
|
||||||
defer n.streamLock.Unlock()
|
defer n.streamLock.Unlock()
|
||||||
n.currPos = pos
|
n.currPos = n.currPos.WithUpdates(pos)
|
||||||
|
|
||||||
n.removeEmptyUserStreams()
|
n.removeEmptyUserStreams()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,19 @@ func (sp SyncPosition) IsAfter(other SyncPosition) bool {
|
||||||
sp.TypingPosition > other.TypingPosition
|
sp.TypingPosition > other.TypingPosition
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithUpdates returns a copy of sp with updates represented by other applied.
|
||||||
|
// If a fieldn is not 0 in other, it is considered an update.
|
||||||
|
func (sp SyncPosition) WithUpdates(other SyncPosition) SyncPosition {
|
||||||
|
ret := sp
|
||||||
|
if other.PDUPosition != 0 {
|
||||||
|
ret.PDUPosition = other.PDUPosition
|
||||||
|
}
|
||||||
|
if other.TypingPosition != 0 {
|
||||||
|
ret.TypingPosition = other.TypingPosition
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
// PrevEventRef represents a reference to a previous event in a state event upgrade
|
// PrevEventRef represents a reference to a previous event in a state event upgrade
|
||||||
type PrevEventRef struct {
|
type PrevEventRef struct {
|
||||||
PrevContent json.RawMessage `json:"prev_content"`
|
PrevContent json.RawMessage `json:"prev_content"`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue