diff options
Diffstat (limited to 'Tests/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs')
-rw-r--r-- | Tests/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Tests/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs b/Tests/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs index 1d03d7a..d938b1b 100644 --- a/Tests/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs +++ b/Tests/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs @@ -14,5 +14,11 @@ public static class EventExtensions { OriginServerTs = DateTimeOffset.Now.ToUnixTimeMilliseconds() }; } - + + public static List<StateEventResponse> GetCalculatedState(this IEnumerable<StateEventResponse> events) { + return events.Where(s => s.StateKey != null) + .OrderByDescending(s => s.OriginServerTs) + .DistinctBy(x => (x.Type, x.StateKey)) + .ToList(); + } } \ No newline at end of file |