about summary refs log tree commit diff
path: root/Tests/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs')
-rw-r--r--Tests/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs8
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