about summary refs log tree commit diff
path: root/MiniUtils/Services/IgnoreListManager.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-05-18 22:52:39 +0200
committerRory& <root@rory.gay>2025-05-18 22:52:39 +0200
commit82e5660b63ea6466e22f855fe524b288b62da7f9 (patch)
treeb9aa304da0002c2b85d4063a84f4d6e59e8f9008 /MiniUtils/Services/IgnoreListManager.cs
parentAdd more commands (diff)
downloadMiniUtils-master.tar.xz
More stuff HEAD master
Diffstat (limited to 'MiniUtils/Services/IgnoreListManager.cs')
-rw-r--r--MiniUtils/Services/IgnoreListManager.cs20
1 files changed, 20 insertions, 0 deletions
diff --git a/MiniUtils/Services/IgnoreListManager.cs b/MiniUtils/Services/IgnoreListManager.cs

index c42dd02..3b6dc96 100644 --- a/MiniUtils/Services/IgnoreListManager.cs +++ b/MiniUtils/Services/IgnoreListManager.cs
@@ -64,4 +64,24 @@ public class IgnoreListManager(AuthenticatedHomeserverGeneric homeserver) { Lock.Release(); return moved; } + + public async Task<int> AddList(string[] itemsToAdd) { + int added = 0; + await Lock.WaitAsync(); + var ignoreList = await homeserver.GetAccountDataOrNullAsync<IgnoredUserListEventContentWithDisabled>(IgnoredUserListEventContent.EventId) ?? new(); + foreach (var item in itemsToAdd) { + if (ignoreList.IgnoredUsers.ContainsKey(item)) continue; + if (ignoreList.DisabledIgnoredUsers.Remove(item, out var value)) { + ignoreList.IgnoredUsers.Add(item, value); + added++; + continue; + } + ignoreList.IgnoredUsers.Add(item, new()); + added++; + } + if (added > 0) + await homeserver.SetAccountDataAsync(IgnoredUserListEventContent.EventId, ignoreList); + Lock.Release(); + return added; + } } \ No newline at end of file