diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-11 15:52:28 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-10-11 15:52:28 +0200 |
commit | a98f16f1aaa72aa68278420a61d8ce897639416f (patch) | |
tree | 959044674e30b9fe16dc909e8e44af1483c99bc8 /LibMatrix/Extensions | |
parent | Fix bug with event sending, make initial sync detection deterministic (diff) | |
download | LibMatrix-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 '')
-rw-r--r-- | LibMatrix/Extensions/HttpClientExtensions.cs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/LibMatrix/Extensions/HttpClientExtensions.cs b/LibMatrix/Extensions/HttpClientExtensions.cs index 6f1eab6..2faf0d5 100644 --- a/LibMatrix/Extensions/HttpClientExtensions.cs +++ b/LibMatrix/Extensions/HttpClientExtensions.cs @@ -98,4 +98,13 @@ public class MatrixHttpClient : HttpClient { Encoding.UTF8, "application/json"); return await SendAsync(request, cancellationToken); } + + public async Task<HttpResponseMessage> PostAsJsonAsync<T>([StringSyntax(StringSyntaxAttribute.Uri)] string? requestUri, T value, JsonSerializerOptions? options = null, + CancellationToken cancellationToken = default) { + var request = new HttpRequestMessage(HttpMethod.Post, requestUri); + request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + request.Content = new StringContent(JsonSerializer.Serialize(value, value.GetType(), options ?? new() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull }), + Encoding.UTF8, "application/json"); + return await SendAsync(request, cancellationToken); + } } |