mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-29 08:18:27 +00:00
Merge branch 'master' into babolivier/cs-messages
This commit is contained in:
commit
77dc37ce6f
1 changed files with 15 additions and 0 deletions
|
@ -329,6 +329,11 @@ func (d *SyncServerDatabase) CompleteSync(
|
||||||
recentEvents := StreamEventsToEvents(nil, recentStreamEvents)
|
recentEvents := StreamEventsToEvents(nil, recentStreamEvents)
|
||||||
stateEvents = removeDuplicates(stateEvents, recentEvents)
|
stateEvents = removeDuplicates(stateEvents, recentEvents)
|
||||||
jr := types.NewJoinResponse()
|
jr := types.NewJoinResponse()
|
||||||
|
if prevBatch := recentStreamEvents[0].streamPosition - 1; prevBatch > 0 {
|
||||||
|
jr.Timeline.PrevBatch = types.StreamPosition(prevBatch).String()
|
||||||
|
} else {
|
||||||
|
jr.Timeline.PrevBatch = types.StreamPosition(1).String()
|
||||||
|
}
|
||||||
jr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync)
|
jr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync)
|
||||||
jr.Timeline.Limited = true
|
jr.Timeline.Limited = true
|
||||||
jr.State.Events = gomatrixserverlib.ToClientEvents(stateEvents, gomatrixserverlib.FormatSync)
|
jr.State.Events = gomatrixserverlib.ToClientEvents(stateEvents, gomatrixserverlib.FormatSync)
|
||||||
|
@ -458,6 +463,11 @@ func (d *SyncServerDatabase) addRoomDeltaToResponse(
|
||||||
switch delta.membership {
|
switch delta.membership {
|
||||||
case "join":
|
case "join":
|
||||||
jr := types.NewJoinResponse()
|
jr := types.NewJoinResponse()
|
||||||
|
if prevBatch := recentStreamEvents[0].streamPosition - 1; prevBatch > 0 {
|
||||||
|
jr.Timeline.PrevBatch = types.StreamPosition(prevBatch).String()
|
||||||
|
} else {
|
||||||
|
jr.Timeline.PrevBatch = types.StreamPosition(1).String()
|
||||||
|
}
|
||||||
jr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync)
|
jr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync)
|
||||||
jr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true
|
jr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true
|
||||||
jr.State.Events = gomatrixserverlib.ToClientEvents(delta.stateEvents, gomatrixserverlib.FormatSync)
|
jr.State.Events = gomatrixserverlib.ToClientEvents(delta.stateEvents, gomatrixserverlib.FormatSync)
|
||||||
|
@ -468,6 +478,11 @@ func (d *SyncServerDatabase) addRoomDeltaToResponse(
|
||||||
// TODO: recentEvents may contain events that this user is not allowed to see because they are
|
// TODO: recentEvents may contain events that this user is not allowed to see because they are
|
||||||
// no longer in the room.
|
// no longer in the room.
|
||||||
lr := types.NewLeaveResponse()
|
lr := types.NewLeaveResponse()
|
||||||
|
if prevBatch := recentStreamEvents[0].streamPosition - 1; prevBatch > 0 {
|
||||||
|
lr.Timeline.PrevBatch = types.StreamPosition(prevBatch).String()
|
||||||
|
} else {
|
||||||
|
lr.Timeline.PrevBatch = types.StreamPosition(1).String()
|
||||||
|
}
|
||||||
lr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync)
|
lr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync)
|
||||||
lr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true
|
lr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true
|
||||||
lr.State.Events = gomatrixserverlib.ToClientEvents(delta.stateEvents, gomatrixserverlib.FormatSync)
|
lr.State.Events = gomatrixserverlib.ToClientEvents(delta.stateEvents, gomatrixserverlib.FormatSync)
|
||||||
|
|
Loading…
Reference in a new issue