mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 23:48:27 +00:00
Tidy filterStreamEventsAccordingToHistoryVisibility
This commit is contained in:
parent
2322d8f027
commit
be9ee18233
1 changed files with 1 additions and 31 deletions
|
@ -2,13 +2,10 @@ package streams
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/syncapi/types"
|
"github.com/matrix-org/dendrite/syncapi/types"
|
||||||
userapi "github.com/matrix-org/dendrite/userapi/api"
|
userapi "github.com/matrix-org/dendrite/userapi/api"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PDUStreamProvider struct {
|
type PDUStreamProvider struct {
|
||||||
|
@ -387,34 +384,7 @@ func (p *PDUStreamProvider) filterStreamEventsAccordingToHistoryVisibility(
|
||||||
sliceEnd = leaveEventIndex
|
sliceEnd = leaveEventIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
type somematrixevent struct {
|
return recentStreamEvents[sliceStart:sliceEnd], limited
|
||||||
event_id, sender, eventType, origin_server_ts, content string
|
|
||||||
}
|
|
||||||
|
|
||||||
events := make([]somematrixevent, len(recentStreamEvents))
|
|
||||||
for i, v := range recentStreamEvents {
|
|
||||||
events[i] = somematrixevent{
|
|
||||||
event_id: v.HeaderedEvent.Event.EventID(),
|
|
||||||
sender: v.HeaderedEvent.Event.Sender(),
|
|
||||||
eventType: v.HeaderedEvent.Event.Type(),
|
|
||||||
origin_server_ts: strconv.FormatUint(uint64(v.HeaderedEvent.Event.OriginServerTS()), 10),
|
|
||||||
content: string(v.HeaderedEvent.Event.Content()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logrus.WithFields(logrus.Fields{
|
|
||||||
"sliceStart": sliceStart,
|
|
||||||
"sliceEnd": sliceEnd,
|
|
||||||
"recentStreamEvents": fmt.Sprintf("%+v", events),
|
|
||||||
}).Info("cutting down the events")
|
|
||||||
|
|
||||||
outEvents := recentStreamEvents[sliceStart:sliceEnd]
|
|
||||||
|
|
||||||
logrus.WithFields(logrus.Fields{
|
|
||||||
"recentStreamEvents": fmt.Sprintf("%+v", events[sliceStart:sliceEnd]),
|
|
||||||
}).Info("cutting down the events after")
|
|
||||||
|
|
||||||
return outEvents, limited
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeDuplicates(stateEvents, recentEvents []*gomatrixserverlib.HeaderedEvent) []*gomatrixserverlib.HeaderedEvent {
|
func removeDuplicates(stateEvents, recentEvents []*gomatrixserverlib.HeaderedEvent) []*gomatrixserverlib.HeaderedEvent {
|
||||||
|
|
Loading…
Reference in a new issue