mirror of
https://github.com/signaller-matrix/signaller.git
synced 2024-11-09 12:11:03 +00:00
[WIP] fix: Add check to empty since token (/sync)
This commit is contained in:
parent
b911c7e351
commit
53372cc1c1
@ -355,14 +355,20 @@ func (user *User) GetFilterByID(filterID string) *common.Filter {
|
|||||||
|
|
||||||
func (user *User) Sync(token string, request mSync.SyncRequest) (response *mSync.SyncReply, err models.ApiError) {
|
func (user *User) Sync(token string, request mSync.SyncRequest) (response *mSync.SyncReply, err models.ApiError) {
|
||||||
response = mSync.BuildEmptySyncReply()
|
response = mSync.BuildEmptySyncReply()
|
||||||
|
emptyEventList := true
|
||||||
|
emptySinceToken := true
|
||||||
|
var eventsList []events.Event
|
||||||
|
|
||||||
eventsList := user.backend.GetEventsSince(user, request.Since, 0) // TODO filtering
|
if request.Since != "" {
|
||||||
var eventListEmpty bool
|
emptySinceToken = false
|
||||||
if len(eventsList) != 0 {
|
eventsList := user.backend.GetEventsSince(user, request.Since, 0) // TODO filtering
|
||||||
eventListEmpty = false
|
|
||||||
|
if len(eventsList) != 0 {
|
||||||
|
emptyEventList = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !eventListEmpty {
|
if !emptyEventList {
|
||||||
for _, room := range user.JoinedRooms() {
|
for _, room := range user.JoinedRooms() {
|
||||||
filteredEventList := filterEventsByRoom(room.ID(), eventsList)
|
filteredEventList := filterEventsByRoom(room.ID(), eventsList)
|
||||||
var prevBatch string
|
var prevBatch string
|
||||||
@ -386,6 +392,8 @@ func (user *User) Sync(token string, request mSync.SyncRequest) (response *mSync
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
response.NextBatch = eventsList[len(eventsList)-1].ID()
|
response.NextBatch = eventsList[len(eventsList)-1].ID()
|
||||||
|
} else if emptySinceToken {
|
||||||
|
// TODO
|
||||||
} else {
|
} else {
|
||||||
// TODO wait for new events or just return empty response when timeout is reached
|
// TODO wait for new events or just return empty response when timeout is reached
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user