diff options
Diffstat (limited to 'LibMatrix/Responses/SyncResponse.cs')
-rw-r--r-- | LibMatrix/Responses/SyncResponse.cs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/LibMatrix/Responses/SyncResponse.cs b/LibMatrix/Responses/SyncResponse.cs index d807ecb..2d3d3f8 100644 --- a/LibMatrix/Responses/SyncResponse.cs +++ b/LibMatrix/Responses/SyncResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using LibMatrix.EventTypes.Spec.Ephemeral; using LibMatrix.EventTypes.Spec.State; namespace LibMatrix.Responses; @@ -60,10 +61,9 @@ public class SyncResponse { public EventList? State { get; set; } public override string ToString() { - var lastEvent = Timeline?.Events?.LastOrDefault(x=>x.Type == "m.room.member"); + var lastEvent = Timeline?.Events?.LastOrDefault(x => x.Type == "m.room.member"); var membership = (lastEvent?.TypedContent as RoomMemberEventContent); return $"LeftRoomDataStructure: {lastEvent?.Sender} {membership?.Membership} ({membership?.Reason})"; - } } @@ -129,4 +129,15 @@ public class SyncResponse { public EventList? InviteState { get; set; } } } + + public long GetDerivedSyncTime() { + return ((long[]) [ + AccountData?.Events?.Max(x => x.OriginServerTs) ?? 0, + Presence?.Events?.Max(x => x.OriginServerTs) ?? 0, + ToDevice?.Events?.Max(x => x.OriginServerTs) ?? 0, + Rooms?.Join?.Values?.Max(x => x.Timeline?.Events?.Max(y => y.OriginServerTs)) ?? 0, + Rooms?.Invite?.Values?.Max(x => x.InviteState?.Events?.Max(y => y.OriginServerTs)) ?? 0, + Rooms?.Leave?.Values?.Max(x => x.Timeline?.Events?.Max(y => y.OriginServerTs)) ?? 0 + ]).Max(); + } } \ No newline at end of file |