about summary refs log tree commit diff
path: root/Tests/LibMatrix.HomeserverEmulator/Services/PaginationTokenResolverService.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-09-17 04:26:25 +0200
committerRory& <root@rory.gay>2024-09-17 04:26:25 +0200
commit37a8ac420278fd53ab8218956f1ba13692feb48e (patch)
tree83afec51130a254f6ed0ba11c45975f3f2ba8b9f /Tests/LibMatrix.HomeserverEmulator/Services/PaginationTokenResolverService.cs
parentDrop example bots (diff)
parentMove around some projects, further cleanup pending (diff)
downloadLibMatrix-bak-37a8ac420278fd53ab8218956f1ba13692feb48e.tar.xz
Merge remote-tracking branch 'origin/dev/project-cleanup'
Diffstat (limited to 'Tests/LibMatrix.HomeserverEmulator/Services/PaginationTokenResolverService.cs')
-rw-r--r--Tests/LibMatrix.HomeserverEmulator/Services/PaginationTokenResolverService.cs54
1 files changed, 0 insertions, 54 deletions
diff --git a/Tests/LibMatrix.HomeserverEmulator/Services/PaginationTokenResolverService.cs b/Tests/LibMatrix.HomeserverEmulator/Services/PaginationTokenResolverService.cs
deleted file mode 100644

index 0128ba6..0000000 --- a/Tests/LibMatrix.HomeserverEmulator/Services/PaginationTokenResolverService.cs +++ /dev/null
@@ -1,54 +0,0 @@ -namespace LibMatrix.HomeserverEmulator.Services; - -public class PaginationTokenResolverService(ILogger<PaginationTokenResolverService> logger, RoomStore roomStore, UserStore userStore) { - public async Task<long?> ResolveTokenToTimestamp(string token) { - logger.LogTrace("ResolveTokenToTimestamp({token})", token); - if (token.StartsWith('$')) { - //we have an event ID - foreach (var room in roomStore._rooms) { - var evt = await ResolveTokenToEvent(token, room); - if (evt is not null) return evt.OriginServerTs; - } - - // event not found - throw new NotImplementedException(); - } - else { - // we have a sync token - foreach (var user in userStore._users) { - foreach (var (_, session) in user.AccessTokens) { - if (!session.SyncStates.TryGetValue(token, out var syncState)) continue; - long? maxTs = 0; - foreach (var room in syncState.RoomPositions) { - var roomObj = roomStore.GetRoomById(room.Key); - if (roomObj is null) - continue; - var ts = roomObj.Timeline.Last().OriginServerTs; - if (ts > maxTs) maxTs = ts; - } - - return maxTs; - } - } - - throw new NotImplementedException(); - } - } - - public async Task<StateEventResponse?> ResolveTokenToEvent(string token, RoomStore.Room room) { - if (token.StartsWith('$')) { - //we have an event ID - logger.LogTrace("ResolveTokenToEvent(EventId({token}), Room({room})): searching for event...", token, room.RoomId); - - var evt = room.Timeline.SingleOrDefault(x => x.EventId == token); - if (evt is not null) return evt; - logger.LogTrace("ResolveTokenToEvent({token}, Room({room})): event not in requested room...", token, room.RoomId); - return null; - } - else { - // we have a sync token - logger.LogTrace("ResolveTokenToEvent(SyncToken({token}), Room({room}))", token, room.RoomId); - throw new NotImplementedException(); - } - } -} \ No newline at end of file