From 013f1693885a5de01ae357af2909589e925863d5 Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 22 Aug 2025 17:36:27 +0200 Subject: Bulk sending, policy interpreting improvements, room upgrade builder work --- LibMatrix/RoomTypes/GenericRoom.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'LibMatrix/RoomTypes') diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs index 9753176..0077acb 100644 --- a/LibMatrix/RoomTypes/GenericRoom.cs +++ b/LibMatrix/RoomTypes/GenericRoom.cs @@ -623,10 +623,12 @@ public class GenericRoom { } } - public async Task BulkSendEventsAsync(IEnumerable events) { - if ((await Homeserver.GetCapabilitiesAsync()).Capabilities.BulkSendEvents?.Enabled == true) - await Homeserver.ClientHttpClient.PostAsJsonAsync( - $"/_matrix/client/unstable/gay.rory.bulk_send_events/rooms/{RoomId}/bulk_send_events?_libmatrix_txn_id={Guid.NewGuid()}", events); + public async Task BulkSendEventsAsync(IEnumerable events, int? forceSyncInterval = null) { + if ((await Homeserver.GetCapabilitiesAsync()).Capabilities.BulkSendEvents?.Enabled == true) { + var uri = $"/_matrix/client/unstable/gay.rory.bulk_send_events/rooms/{RoomId}/bulk_send_events?_libmatrix_txn_id={Guid.NewGuid()}"; + if (forceSyncInterval is not null) uri += $"&force_sync_interval={forceSyncInterval}"; + await Homeserver.ClientHttpClient.PostAsJsonAsync(uri, events); + } else { Console.WriteLine("Homeserver does not support bulk sending events, falling back to individual sends."); foreach (var evt in events) @@ -638,10 +640,12 @@ public class GenericRoom { } } - public async Task BulkSendEventsAsync(IAsyncEnumerable events) { - if ((await Homeserver.GetCapabilitiesAsync()).Capabilities.BulkSendEvents?.Enabled == true) - await Homeserver.ClientHttpClient.PostAsJsonAsync( - $"/_matrix/client/unstable/gay.rory.bulk_send_events/rooms/{RoomId}/bulk_send_events?_libmatrix_txn_id={Guid.NewGuid()}", events); + public async Task BulkSendEventsAsync(IAsyncEnumerable events, int? forceSyncInterval = null) { + if ((await Homeserver.GetCapabilitiesAsync()).Capabilities.BulkSendEvents?.Enabled == true) { + var uri = $"/_matrix/client/unstable/gay.rory.bulk_send_events/rooms/{RoomId}/bulk_send_events?_libmatrix_txn_id={Guid.NewGuid()}"; + if (forceSyncInterval is not null) uri += $"&force_sync_interval={forceSyncInterval}"; + await Homeserver.ClientHttpClient.PostAsJsonAsync(uri, events); + } else { Console.WriteLine("Homeserver does not support bulk sending events, falling back to individual sends."); await foreach (var evt in events) -- cgit 1.5.1