about summary refs log tree commit diff
path: root/LibMatrix/RoomTypes
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-11 15:52:28 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-11 15:52:28 +0200
commita98f16f1aaa72aa68278420a61d8ce897639416f (patch)
tree959044674e30b9fe16dc909e8e44af1483c99bc8 /LibMatrix/RoomTypes
parentFix bug with event sending, make initial sync detection deterministic (diff)
downloadLibMatrix-a98f16f1aaa72aa68278420a61d8ce897639416f.tar.xz
Added options to skip inviting already invited/joined/left users, added option to join room if it already exists when trying to create
Diffstat (limited to 'LibMatrix/RoomTypes')
-rw-r--r--LibMatrix/RoomTypes/GenericRoom.cs8
1 files changed, 5 insertions, 3 deletions
diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs
index 37006af..1c0633c 100644
--- a/LibMatrix/RoomTypes/GenericRoom.cs
+++ b/LibMatrix/RoomTypes/GenericRoom.cs
@@ -232,7 +232,9 @@ public class GenericRoom {
             $"/_matrix/client/v3/rooms/{RoomId}/redact/{eventToRedact}/{Guid.NewGuid()}", data)).Content.ReadFromJsonAsync<EventIdResponse>())!;
     }
 
-    public async Task InviteUserAsync(string userId, string? reason = null) {
+    public async Task InviteUserAsync(string userId, string? reason = null, bool skipExisting = true) {
+        if (skipExisting && await GetStateAsync<RoomMemberEventContent>("m.room.member", userId) is not null)
+            return;
         await _httpClient.PostAsJsonAsync($"/_matrix/client/v3/rooms/{RoomId}/invite", new UserIdAndReason(userId, reason));
     }
 
@@ -265,8 +267,8 @@ public class GenericRoom {
 
 #endregion
 
-    public async Task InviteUsersAsync(IEnumerable<string> users) {
-        var tasks = users.Select(x=>InviteUserAsync(x)).ToList();
+    public async Task InviteUsersAsync(IEnumerable<string> users, string? reason = null, bool skipExisting = true) {
+        var tasks = users.Select(x => InviteUserAsync(x, reason, skipExisting)).ToList();
         await Task.WhenAll(tasks);
     }
 }