From 30a0868789466012bab869af4300aef5a9cac108 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 30 May 2024 09:46:43 +0000 Subject: Rename legacy event types --- LibMatrix/RoomTypes/GenericRoom.cs | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'LibMatrix/RoomTypes/GenericRoom.cs') diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs index 3ef2395..8fa46d3 100644 --- a/LibMatrix/RoomTypes/GenericRoom.cs +++ b/LibMatrix/RoomTypes/GenericRoom.cs @@ -205,7 +205,7 @@ public class GenericRoom { Console.WriteLine("End of GetManyAsync"); } - public async Task GetNameAsync() => (await GetStateOrNullAsync("m.room.name"))?.Name; + public async Task GetNameAsync() => (await GetStateOrNullAsync("m.room.name"))?.Name; public async Task JoinAsync(string[]? homeservers = null, string? reason = null, bool checkIfAlreadyMember = true) { if (checkIfAlreadyMember) @@ -279,42 +279,42 @@ public class GenericRoom { #region Utility shortcuts - public Task SendMessageEventAsync(RoomMessageEventContent content) => + public Task SendMessageEventAsync(RoomMessageLegacyEventContent content) => SendTimelineEventAsync("m.room.message", content); public async Task?> GetAliasesAsync() { - var res = await GetStateAsync("m.room.aliases"); + var res = await GetStateAsync("m.room.aliases"); return res.Aliases; } - public Task GetCanonicalAliasAsync() => - GetStateAsync("m.room.canonical_alias"); + public Task GetCanonicalAliasAsync() => + GetStateAsync("m.room.canonical_alias"); - public Task GetTopicAsync() => - GetStateAsync("m.room.topic"); + public Task GetTopicAsync() => + GetStateAsync("m.room.topic"); - public Task GetAvatarUrlAsync() => - GetStateAsync("m.room.avatar"); + public Task GetAvatarUrlAsync() => + GetStateAsync("m.room.avatar"); - public Task GetJoinRuleAsync() => - GetStateAsync("m.room.join_rules"); + public Task GetJoinRuleAsync() => + GetStateAsync("m.room.join_rules"); - public Task GetHistoryVisibilityAsync() => - GetStateAsync("m.room.history_visibility"); + public Task GetHistoryVisibilityAsync() => + GetStateAsync("m.room.history_visibility"); - public Task GetGuestAccessAsync() => - GetStateAsync("m.room.guest_access"); + public Task GetGuestAccessAsync() => + GetStateAsync("m.room.guest_access"); - public Task GetCreateEventAsync() => - GetStateAsync("m.room.create"); + public Task GetCreateEventAsync() => + GetStateAsync("m.room.create"); public async Task GetRoomType() { - var res = await GetStateAsync("m.room.create"); + var res = await GetStateAsync("m.room.create"); return res.Type; } - public Task GetPowerLevelsAsync() => - GetStateAsync("m.room.power_levels"); + public Task GetPowerLevelsAsync() => + GetStateAsync("m.room.power_levels"); public async Task GetNameOrFallbackAsync(int maxMemberNames = 2) { try { @@ -393,7 +393,7 @@ public class GenericRoom { new UserIdAndReason { UserId = userId }); public async Task InviteUserAsync(string userId, string? reason = null, bool skipExisting = true) { - if (skipExisting && await GetStateAsync("m.room.member", userId) is not null) + if (skipExisting && await GetStateAsync("m.room.member", userId) is not null) return; await Homeserver.ClientHttpClient.PostAsJsonAsync($"/_matrix/client/v3/rooms/{RoomId}/invite", new UserIdAndReason(userId, reason)); } @@ -410,7 +410,7 @@ public class GenericRoom { await (await Homeserver.ClientHttpClient.PutAsJsonAsync($"/_matrix/client/v3/rooms/{RoomId}/state/{eventType}/{stateKey}", content)) .Content.ReadFromJsonAsync(); - public async Task SendTimelineEventAsync(string eventType, TimelineEventContent content) { + public async Task SendTimelineEventAsync(string eventType, TimelineLegacyEventContent content) { var res = await Homeserver.ClientHttpClient.PutAsJsonAsync( $"/_matrix/client/v3/rooms/{RoomId}/send/{eventType}/" + Guid.NewGuid(), content, new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull @@ -420,12 +420,12 @@ public class GenericRoom { public async Task SendFileAsync(string fileName, Stream fileStream, string messageType = "m.file", string contentType = "application/octet-stream") { var url = await Homeserver.UploadFile(fileName, fileStream); - var content = new RoomMessageEventContent() { + var content = new RoomMessageLegacyEventContent() { MessageType = messageType, Url = url, Body = fileName, FileName = fileName, - FileInfo = new RoomMessageEventContent.FileInfoStruct { + FileInfo = new RoomMessageLegacyEventContent.FileInfoStruct { Size = fileStream.Length, MimeType = contentType } -- cgit 1.4.1