diff --git a/LibMatrix/Extensions/EnumerableExtensions.cs b/LibMatrix/Extensions/EnumerableExtensions.cs
index 4dcf26e..88e79f0 100644
--- a/LibMatrix/Extensions/EnumerableExtensions.cs
+++ b/LibMatrix/Extensions/EnumerableExtensions.cs
@@ -4,7 +4,7 @@ using System.Collections.Immutable;
namespace LibMatrix.Extensions;
public static class EnumerableExtensions {
- public static void MergeStateEventLists(this IList<StateEvent> oldState, IList<StateEvent> newState) {
+ public static void MergeStateEventLists(this IList<MatrixEvent> oldState, IList<MatrixEvent> newState) {
// foreach (var stateEvent in newState) {
// var old = oldState.FirstOrDefault(x => x.Type == stateEvent.Type && x.StateKey == stateEvent.StateKey);
// if (old is null) {
@@ -27,7 +27,7 @@ public static class EnumerableExtensions {
}
}
- int FindIndex(StateEvent needle) {
+ int FindIndex(MatrixEvent needle) {
for (int i = 0; i < oldState.Count; i++) {
var old = oldState[i];
if (old.Type == needle.Type && old.StateKey == needle.StateKey)
@@ -38,7 +38,7 @@ public static class EnumerableExtensions {
}
}
- public static void MergeStateEventLists(this IList<StateEventResponse> oldState, IList<StateEventResponse> newState) {
+ public static void MergeStateEventLists(this IList<MatrixEventResponse> oldState, IList<MatrixEventResponse> newState) {
foreach (var e in newState) {
switch (FindIndex(e)) {
case -1:
@@ -50,7 +50,7 @@ public static class EnumerableExtensions {
}
}
- int FindIndex(StateEventResponse needle) {
+ int FindIndex(MatrixEventResponse needle) {
for (int i = 0; i < oldState.Count; i++) {
var old = oldState[i];
if (old.Type == needle.Type && old.StateKey == needle.StateKey)
@@ -61,7 +61,7 @@ public static class EnumerableExtensions {
}
}
- public static void MergeStateEventLists(this List<StateEventResponse> oldState, List<StateEventResponse> newState) {
+ public static void MergeStateEventLists(this List<MatrixEventResponse> oldState, List<MatrixEventResponse> newState) {
foreach (var e in newState) {
switch (FindIndex(e)) {
case -1:
@@ -73,7 +73,7 @@ public static class EnumerableExtensions {
}
}
- int FindIndex(StateEventResponse needle) {
+ int FindIndex(MatrixEventResponse needle) {
for (int i = 0; i < oldState.Count; i++) {
var old = oldState[i];
if (old.Type == needle.Type && old.StateKey == needle.StateKey)
diff --git a/LibMatrix/Extensions/JsonElementExtensions.cs b/LibMatrix/Extensions/JsonElementExtensions.cs
index dfec95b..9225f58 100644
--- a/LibMatrix/Extensions/JsonElementExtensions.cs
+++ b/LibMatrix/Extensions/JsonElementExtensions.cs
@@ -8,7 +8,7 @@ namespace LibMatrix.Extensions;
public static class JsonElementExtensions {
public static bool FindExtraJsonElementFields(this JsonElement obj, Type objectType, string objectPropertyName) {
if (objectPropertyName == "content" && objectType == typeof(JsonObject))
- objectType = typeof(StateEventResponse);
+ objectType = typeof(MatrixEventResponse);
// if (t == typeof(JsonNode))
// return false;
@@ -35,9 +35,9 @@ public static class JsonElementExtensions {
continue;
}
- if (field.Name == "content" && (objectType == typeof(StateEventResponse) || objectType == typeof(StateEvent))) {
+ if (field.Name == "content" && (objectType == typeof(MatrixEventResponse) || objectType == typeof(MatrixEvent))) {
unknownPropertyFound |= field.FindExtraJsonPropertyFieldsByValueKind(
- StateEvent.GetStateEventType(obj.GetProperty("type").GetString()!), // We expect type to always be present
+ MatrixEvent.GetEventType(obj.GetProperty("type").GetString()!), // We expect type to always be present
mappedProperty.PropertyType);
continue;
}
diff --git a/LibMatrix/Helpers/RoomBuilder.cs b/LibMatrix/Helpers/RoomBuilder.cs
index 6e24103..a292f33 100644
--- a/LibMatrix/Helpers/RoomBuilder.cs
+++ b/LibMatrix/Helpers/RoomBuilder.cs
@@ -44,12 +44,12 @@ public class RoomBuilder {
/// <summary>
/// State events to be sent *before* room access is configured. Keep this small!
/// </summary>
- public List<StateEvent> ImportantState { get; set; } = [];
+ public List<MatrixEvent> ImportantState { get; set; } = [];
/// <summary>
/// State events to be sent *after* room access is configured, but before invites are sent.
/// </summary>
- public List<StateEvent> InitialState { get; set; } = [];
+ public List<MatrixEvent> InitialState { get; set; } = [];
/// <summary>
/// Users to invite, with optional reason
@@ -86,7 +86,7 @@ public class RoomBuilder {
{ RoomPolicyServerEventContent.EventId, 100 },
{ RoomPinnedEventContent.EventId, 50 },
// recommended extensions
- { "im.vector.modular.widgets", 50},
+ { "im.vector.modular.widgets", 50 },
// { "m.reaction", 0 }, // we probably don't want these to end up as room state
// - prevent calls
{ "io.element.voice_broadcast_info", 50 },
@@ -197,7 +197,7 @@ public class RoomBuilder {
await Task.WhenAll(inviteTasks);
}
- private async Task SetStatesAsync(GenericRoom room, List<StateEvent> state) {
+ private async Task SetStatesAsync(GenericRoom room, List<MatrixEvent> state) {
if (state.Count == 0) return;
await room.BulkSendEventsAsync(state);
// We chunk this up to try to avoid hitting reverse proxy timeouts
diff --git a/LibMatrix/Helpers/RoomUpgradeBuilder.cs b/LibMatrix/Helpers/RoomUpgradeBuilder.cs
index 85a5e36..ced0ef3 100644
--- a/LibMatrix/Helpers/RoomUpgradeBuilder.cs
+++ b/LibMatrix/Helpers/RoomUpgradeBuilder.cs
@@ -107,7 +107,7 @@ public class RoomUpgradeBuilder : RoomBuilder {
Console.WriteLine($"Imported {total} state events from old room {OldRoom.RoomId} in {sw.ElapsedMilliseconds}ms");
}
- private StateEventResponse UpgradeUnstableValues(StateEventResponse evt) {
+ private MatrixEventResponse UpgradeUnstableValues(MatrixEventResponse evt) {
if (evt.IsLegacyType) {
var oldType = evt.Type;
evt.Type = evt.MappedType.GetCustomAttributes<MatrixEventAttribute>().FirstOrDefault(x => !x.Legacy)!.EventName;
@@ -124,7 +124,7 @@ public class RoomUpgradeBuilder : RoomBuilder {
return evt;
}
- private void ImportPolicyEventAsync(StateEventResponse evt) {
+ private void ImportPolicyEventAsync(MatrixEventResponse evt) {
var msc4321Options = UpgradeOptions.Msc4321PolicyListUpgradeOptions;
if (msc4321Options is { Enable: true, UpgradeType: Msc4321PolicyListUpgradeOptions.Msc4321PolicyListUpgradeType.Transition })
return; // this upgrade type doesnt copy policies
diff --git a/LibMatrix/Helpers/SyncHelper.cs b/LibMatrix/Helpers/SyncHelper.cs
index c8e2928..ebe653c 100644
--- a/LibMatrix/Helpers/SyncHelper.cs
+++ b/LibMatrix/Helpers/SyncHelper.cs
@@ -298,9 +298,9 @@ public class SyncHelper(AuthenticatedHomeserverGeneric homeserver, ILogger? logg
if (syncResponse.Rooms is { Join.Count: > 0 })
foreach (var updatedRoom in syncResponse.Rooms.Join) {
if (updatedRoom.Value.Timeline is null) continue;
- foreach (var stateEventResponse in updatedRoom.Value.Timeline.Events ?? []) {
- stateEventResponse.RoomId = updatedRoom.Key;
- var tasks = TimelineEventHandlers.Select(x => x(stateEventResponse)).ToList();
+ foreach (var MatrixEventResponse in updatedRoom.Value.Timeline.Events ?? []) {
+ MatrixEventResponse.RoomId = updatedRoom.Key;
+ var tasks = TimelineEventHandlers.Select(x => x(MatrixEventResponse)).ToList();
await Task.WhenAll(tasks);
}
}
@@ -319,12 +319,12 @@ public class SyncHelper(AuthenticatedHomeserverGeneric homeserver, ILogger? logg
/// <summary>
/// Event fired when a timeline event is received
/// </summary>
- public List<Func<StateEventResponse, Task>> TimelineEventHandlers { get; } = new();
+ public List<Func<MatrixEventResponse, Task>> TimelineEventHandlers { get; } = new();
/// <summary>
/// Event fired when an account data event is received
/// </summary>
- public List<Func<StateEventResponse, Task>> AccountDataReceivedHandlers { get; } = new();
+ public List<Func<MatrixEventResponse, Task>> AccountDataReceivedHandlers { get; } = new();
/// <summary>
/// Event fired when an exception is thrown
diff --git a/LibMatrix/Helpers/SyncProcessors/Msc4222EmulationSyncProcessor.cs b/LibMatrix/Helpers/SyncProcessors/Msc4222EmulationSyncProcessor.cs
index be8aa8d..c887f6e 100644
--- a/LibMatrix/Helpers/SyncProcessors/Msc4222EmulationSyncProcessor.cs
+++ b/LibMatrix/Helpers/SyncProcessors/Msc4222EmulationSyncProcessor.cs
@@ -8,11 +8,11 @@ using Microsoft.Extensions.Logging;
namespace LibMatrix.Helpers.SyncProcessors;
public class Msc4222EmulationSyncProcessor(AuthenticatedHomeserverGeneric homeserver, ILogger? logger) {
- private static bool StateEventsMatch(StateEventResponse a, StateEventResponse b) {
+ private static bool StateEventsMatch(MatrixEventResponse a, MatrixEventResponse b) {
return a.Type == b.Type && a.StateKey == b.StateKey;
}
- private static bool StateEventIsNewer(StateEventResponse a, StateEventResponse b) {
+ private static bool StateEventIsNewer(MatrixEventResponse a, MatrixEventResponse b) {
return StateEventsMatch(a, b) && a.OriginServerTs < b.OriginServerTs;
}
@@ -76,7 +76,7 @@ public class Msc4222EmulationSyncProcessor(AuthenticatedHomeserverGeneric homese
Events = []
};
- var oldState = new List<StateEventResponse>();
+ var oldState = new List<MatrixEventResponse>();
if (data.State is { Events.Count: > 0 }) {
oldState.ReplaceBy(data.State.Events, StateEventIsNewer);
}
@@ -160,7 +160,7 @@ public class Msc4222EmulationSyncProcessor(AuthenticatedHomeserverGeneric homese
logger?.LogWarning("Msc4222Emulation: Failed to get full state for room {roomId}, state may be incomplete!\n{exception}", roomId, e);
}
- var oldState = new List<StateEventResponse>();
+ var oldState = new List<MatrixEventResponse>();
if (data.State is { Events.Count: > 0 }) {
oldState.ReplaceBy(data.State.Events, StateEventIsNewer);
}
diff --git a/LibMatrix/Helpers/SyncStateResolver.cs b/LibMatrix/Helpers/SyncStateResolver.cs
index f111c79..17c1a41 100644
--- a/LibMatrix/Helpers/SyncStateResolver.cs
+++ b/LibMatrix/Helpers/SyncStateResolver.cs
@@ -625,7 +625,7 @@ public class SyncStateResolver(AuthenticatedHomeserverGeneric homeserver, ILogge
return oldState;
}
- private static EventList? MergeEventListBy(EventList? oldState, EventList? newState, Func<StateEventResponse, StateEventResponse, bool> comparer) {
+ private static EventList? MergeEventListBy(EventList? oldState, EventList? newState, Func<MatrixEventResponse, MatrixEventResponse, bool> comparer) {
if (newState is null) return oldState;
if (oldState is null) {
return newState;
diff --git a/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/EventReportListResult.cs b/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/EventReportListResult.cs
index 10fc039..0f3ee56 100644
--- a/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/EventReportListResult.cs
+++ b/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/EventReportListResult.cs
@@ -97,10 +97,10 @@ public class SynapseAdminEventReportListResult : SynapseNextTokenTotalCollection
[JsonPropertyName("unsigned")]
public JsonObject? Unsigned { get; set; }
- // Extra... copied from StateEventResponse
+ // Extra... copied from MatrixEventResponse
[JsonIgnore]
- public Type MappedType => StateEvent.GetStateEventType(Type);
+ public Type MappedType => MatrixEvent.GetEventType(Type);
[JsonIgnore]
public bool IsLegacyType => MappedType.GetCustomAttributes<MatrixEventAttribute>().FirstOrDefault(x => x.EventName == Type)?.Legacy ?? false;
@@ -128,7 +128,7 @@ public class SynapseAdminEventReportListResult : SynapseNextTokenTotalCollection
// return null;
// }
try {
- var mappedType = StateEvent.GetStateEventType(Type);
+ var mappedType = MatrixEvent.GetEventType(Type);
if (mappedType == typeof(UnknownEventContent))
Console.WriteLine($"Warning: unknown event type '{Type}'");
var deserialisedContent = (EventContent)RawContent.Deserialize(mappedType, TypedContentSerializerOptions)!;
diff --git a/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/RoomListResult.cs b/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/RoomListResult.cs
index 3bc1f47..7006c07 100644
--- a/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/RoomListResult.cs
+++ b/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/RoomListResult.cs
@@ -63,15 +63,15 @@ public class SynapseAdminRoomListResult {
public int StateEvents { get; set; }
[JsonPropertyName("gay.rory.synapse_admin_extensions.tombstone")]
- public StateEventResponse? TombstoneEvent { get; set; }
+ public MatrixEventResponse? TombstoneEvent { get; set; }
[JsonPropertyName("gay.rory.synapse_admin_extensions.create")]
- public StateEventResponse? CreateEvent { get; set; }
+ public MatrixEventResponse? CreateEvent { get; set; }
[JsonPropertyName("gay.rory.synapse_admin_extensions.topic")]
- public StateEventResponse? TopicEvent { get; set; }
+ public MatrixEventResponse? TopicEvent { get; set; }
- public async Task<StateEventResponse?> GetCreateEventAsync(AuthenticatedHomeserverSynapse hs) {
+ public async Task<MatrixEventResponse?> GetCreateEventAsync(AuthenticatedHomeserverSynapse hs) {
if (CreateEvent != null) return CreateEvent;
try {
@@ -85,7 +85,7 @@ public class SynapseAdminRoomListResult {
return null;
}
- public async Task<StateEventResponse?> GetTombstoneEventAsync(AuthenticatedHomeserverSynapse hs) {
+ public async Task<MatrixEventResponse?> GetTombstoneEventAsync(AuthenticatedHomeserverSynapse hs) {
if (TombstoneEvent != null) return TombstoneEvent;
try {
@@ -99,7 +99,7 @@ public class SynapseAdminRoomListResult {
return null;
}
- public async Task<StateEventResponse?> GetTopicEventAsync(AuthenticatedHomeserverSynapse hs) {
+ public async Task<MatrixEventResponse?> GetTopicEventAsync(AuthenticatedHomeserverSynapse hs) {
if (TopicEvent != null) return TopicEvent;
try {
diff --git a/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/SynapseAdminRoomStateResult.cs b/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/SynapseAdminRoomStateResult.cs
index ae36d4e..d9d5f1a 100644
--- a/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/SynapseAdminRoomStateResult.cs
+++ b/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/SynapseAdminRoomStateResult.cs
@@ -4,5 +4,5 @@ namespace LibMatrix.Homeservers.ImplementationDetails.Synapse.Models.Responses;
public class SynapseAdminRoomStateResult {
[JsonPropertyName("state")]
- public required List<StateEventResponse> Events { get; set; }
+ public required List<MatrixEventResponse> Events { get; set; }
}
\ No newline at end of file
diff --git a/LibMatrix/Homeservers/ImplementationDetails/Synapse/SynapseAdminApiClient.cs b/LibMatrix/Homeservers/ImplementationDetails/Synapse/SynapseAdminApiClient.cs
index 6d09006..f839e20 100644
--- a/LibMatrix/Homeservers/ImplementationDetails/Synapse/SynapseAdminApiClient.cs
+++ b/LibMatrix/Homeservers/ImplementationDetails/Synapse/SynapseAdminApiClient.cs
@@ -174,13 +174,13 @@ public class SynapseAdminApiClient(AuthenticatedHomeserverSynapse authenticatedH
}
var parallelisationLimit = new SemaphoreSlim(32, 32);
- List<Task<(SynapseAdminRoomListResult.SynapseAdminRoomListResultRoom room, StateEventResponse?[] tasks)>> tasks = [];
+ List<Task<(SynapseAdminRoomListResult.SynapseAdminRoomListResultRoom room, MatrixEventResponse?[] tasks)>> tasks = [];
- async Task<(SynapseAdminRoomListResult.SynapseAdminRoomListResultRoom room, StateEventResponse?[] tasks)> fillTask(
+ async Task<(SynapseAdminRoomListResult.SynapseAdminRoomListResultRoom room, MatrixEventResponse?[] tasks)> fillTask(
SynapseAdminRoomListResult.SynapseAdminRoomListResultRoom room) {
if (serverSupportsQueryEventsV2) return (room, []);
- var fillTasks = await Task.WhenAll(((Task<StateEventResponse?>?[]) [
+ var fillTasks = await Task.WhenAll(((Task<MatrixEventResponse?>?[]) [
fetchTombstones && room.TombstoneEvent is null
? parallelisationLimit.RunWithLockAsync(() => room.GetTombstoneEventAsync(authenticatedHomeserver))
: null!,
@@ -201,7 +201,7 @@ public class SynapseAdminApiClient(AuthenticatedHomeserverSynapse authenticatedH
tasks.AddRange(
serverSupportsQueryEventsV2
- ? keep.Select(x => Task.FromResult((x, (StateEventResponse?[])[])))
+ ? keep.Select(x => Task.FromResult((x, (MatrixEventResponse?[])[])))
: keep.Select(fillTask)
);
diff --git a/LibMatrix/Responses/CreateRoomRequest.cs b/LibMatrix/Responses/CreateRoomRequest.cs
index db7d004..b4dcc78 100644
--- a/LibMatrix/Responses/CreateRoomRequest.cs
+++ b/LibMatrix/Responses/CreateRoomRequest.cs
@@ -29,7 +29,7 @@ public class CreateRoomRequest {
// public string Preset { get; set; }
[JsonPropertyName("initial_state")]
- public List<StateEvent>? InitialState { get; set; }
+ public List<MatrixEvent>? InitialState { get; set; }
/// <summary>
/// One of: ["public", "private"]
@@ -54,15 +54,15 @@ public class CreateRoomRequest {
/// For use only when you can't use the CreationContent property
/// </summary>
- public StateEvent? this[string eventType, string eventKey = ""] {
+ public MatrixEvent? this[string eventType, string eventKey = ""] {
get {
var stateEvent = InitialState?.FirstOrDefault(x => x.Type == eventType && x.StateKey == eventKey);
if (stateEvent == null)
- InitialState?.Add(stateEvent = new StateEvent {
+ InitialState?.Add(stateEvent = new MatrixEvent {
Type = eventType,
StateKey = eventKey,
TypedContent = (EventContent)Activator.CreateInstance(
- StateEvent.KnownStateEventTypes.FirstOrDefault(x =>
+ MatrixEvent.KnownEventTypes.FirstOrDefault(x =>
x.GetCustomAttributes<MatrixEventAttribute>()?
.Any(y => y.EventName == eventType) ?? false) ?? typeof(UnknownEventContent)
)!
@@ -122,7 +122,7 @@ public class CreateRoomRequest {
}
},
RoomAliasName = roomAliasName,
- InitialState = new List<StateEvent>()
+ InitialState = new List<MatrixEvent>()
};
return request;
@@ -162,7 +162,7 @@ public class CreateRoomRequest {
}
},
RoomAliasName = roomAliasName,
- InitialState = new List<StateEvent>()
+ InitialState = new List<MatrixEvent>()
};
return request;
diff --git a/LibMatrix/Responses/MessagesResponse.cs b/LibMatrix/Responses/MessagesResponse.cs
index 4912add..1b412fe 100644
--- a/LibMatrix/Responses/MessagesResponse.cs
+++ b/LibMatrix/Responses/MessagesResponse.cs
@@ -10,8 +10,8 @@ public class MessagesResponse {
public string? End { get; set; }
[JsonPropertyName("chunk")]
- public List<StateEventResponse> Chunk { get; set; } = new();
+ public List<MatrixEventResponse> Chunk { get; set; } = new();
[JsonPropertyName("state")]
- public List<StateEventResponse> State { get; set; } = new();
+ public List<MatrixEventResponse> State { get; set; } = new();
}
\ No newline at end of file
diff --git a/LibMatrix/Responses/SyncResponse.cs b/LibMatrix/Responses/SyncResponse.cs
index c2598ae..362ccc4 100644
--- a/LibMatrix/Responses/SyncResponse.cs
+++ b/LibMatrix/Responses/SyncResponse.cs
@@ -44,7 +44,7 @@ public class SyncResponse {
// supporting classes
public class PresenceDataStructure {
[JsonPropertyName("events")]
- public List<StateEventResponse>? Events { get; set; }
+ public List<MatrixEventResponse>? Events { get; set; }
}
public class RoomsDataStructure {
@@ -116,13 +116,13 @@ public class SyncResponse {
public class TimelineDataStructure : EventList {
public TimelineDataStructure() { }
- public TimelineDataStructure(List<StateEventResponse>? events, bool? limited) {
+ public TimelineDataStructure(List<MatrixEventResponse>? events, bool? limited) {
Events = events;
Limited = limited;
}
// [JsonPropertyName("events")]
- // public List<StateEventResponse>? Events { get; set; }
+ // public List<MatrixEventResponse>? Events { get; set; }
[JsonPropertyName("prev_batch")]
public string? PrevBatch { get; set; }
diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs
index 37f301e..6d9a499 100644
--- a/LibMatrix/RoomTypes/GenericRoom.cs
+++ b/LibMatrix/RoomTypes/GenericRoom.cs
@@ -27,13 +27,13 @@ public class GenericRoom {
public string RoomId { get; set; }
- public async IAsyncEnumerable<StateEventResponse?> GetFullStateAsync() {
- var result = Homeserver.ClientHttpClient.GetAsyncEnumerableFromJsonAsync<StateEventResponse>($"/_matrix/client/v3/rooms/{RoomId}/state");
+ public async IAsyncEnumerable<MatrixEventResponse?> GetFullStateAsync() {
+ var result = Homeserver.ClientHttpClient.GetAsyncEnumerableFromJsonAsync<MatrixEventResponse>($"/_matrix/client/v3/rooms/{RoomId}/state");
await foreach (var resp in result) yield return resp;
}
- public Task<List<StateEventResponse>> GetFullStateAsListAsync() =>
- Homeserver.ClientHttpClient.GetFromJsonAsync<List<StateEventResponse>>($"/_matrix/client/v3/rooms/{RoomId}/state");
+ public Task<List<MatrixEventResponse>> GetFullStateAsListAsync() =>
+ Homeserver.ClientHttpClient.GetFromJsonAsync<List<MatrixEventResponse>>($"/_matrix/client/v3/rooms/{RoomId}/state");
public async Task<T?> GetStateAsync<T>(string type, string stateKey = "") {
if (string.IsNullOrEmpty(type)) throw new ArgumentNullException(nameof(type), "Event type must be specified");
@@ -63,7 +63,7 @@ public class GenericRoom {
}
}
- public async Task<StateEventResponse> GetStateEventAsync(string type, string stateKey = "") {
+ public async Task<MatrixEventResponse> GetStateEventAsync(string type, string stateKey = "") {
if (string.IsNullOrEmpty(type)) throw new ArgumentNullException(nameof(type), "Event type must be specified");
var url = $"/_matrix/client/v3/rooms/{RoomId}/state/{type}";
if (!string.IsNullOrEmpty(stateKey)) url += $"/{stateKey}";
@@ -76,7 +76,7 @@ public class GenericRoom {
ErrorCode = LibMatrixException.ErrorCodes.M_UNSUPPORTED
};
// throw new InvalidDataException("Returned event type does not match requested type, or server does not support passing `format`.");
- return resp.Deserialize<StateEventResponse>();
+ return resp.Deserialize<MatrixEventResponse>();
}
catch (MatrixException e) {
// if (e is not { ErrorCodode: "M_NOT_FOUND" }) {
@@ -128,7 +128,7 @@ public class GenericRoom {
}
}
- public async Task<StateEventResponse?> GetStateEventOrNullAsync(string type, string stateKey = "") {
+ public async Task<MatrixEventResponse?> GetStateEventOrNullAsync(string type, string stateKey = "") {
try {
return await GetStateEventAsync(type, stateKey);
}
@@ -241,13 +241,13 @@ public class GenericRoom {
return await res.Content.ReadFromJsonAsync<RoomIdResponse>() ?? throw new Exception("Failed to join room?");
}
- public async IAsyncEnumerable<StateEventResponse> GetMembersEnumerableAsync(string? membership = null) {
+ public async IAsyncEnumerable<MatrixEventResponse> GetMembersEnumerableAsync(string? membership = null) {
var url = $"/_matrix/client/v3/rooms/{RoomId}/members";
var isMembershipSet = !string.IsNullOrWhiteSpace(membership);
if (isMembershipSet) url += $"?membership={membership}";
var res = await Homeserver.ClientHttpClient.GetAsync(url);
- var result = await JsonSerializer.DeserializeAsync<ChunkedStateEventResponse>(await res.Content.ReadAsStreamAsync(), new JsonSerializerOptions() {
- TypeInfoResolver = ChunkedStateEventResponseSerializerContext.Default
+ var result = await JsonSerializer.DeserializeAsync<ChunkedMatrixEventResponse>(await res.Content.ReadAsStreamAsync(), new JsonSerializerOptions() {
+ TypeInfoResolver = ChunkedMatrixEventResponseSerializerContext.Default
});
if (result is null) throw new Exception("Failed to deserialise members response");
@@ -259,18 +259,18 @@ public class GenericRoom {
}
}
- public async Task<FrozenSet<StateEventResponse>> GetMembersListAsync(string? membership = null) {
+ public async Task<FrozenSet<MatrixEventResponse>> GetMembersListAsync(string? membership = null) {
var url = $"/_matrix/client/v3/rooms/{RoomId}/members";
var isMembershipSet = !string.IsNullOrWhiteSpace(membership);
if (isMembershipSet) url += $"?membership={membership}";
var res = await Homeserver.ClientHttpClient.GetAsync(url);
- var result = await JsonSerializer.DeserializeAsync<ChunkedStateEventResponse>(await res.Content.ReadAsStreamAsync(), new JsonSerializerOptions() {
- TypeInfoResolver = ChunkedStateEventResponseSerializerContext.Default
+ var result = await JsonSerializer.DeserializeAsync<ChunkedMatrixEventResponse>(await res.Content.ReadAsStreamAsync(), new JsonSerializerOptions() {
+ TypeInfoResolver = ChunkedMatrixEventResponseSerializerContext.Default
});
if (result is null) throw new Exception("Failed to deserialise members response");
- var members = new List<StateEventResponse>();
+ var members = new List<MatrixEventResponse>();
foreach (var resp in result.Chunk ?? []) {
if (resp.Type != "m.room.member") continue;
if (isMembershipSet && resp.RawContent?["membership"]?.GetValue<string>() != membership) continue;
@@ -478,8 +478,8 @@ public class GenericRoom {
}
}
- public Task<StateEventResponse> GetEventAsync(string eventId, bool includeUnredactedContent = false) =>
- Homeserver.ClientHttpClient.GetFromJsonAsync<StateEventResponse>(
+ public Task<MatrixEventResponse> GetEventAsync(string eventId, bool includeUnredactedContent = false) =>
+ Homeserver.ClientHttpClient.GetFromJsonAsync<MatrixEventResponse>(
// .ToLower() on boolean here because this query param specifically on synapse is checked as a string rather than a boolean
$"/_matrix/client/v3/rooms/{RoomId}/event/{eventId}?fi.mau.msc2815.include_unredacted_content={includeUnredactedContent.ToString().ToLower()}");
@@ -597,7 +597,7 @@ public class GenericRoom {
#endregion
- public async IAsyncEnumerable<StateEventResponse> GetRelatedEventsAsync(string eventId, string? relationType = null, string? eventType = null, string? dir = "f",
+ public async IAsyncEnumerable<MatrixEventResponse> GetRelatedEventsAsync(string eventId, string? relationType = null, string? eventType = null, string? dir = "f",
string? from = null, int? chunkLimit = 100, bool? recurse = null, string? to = null) {
var path = $"/_matrix/client/v1/rooms/{RoomId}/relations/{HttpUtility.UrlEncode(eventId)}";
if (!string.IsNullOrEmpty(relationType)) path += $"/{relationType}";
@@ -612,18 +612,18 @@ public class GenericRoom {
if (!string.IsNullOrEmpty(to)) uri = uri.AddQuery("to", to);
// Console.WriteLine($"Getting related events from {uri}");
- var result = await Homeserver.ClientHttpClient.GetFromJsonAsync<RecursedBatchedChunkedStateEventResponse>(uri.ToString());
+ var result = await Homeserver.ClientHttpClient.GetFromJsonAsync<RecursedBatchedChunkedMatrixEventResponse>(uri.ToString());
while (result!.Chunk.Count > 0) {
foreach (var resp in result.Chunk) {
yield return resp;
}
if (result.NextBatch is null) break;
- result = await Homeserver.ClientHttpClient.GetFromJsonAsync<RecursedBatchedChunkedStateEventResponse>(uri.AddQuery("from", result.NextBatch).ToString());
+ result = await Homeserver.ClientHttpClient.GetFromJsonAsync<RecursedBatchedChunkedMatrixEventResponse>(uri.AddQuery("from", result.NextBatch).ToString());
}
}
- public async Task BulkSendEventsAsync(IEnumerable<StateEvent> events, int? forceSyncInterval = null) {
+ public async Task BulkSendEventsAsync(IEnumerable<MatrixEvent> 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}";
@@ -640,7 +640,7 @@ public class GenericRoom {
}
}
- public async Task BulkSendEventsAsync(IAsyncEnumerable<StateEvent> events, int? forceSyncInterval = null) {
+ public async Task BulkSendEventsAsync(IAsyncEnumerable<MatrixEvent> 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}";
@@ -670,7 +670,7 @@ public class GenericRoom {
/// </summary>
/// <returns>A list of size 1 for v11 rooms and older, all creators for v12+</returns>
public async Task<List<string>> GetRoomCreatorsAsync() {
- StateEventResponse createEvent;
+ MatrixEventResponse createEvent;
if (IsV12PlusRoomId) {
createEvent = await GetEventAsync('$' + RoomId[1..]);
}
@@ -721,4 +721,4 @@ public class GenericRoom {
public class RoomIdResponse {
[JsonPropertyName("room_id")]
public string RoomId { get; set; }
-}
+}
\ No newline at end of file
diff --git a/LibMatrix/RoomTypes/PolicyRoom.cs b/LibMatrix/RoomTypes/PolicyRoom.cs
index c6eec63..e4fa6ae 100644
--- a/LibMatrix/RoomTypes/PolicyRoom.cs
+++ b/LibMatrix/RoomTypes/PolicyRoom.cs
@@ -7,13 +7,13 @@ namespace LibMatrix.RoomTypes;
public class PolicyRoom(AuthenticatedHomeserverGeneric homeserver, string roomId) : GenericRoom(homeserver, roomId) {
public const string TypeName = "support.feline.policy.lists.msc.v1";
-
+
public static readonly FrozenSet<string> UserPolicyEventTypes = EventContent.GetMatchingEventTypes<UserPolicyRuleEventContent>().ToFrozenSet();
public static readonly FrozenSet<string> ServerPolicyEventTypes = EventContent.GetMatchingEventTypes<ServerPolicyRuleEventContent>().ToFrozenSet();
public static readonly FrozenSet<string> RoomPolicyEventTypes = EventContent.GetMatchingEventTypes<RoomPolicyRuleEventContent>().ToFrozenSet();
public static readonly FrozenSet<string> SpecPolicyEventTypes = [..UserPolicyEventTypes, ..ServerPolicyEventTypes, ..RoomPolicyEventTypes];
- public async IAsyncEnumerable<StateEventResponse> GetPoliciesAsync() {
+ public async IAsyncEnumerable<MatrixEventResponse> GetPoliciesAsync() {
var fullRoomState = GetFullStateAsync();
await foreach (var eventResponse in fullRoomState) {
if (SpecPolicyEventTypes.Contains(eventResponse!.Type)) {
@@ -22,7 +22,7 @@ public class PolicyRoom(AuthenticatedHomeserverGeneric homeserver, string roomId
}
}
- public async IAsyncEnumerable<StateEventResponse> GetUserPoliciesAsync() {
+ public async IAsyncEnumerable<MatrixEventResponse> GetUserPoliciesAsync() {
var fullRoomState = GetPoliciesAsync();
await foreach (var eventResponse in fullRoomState) {
if (UserPolicyEventTypes.Contains(eventResponse!.Type)) {
@@ -31,7 +31,7 @@ public class PolicyRoom(AuthenticatedHomeserverGeneric homeserver, string roomId
}
}
- public async IAsyncEnumerable<StateEventResponse> GetServerPoliciesAsync() {
+ public async IAsyncEnumerable<MatrixEventResponse> GetServerPoliciesAsync() {
var fullRoomState = GetPoliciesAsync();
await foreach (var eventResponse in fullRoomState) {
if (ServerPolicyEventTypes.Contains(eventResponse!.Type)) {
@@ -40,7 +40,7 @@ public class PolicyRoom(AuthenticatedHomeserverGeneric homeserver, string roomId
}
}
- public async IAsyncEnumerable<StateEventResponse> GetRoomPoliciesAsync() {
+ public async IAsyncEnumerable<MatrixEventResponse> GetRoomPoliciesAsync() {
var fullRoomState = GetPoliciesAsync();
await foreach (var eventResponse in fullRoomState) {
if (RoomPolicyEventTypes.Contains(eventResponse!.Type)) {
diff --git a/LibMatrix/StateEvent.cs b/LibMatrix/StateEvent.cs
index 8455098..861b584 100644
--- a/LibMatrix/StateEvent.cs
+++ b/LibMatrix/StateEvent.cs
@@ -13,10 +13,10 @@ using LibMatrix.Extensions;
namespace LibMatrix;
-public class StateEvent {
- public static FrozenSet<Type> KnownStateEventTypes { get; } = ClassCollector<EventContent>.ResolveFromAllAccessibleAssemblies().ToFrozenSet();
+public class MatrixEvent {
+ public static FrozenSet<Type> KnownEventTypes { get; } = ClassCollector<EventContent>.ResolveFromAllAccessibleAssemblies().ToFrozenSet();
- public static FrozenDictionary<string, Type> KnownStateEventTypesByName { get; } = KnownStateEventTypes.Aggregate(
+ public static FrozenDictionary<string, Type> KnownEventTypesByName { get; } = KnownEventTypes.Aggregate(
new Dictionary<string, Type>(),
(dict, type) => {
var attrs = type.GetCustomAttributes<MatrixEventAttribute>();
@@ -29,11 +29,11 @@ public class StateEvent {
return dict;
}).OrderBy(x => x.Key).ToFrozenDictionary();
- public static Type GetStateEventType(string? type) =>
- string.IsNullOrWhiteSpace(type) ? typeof(UnknownEventContent) : KnownStateEventTypesByName.GetValueOrDefault(type) ?? typeof(UnknownEventContent);
+ public static Type GetEventType(string? type) =>
+ string.IsNullOrWhiteSpace(type) ? typeof(UnknownEventContent) : KnownEventTypesByName.GetValueOrDefault(type) ?? typeof(UnknownEventContent);
[JsonIgnore]
- public Type MappedType => GetStateEventType(Type);
+ public Type MappedType => GetEventType(Type);
[JsonIgnore]
public bool IsLegacyType => MappedType.GetCustomAttributes<MatrixEventAttribute>().FirstOrDefault(x => x.EventName == Type)?.Legacy ?? false;
@@ -58,7 +58,7 @@ public class StateEvent {
public EventContent? TypedContent {
get {
try {
- var mappedType = GetStateEventType(Type);
+ var mappedType = GetEventType(Type);
if (mappedType == typeof(UnknownEventContent))
Console.WriteLine($"Warning: unknown event type '{Type}'");
var deserialisedContent = (EventContent)RawContent.Deserialize(mappedType, TypedContentSerializerOptions)!;
@@ -121,8 +121,8 @@ public class StateEvent {
[JsonIgnore]
public string InternalContentTypeName => TypedContent?.GetType().Name ?? "null";
- public static bool TypeKeyPairMatches(StateEventResponse x, StateEventResponse y) => x.Type == y.Type && x.StateKey == y.StateKey;
- public static bool Equals(StateEventResponse x, StateEventResponse y) => x.Type == y.Type && x.StateKey == y.StateKey && x.EventId == y.EventId;
+ public static bool TypeKeyPairMatches(MatrixEventResponse x, MatrixEventResponse y) => x.Type == y.Type && x.StateKey == y.StateKey;
+ public static bool Equals(MatrixEventResponse x, MatrixEventResponse y) => x.Type == y.Type && x.StateKey == y.StateKey && x.EventId == y.EventId;
/// <summary>
/// Compares two state events for deep equality, including type, state key, and raw content.
@@ -131,10 +131,10 @@ public class StateEvent {
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
- public static bool DeepEquals(StateEventResponse x, StateEventResponse y) => x.Type == y.Type && x.StateKey == y.StateKey && JsonNode.DeepEquals(x.RawContent, y.RawContent);
+ public static bool DeepEquals(MatrixEventResponse x, MatrixEventResponse y) => x.Type == y.Type && x.StateKey == y.StateKey && JsonNode.DeepEquals(x.RawContent, y.RawContent);
}
-public class StateEventResponse : StateEvent {
+public class MatrixEventResponse : MatrixEvent {
[JsonPropertyName("origin_server_ts")]
public long? OriginServerTs { get; set; }
@@ -178,27 +178,27 @@ public class StateEventResponse : StateEvent {
}
[JsonSourceGenerationOptions(WriteIndented = true)]
-[JsonSerializable(typeof(ChunkedStateEventResponse))]
-internal partial class ChunkedStateEventResponseSerializerContext : JsonSerializerContext;
+[JsonSerializable(typeof(ChunkedMatrixEventResponse))]
+internal partial class ChunkedMatrixEventResponseSerializerContext : JsonSerializerContext;
[DebuggerDisplay("{Events.Count} events")]
public class EventList {
public EventList() { }
- public EventList(List<StateEventResponse>? events) {
+ public EventList(List<MatrixEventResponse>? events) {
Events = events;
}
[JsonPropertyName("events")]
- public List<StateEventResponse>? Events { get; set; } = new();
+ public List<MatrixEventResponse>? Events { get; set; } = new();
}
-public class ChunkedStateEventResponse {
+public class ChunkedMatrixEventResponse {
[JsonPropertyName("chunk")]
- public List<StateEventResponse>? Chunk { get; set; } = new();
+ public List<MatrixEventResponse>? Chunk { get; set; } = new();
}
-public class PaginatedChunkedStateEventResponse : ChunkedStateEventResponse {
+public class PaginatedChunkedMatrixEventResponse : ChunkedMatrixEventResponse {
[JsonPropertyName("start")]
public string? Start { get; set; }
@@ -206,7 +206,7 @@ public class PaginatedChunkedStateEventResponse : ChunkedStateEventResponse {
public string? End { get; set; }
}
-public class BatchedChunkedStateEventResponse : ChunkedStateEventResponse {
+public class BatchedChunkedMatrixEventResponse : ChunkedMatrixEventResponse {
[JsonPropertyName("next_batch")]
public string? NextBatch { get; set; }
@@ -214,7 +214,7 @@ public class BatchedChunkedStateEventResponse : ChunkedStateEventResponse {
public string? PrevBatch { get; set; }
}
-public class RecursedBatchedChunkedStateEventResponse : BatchedChunkedStateEventResponse {
+public class RecursedBatchedChunkedMatrixEventResponse : BatchedChunkedMatrixEventResponse {
[JsonPropertyName("recursion_depth")]
public int? RecursionDepth { get; set; }
}
@@ -235,7 +235,7 @@ public class StateEventContentPolymorphicTypeInfoResolver : DefaultJsonTypeInfoR
IgnoreUnrecognizedTypeDiscriminators = true,
UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FallBackToBaseType,
- DerivedTypes = StateEvent.KnownStateEventTypesByName.Select(x => new JsonDerivedType(x.Value, x.Key)).ToList()
+ DerivedTypes = MatrixEvent.KnownEventTypesByName.Select(x => new JsonDerivedType(x.Value, x.Key)).ToList()
// DerivedTypes = new ClassCollector<EventContent>()
// .ResolveFromAllAccessibleAssemblies()
diff --git a/Tests/LibMatrix.Tests/Abstractions/RoomAbstraction.cs b/Tests/LibMatrix.Tests/Abstractions/RoomAbstraction.cs
index d02ced3..7c74d9f 100644
--- a/Tests/LibMatrix.Tests/Abstractions/RoomAbstraction.cs
+++ b/Tests/LibMatrix.Tests/Abstractions/RoomAbstraction.cs
@@ -14,29 +14,29 @@ public static class RoomAbstraction {
// Visibility = CreateRoomVisibility.Public,
RoomAliasName = Guid.NewGuid().ToString()
};
- crq.InitialState ??= new List<StateEvent>();
- crq.InitialState.Add(new StateEvent() {
+ crq.InitialState ??= new List<MatrixEvent>();
+ crq.InitialState.Add(new MatrixEvent() {
Type = RoomTopicEventContent.EventId,
StateKey = "",
TypedContent = new RoomTopicEventContent() {
Topic = "LibMatrix Test Room " + DateTime.Now.ToString("O")
}
});
- crq.InitialState.Add(new StateEvent() {
+ crq.InitialState.Add(new MatrixEvent() {
Type = RoomNameEventContent.EventId,
StateKey = "",
TypedContent = new RoomNameEventContent() {
Name = "LibMatrix Test Room " + DateTime.Now.ToString("O")
}
});
- crq.InitialState.Add(new StateEvent() {
+ crq.InitialState.Add(new MatrixEvent() {
Type = RoomAvatarEventContent.EventId,
StateKey = "",
TypedContent = new RoomAvatarEventContent() {
Url = "mxc://conduit.rory.gay/r9KiT0f9eQbv8pv4RxwBZFuzhfKjGWHx"
}
});
- crq.InitialState.Add(new StateEvent() {
+ crq.InitialState.Add(new MatrixEvent() {
Type = RoomAliasEventContent.EventId,
StateKey = "",
TypedContent = new RoomAliasEventContent() {
@@ -60,7 +60,7 @@ public static class RoomAbstraction {
Name = $"LibMatrix Test Space ({roomCount} children)",
// Visibility = CreateRoomVisibility.Public,
RoomAliasName = Guid.NewGuid().ToString(),
- InitialState = new List<StateEvent>()
+ InitialState = new List<MatrixEvent>()
};
crq.CreationContentBaseType.Type = "m.space";
@@ -72,7 +72,7 @@ public static class RoomAbstraction {
})).ToAsyncResultEnumerable();
await foreach (var room in createRoomTasks)
- crq.InitialState.Add(new StateEvent {
+ crq.InitialState.Add(new MatrixEvent {
Type = "m.space.child",
StateKey = room.RoomId,
TypedContent = new SpaceChildEventContent() {
@@ -85,7 +85,7 @@ public static class RoomAbstraction {
if (addSpaces)
for (var i = 0; i < roomCount; i++) {
var space = await GetTestSpace(hs, roomCount - spaceSizeReduction, true, spaceSizeReduction);
- crq.InitialState.Add(new StateEvent {
+ crq.InitialState.Add(new MatrixEvent {
Type = "m.space.child",
StateKey = space.RoomId,
TypedContent = new SpaceChildEventContent() {
diff --git a/Tests/LibMatrix.Tests/Tests/RoomTests/RoomMembershipTests.cs b/Tests/LibMatrix.Tests/Tests/RoomTests/RoomMembershipTests.cs
index 0943b8a..1b2271e 100644
--- a/Tests/LibMatrix.Tests/Tests/RoomTests/RoomMembershipTests.cs
+++ b/Tests/LibMatrix.Tests/Tests/RoomTests/RoomMembershipTests.cs
@@ -17,8 +17,8 @@ public class RoomMembershipTests : TestBed<TestFixture> {
[Fact]
public async Task GetMembersAsync() {
- Assert.True(StateEvent.KnownStateEventTypes is { Count: > 0 }, "StateEvent.KnownStateEventTypes is empty!");
- Assert.True(StateEvent.KnownStateEventTypesByName is { Count: > 0 }, "StateEvent.KnownStateEventTypesByName is empty!");
+ Assert.True(MatrixEvent.KnownEventTypes is { Count: > 0 }, "MatrixEvent.KnownEventTypes is empty!");
+ Assert.True(MatrixEvent.KnownEventTypesByName is { Count: > 0 }, "MatrixEvent.KnownEventTypesByName is empty!");
var hs = await _hsAbstraction.GetConfiguredHomeserver();
var room = await RoomAbstraction.GetTestRoom(hs);
diff --git a/Tests/LibMatrix.Tests/Tests/RoomTests/RoomTests.cs b/Tests/LibMatrix.Tests/Tests/RoomTests/RoomTests.cs
index 7801ed0..817eca9 100644
--- a/Tests/LibMatrix.Tests/Tests/RoomTests/RoomTests.cs
+++ b/Tests/LibMatrix.Tests/Tests/RoomTests/RoomTests.cs
@@ -35,8 +35,8 @@ public class RoomTests : TestBed<TestFixture> {
[Fact]
public async Task GetMembersAsync() {
- Assert.True(StateEvent.KnownStateEventTypes is { Count: > 0 }, "StateEvent.KnownStateEventTypes is empty!");
- Assert.True(StateEvent.KnownStateEventTypesByName is { Count: > 0 }, "StateEvent.KnownStateEventTypesByName is empty!");
+ Assert.True(MatrixEvent.KnownEventTypes is { Count: > 0 }, "MatrixEvent.KnownEventTypes is empty!");
+ Assert.True(MatrixEvent.KnownEventTypesByName is { Count: > 0 }, "MatrixEvent.KnownEventTypesByName is empty!");
var hs = await _hsAbstraction.GetConfiguredHomeserver();
var room = await RoomAbstraction.GetTestRoom(hs);
@@ -240,7 +240,7 @@ public class RoomTests : TestBed<TestFixture> {
});
await room.LeaveAsync();
-
+
await File.WriteAllTextAsync("test.json", messages.ToJson());
}
@@ -268,7 +268,7 @@ public class RoomTests : TestBed<TestFixture> {
await room.LeaveAsync();
}
-
+
[Fact]
public async Task SendMessageEventAsync() {
var hs = await _hsAbstraction.GetConfiguredHomeserver();
@@ -276,13 +276,14 @@ public class RoomTests : TestBed<TestFixture> {
Assert.NotNull(room);
var res = await room.SendMessageEventAsync(new RoomMessageEventContent(body: "This test was written by Emma [it/its], member of the Rory& system." +
- "\nIf you are reading this on matrix, it means the unit test for sending a message works!", messageType: "m.text"));
+ "\nIf you are reading this on matrix, it means the unit test for sending a message works!",
+ messageType: "m.text"));
Assert.NotNull(res);
Assert.NotNull(res.EventId);
await room.LeaveAsync();
}
-
+
[Fact]
public async Task InviteUsersAsync() {
var hs = await _hsAbstraction.GetConfiguredHomeserver();
@@ -298,7 +299,7 @@ public class RoomTests : TestBed<TestFixture> {
Assert.NotNull(u.UserId);
Assert.NotEmpty(u.UserId);
});
-
+
await room.InviteUsersAsync(users.Select(u => u.UserId));
var members = await room.GetMembersListAsync();
Assert.NotNull(members);
@@ -310,7 +311,7 @@ public class RoomTests : TestBed<TestFixture> {
Assert.NotEmpty(m.StateKey);
});
Assert.All(users, u => Assert.Contains(u.UserId, members.Select(m => m.StateKey)));
-
+
await room.LeaveAsync();
}
}
\ No newline at end of file
diff --git a/Tests/LibMatrix.Tests/Tests/RoomTests/SpaceTests.cs b/Tests/LibMatrix.Tests/Tests/RoomTests/SpaceTests.cs
index 36b4ad8..d59920d 100644
--- a/Tests/LibMatrix.Tests/Tests/RoomTests/SpaceTests.cs
+++ b/Tests/LibMatrix.Tests/Tests/RoomTests/SpaceTests.cs
@@ -72,7 +72,7 @@ public class SpaceTests : TestBed<TestFixture> {
var crq = new CreateRoomRequest() {
Name = "Test space",
- InitialState = expectedChildren.Select(c => new StateEvent() {
+ InitialState = expectedChildren.Select(c => new MatrixEvent() {
Type = "m.space.child",
StateKey = c.RoomId,
TypedContent = new SpaceChildEventContent() {
diff --git a/Utilities/LibMatrix.DevTestBot/Bot/DevTestBot.cs b/Utilities/LibMatrix.DevTestBot/Bot/DevTestBot.cs
index 3bb0c25..da4522e 100644
--- a/Utilities/LibMatrix.DevTestBot/Bot/DevTestBot.cs
+++ b/Utilities/LibMatrix.DevTestBot/Bot/DevTestBot.cs
@@ -48,7 +48,7 @@ public class DevTestBot : IHostedService {
// foreach (var room in await hs.GetJoinedRooms()) {
// if(room.RoomId is "!OGEhHVWSdvArJzumhm:matrix.org") continue;
- // foreach (var stateEvent in await room.GetStateAsync<List<StateEvent>>("")) {
+ // foreach (var stateEvent in await room.GetStateAsync<List<MatrixEvent>>("")) {
// var _ = stateEvent.GetType;
// }
// _logger.LogInformation($"Got room state for {room.RoomId}!");
diff --git a/Utilities/LibMatrix.DevTestBot/Bot/PingTestBot.cs b/Utilities/LibMatrix.DevTestBot/Bot/PingTestBot.cs
index e992e3c..345d755 100644
--- a/Utilities/LibMatrix.DevTestBot/Bot/PingTestBot.cs
+++ b/Utilities/LibMatrix.DevTestBot/Bot/PingTestBot.cs
@@ -63,7 +63,7 @@ public class PingTestBot : IHostedService {
// foreach (var room in await hs.GetJoinedRooms()) {
// if(room.RoomId is "!OGEhHVWSdvArJzumhm:matrix.org") continue;
- // foreach (var stateEvent in await room.GetStateAsync<List<StateEvent>>("")) {
+ // foreach (var stateEvent in await room.GetStateAsync<List<MatrixEvent>>("")) {
// var _ = stateEvent.GetType;
// }
// _logger.LogInformation($"Got room state for {room.RoomId}!");
diff --git a/Utilities/LibMatrix.HomeserverEmulator/Controllers/LegacyController.cs b/Utilities/LibMatrix.HomeserverEmulator/Controllers/LegacyController.cs
index 245770e..4c4e970 100644
--- a/Utilities/LibMatrix.HomeserverEmulator/Controllers/LegacyController.cs
+++ b/Utilities/LibMatrix.HomeserverEmulator/Controllers/LegacyController.cs
@@ -42,7 +42,7 @@ public class LegacyController(ILogger<LegacyController> logger, TokenService tok
room_id = room.RoomId,
state = room.State.ToList(),
visibility = "public",
- messages = new PaginatedChunkedStateEventResponse() {
+ messages = new PaginatedChunkedMatrixEventResponse() {
Chunk = timelineChunk,
End = timelineChunk.Last().EventId,
Start = timelineChunk.Count >= limit ? timelineChunk.First().EventId : null
diff --git a/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomAccountDataController.cs b/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomAccountDataController.cs
index bac803f..7bab143 100644
--- a/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomAccountDataController.cs
+++ b/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomAccountDataController.cs
@@ -38,7 +38,7 @@ public class RoomAccountDataController(ILogger<RoomAccountDataController> logger
if (!room.AccountData.ContainsKey(user.UserId))
room.AccountData[user.UserId] = new();
- room.AccountData[user.UserId].Add(new StateEventResponse() {
+ room.AccountData[user.UserId].Add(new MatrixEventResponse() {
Type = "m.fully_read",
StateKey = user.UserId,
RawContent = new() {
@@ -46,7 +46,7 @@ public class RoomAccountDataController(ILogger<RoomAccountDataController> logger
}
});
- room.AccountData[user.UserId].Add(new StateEventResponse() {
+ room.AccountData[user.UserId].Add(new MatrixEventResponse() {
Type = "m.read",
StateKey = user.UserId,
RawContent = new() {
@@ -54,7 +54,7 @@ public class RoomAccountDataController(ILogger<RoomAccountDataController> logger
}
});
- room.AccountData[user.UserId].Add(new StateEventResponse() {
+ room.AccountData[user.UserId].Add(new MatrixEventResponse() {
Type = "m.read.private",
StateKey = user.UserId,
RawContent = new() {
diff --git a/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomMembersController.cs b/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomMembersController.cs
index 6c57cc4..f599e5e 100644
--- a/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomMembersController.cs
+++ b/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomMembersController.cs
@@ -13,7 +13,7 @@ public class RoomMembersController(
RoomStore roomStore,
PaginationTokenResolverService paginationTokenResolver) : ControllerBase {
[HttpGet("members")]
- public async Task<List<StateEventResponse>> GetMembers(string roomId, string? at = null, string? membership = null, string? not_membership = null) {
+ public async Task<List<MatrixEventResponse>> GetMembers(string roomId, string? at = null, string? membership = null, string? not_membership = null) {
var token = tokenService.GetAccessTokenOrNull(HttpContext);
if (token == null)
throw new MatrixException() {
@@ -44,7 +44,7 @@ public class RoomMembersController(
members = members.Where(x => (x.TypedContent as RoomMemberEventContent)?.Membership != not_membership).ToList();
if (at != null) {
- StateEventResponse? evt = null;
+ MatrixEventResponse? evt = null;
if (at.StartsWith('$'))
evt = await paginationTokenResolver.ResolveTokenToEvent(at, room);
diff --git a/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomStateController.cs b/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomStateController.cs
index 485c028..bc17b06 100644
--- a/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomStateController.cs
+++ b/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomStateController.cs
@@ -11,7 +11,7 @@ namespace LibMatrix.HomeserverEmulator.Controllers.Rooms;
[Route("/_matrix/client/{version}/rooms/{roomId}/state")]
public class RoomStateController(ILogger<RoomStateController> logger, TokenService tokenService, UserStore userStore, RoomStore roomStore) : ControllerBase {
[HttpGet("")]
- public async Task<FrozenSet<StateEventResponse>> GetState(string roomId) {
+ public async Task<FrozenSet<MatrixEventResponse>> GetState(string roomId) {
var token = tokenService.GetAccessTokenOrNull(HttpContext);
if (token == null)
throw new MatrixException() {
@@ -104,7 +104,7 @@ public class RoomStateController(ILogger<RoomStateController> logger, TokenServi
ErrorCode = "M_NOT_FOUND",
Error = "Room not found"
};
- var evt = room.SetStateInternal(new StateEvent() { Type = eventType, StateKey = stateKey, RawContent = request }.ToStateEvent(user, room));
+ var evt = room.SetStateInternal(new MatrixEvent() { Type = eventType, StateKey = stateKey, RawContent = request }.ToStateEvent(user, room));
evt.Type = eventType;
evt.StateKey = stateKey;
return new EventIdResponse() {
diff --git a/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomTimelineController.cs b/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomTimelineController.cs
index 61195b8..d05554c 100644
--- a/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomTimelineController.cs
+++ b/Utilities/LibMatrix.HomeserverEmulator/Controllers/Rooms/RoomTimelineController.cs
@@ -35,7 +35,7 @@ public class RoomTimelineController(
Error = "Room not found"
};
- var evt = new StateEvent() {
+ var evt = new MatrixEvent() {
RawContent = content,
Type = eventType
}.ToStateEvent(user, room);
@@ -100,7 +100,7 @@ public class RoomTimelineController(
}
[HttpGet("event/{eventId}")]
- public async Task<StateEventResponse> GetEvent(string roomId, string eventId) {
+ public async Task<MatrixEventResponse> GetEvent(string roomId, string eventId) {
var token = tokenService.GetAccessToken(HttpContext);
var user = await userStore.GetUserByToken(token);
@@ -128,7 +128,7 @@ public class RoomTimelineController(
}
[HttpGet("relations/{eventId}")]
- public async Task<RecursedBatchedChunkedStateEventResponse> GetRelations(string roomId, string eventId, [FromQuery] string? dir = "b", [FromQuery] string? from = null,
+ public async Task<RecursedBatchedChunkedMatrixEventResponse> GetRelations(string roomId, string eventId, [FromQuery] string? dir = "b", [FromQuery] string? from = null,
[FromQuery] int? limit = 100, [FromQuery] bool? recurse = false, [FromQuery] string? to = null) {
var token = tokenService.GetAccessToken(HttpContext);
var user = await userStore.GetUserByToken(token);
@@ -161,7 +161,7 @@ public class RoomTimelineController(
}
[HttpGet("relations/{eventId}/{relationType}")]
- public async Task<RecursedBatchedChunkedStateEventResponse> GetRelations(string roomId, string eventId, string relationType, [FromQuery] string? dir = "b",
+ public async Task<RecursedBatchedChunkedMatrixEventResponse> GetRelations(string roomId, string eventId, string relationType, [FromQuery] string? dir = "b",
[FromQuery] string? from = null, [FromQuery] int? limit = 100, [FromQuery] bool? recurse = false, [FromQuery] string? to = null) {
var token = tokenService.GetAccessToken(HttpContext);
var user = await userStore.GetUserByToken(token);
@@ -194,7 +194,7 @@ public class RoomTimelineController(
}
[HttpGet("relations/{eventId}/{relationType}/{eventType}")]
- public async Task<RecursedBatchedChunkedStateEventResponse> GetRelations(string roomId, string eventId, string relationType, string eventType, [FromQuery] string? dir = "b",
+ public async Task<RecursedBatchedChunkedMatrixEventResponse> GetRelations(string roomId, string eventId, string relationType, string eventType, [FromQuery] string? dir = "b",
[FromQuery] string? from = null, [FromQuery] int? limit = 100, [FromQuery] bool? recurse = false, [FromQuery] string? to = null) {
var token = tokenService.GetAccessToken(HttpContext);
var user = await userStore.GetUserByToken(token);
@@ -226,7 +226,7 @@ public class RoomTimelineController(
};
}
- private async Task<IEnumerable<StateEventResponse>> GetRelationsInternal(string roomId, string eventId, string dir, string? from, int? limit, bool? recurse, string? to) {
+ private async Task<IEnumerable<MatrixEventResponse>> GetRelationsInternal(string roomId, string eventId, string dir, string? from, int? limit, bool? recurse, string? to) {
var room = roomStore.GetRoomById(roomId);
var evt = room.Timeline.SingleOrDefault(x => x.EventId == eventId);
if (evt == null)
@@ -254,7 +254,7 @@ public class RoomTimelineController(
private void InternalSendMessage(RoomStore.Room room, RoomMessageEventContent content) {
logger.LogInformation("Sending internal message: {content}", content.Body);
- room.Timeline.Add(new StateEventResponse() {
+ room.Timeline.Add(new MatrixEventResponse() {
Type = RoomMessageEventContent.EventId,
TypedContent = content,
// Sender = $"@hse:{tokenService.GenerateServerName(HttpContext)}",
@@ -265,7 +265,7 @@ public class RoomTimelineController(
});
}
- private async Task HandleHseCommand(StateEventResponse evt, RoomStore.Room room, UserStore.User user) {
+ private async Task HandleHseCommand(MatrixEventResponse evt, RoomStore.Room room, UserStore.User user) {
logger.LogWarning("Handling HSE command for {0}: {1}", user.UserId, evt.RawContent.ToJson(false, true));
try {
var msgContent = evt.TypedContent as RoomMessageEventContent;
@@ -332,7 +332,7 @@ public class RoomTimelineController(
if (Random.Shared.Next(100) > 75) {
crq.CreationContent["type"] = "m.space";
foreach (var item in Random.Shared.GetItems(roomStore._rooms.ToArray(), 50)) {
- crq.InitialState!.Add(new StateEvent() {
+ crq.InitialState!.Add(new MatrixEvent() {
Type = "m.space.child",
StateKey = item.RoomId,
TypedContent = new SpaceChildEventContent() {
@@ -384,7 +384,7 @@ public class RoomTimelineController(
}
}
- private async Task HandleImportNhekoProfilesCommand(string[] args, StateEventResponse evt, RoomStore.Room room, UserStore.User user) {
+ private async Task HandleImportNhekoProfilesCommand(string[] args, MatrixEventResponse evt, RoomStore.Room room, UserStore.User user) {
var msgContent = evt.TypedContent as RoomMessageEventContent;
var parts = msgContent.Body.Split('\n');
@@ -422,7 +422,7 @@ public class RoomTimelineController(
}
}
- private async Task HandleImportCommand(string[] args, StateEventResponse evt, RoomStore.Room room, UserStore.User user) {
+ private async Task HandleImportCommand(string[] args, MatrixEventResponse evt, RoomStore.Room room, UserStore.User user) {
var roomId = args[0];
var profile = args[1];
diff --git a/Utilities/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs b/Utilities/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs
index d938b1b..15e41d4 100644
--- a/Utilities/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs
+++ b/Utilities/LibMatrix.HomeserverEmulator/Extensions/EventExtensions.cs
@@ -3,8 +3,8 @@ using LibMatrix.HomeserverEmulator.Services;
namespace LibMatrix.HomeserverEmulator.Extensions;
public static class EventExtensions {
- public static StateEventResponse ToStateEvent(this StateEvent stateEvent, UserStore.User user, RoomStore.Room room) {
- return new StateEventResponse {
+ public static MatrixEventResponse ToStateEvent(this StateEvent stateEvent, UserStore.User user, RoomStore.Room room) {
+ return new MatrixEventResponse {
RawContent = stateEvent.RawContent,
EventId = "$" + string.Join("", Random.Shared.GetItems("abcdefghijklmnopqrstuvwxyzABCDEFGHIJLKMNOPQRSTUVWXYZ0123456789".ToCharArray(), 100)),
RoomId = room.RoomId,
@@ -15,7 +15,7 @@ public static class EventExtensions {
};
}
- public static List<StateEventResponse> GetCalculatedState(this IEnumerable<StateEventResponse> events) {
+ public static List<MatrixEventResponse> GetCalculatedState(this IEnumerable<MatrixEventResponse> events) {
return events.Where(s => s.StateKey != null)
.OrderByDescending(s => s.OriginServerTs)
.DistinctBy(x => (x.Type, x.StateKey))
diff --git a/Utilities/LibMatrix.HomeserverEmulator/Services/PaginationTokenResolverService.cs b/Utilities/LibMatrix.HomeserverEmulator/Services/PaginationTokenResolverService.cs
index 0603a2d..7324bd8 100644
--- a/Utilities/LibMatrix.HomeserverEmulator/Services/PaginationTokenResolverService.cs
+++ b/Utilities/LibMatrix.HomeserverEmulator/Services/PaginationTokenResolverService.cs
@@ -35,7 +35,7 @@ public class PaginationTokenResolverService(ILogger<PaginationTokenResolverServi
}
}
- public Task<StateEventResponse?> ResolveTokenToEvent(string token, RoomStore.Room room) {
+ public Task<MatrixEventResponse?> ResolveTokenToEvent(string token, RoomStore.Room room) {
if (token.StartsWith('$')) {
//we have an event ID
logger.LogTrace("ResolveTokenToEvent(EventId({token}), Room({room})): searching for event...", token, room.RoomId);
@@ -43,7 +43,7 @@ public class PaginationTokenResolverService(ILogger<PaginationTokenResolverServi
var evt = room.Timeline.SingleOrDefault(x => x.EventId == token);
if (evt is not null) return Task.FromResult(evt);
logger.LogTrace("ResolveTokenToEvent({token}, Room({room})): event not in requested room...", token, room.RoomId);
- return Task.FromResult<StateEventResponse?>(null);
+ return Task.FromResult<MatrixEventResponse?>(null);
}
else {
// we have a sync token
diff --git a/Utilities/LibMatrix.HomeserverEmulator/Services/RoomStore.cs b/Utilities/LibMatrix.HomeserverEmulator/Services/RoomStore.cs
index b6fe7c2..232863f 100644
--- a/Utilities/LibMatrix.HomeserverEmulator/Services/RoomStore.cs
+++ b/Utilities/LibMatrix.HomeserverEmulator/Services/RoomStore.cs
@@ -51,7 +51,7 @@ public class RoomStore {
public Room CreateRoom(CreateRoomRequest request, UserStore.User? user = null) {
var room = new Room(roomId: $"!{Guid.NewGuid().ToString()}");
- var newCreateEvent = new StateEvent() {
+ var newCreateEvent = new MatrixEvent() {
Type = RoomCreateEventContent.EventId,
RawContent = new()
};
@@ -78,7 +78,7 @@ public class RoomStore {
}
if (!string.IsNullOrWhiteSpace(request.Name))
- room.SetStateInternal(new StateEvent() {
+ room.SetStateInternal(new MatrixEvent() {
Type = RoomNameEventContent.EventId,
TypedContent = new RoomNameEventContent() {
Name = request.Name
@@ -86,7 +86,7 @@ public class RoomStore {
});
if (!string.IsNullOrWhiteSpace(request.RoomAliasName))
- room.SetStateInternal(new StateEvent() {
+ room.SetStateInternal(new MatrixEvent() {
Type = RoomCanonicalAliasEventContent.EventId,
TypedContent = new RoomCanonicalAliasEventContent() {
Alias = $"#{request.RoomAliasName}:localhost"
@@ -112,10 +112,10 @@ public class RoomStore {
public class Room : NotifyPropertyChanged {
private CancellationTokenSource _debounceCts = new();
- private ObservableCollection<StateEventResponse> _timeline;
- private ObservableDictionary<string, List<StateEventResponse>> _accountData;
+ private ObservableCollection<MatrixEventResponse> _timeline;
+ private ObservableDictionary<string, List<MatrixEventResponse>> _accountData;
private ObservableDictionary<string, ReadMarkersData> _readMarkers;
- private FrozenSet<StateEventResponse> _stateCache;
+ private FrozenSet<MatrixEventResponse> _stateCache;
private int _timelineHash;
public Room(string roomId) {
@@ -129,9 +129,9 @@ public class RoomStore {
public string RoomId { get; set; }
- public FrozenSet<StateEventResponse> State => _timelineHash == _timeline.GetHashCode() ? _stateCache : RebuildState();
+ public FrozenSet<MatrixEventResponse> State => _timelineHash == _timeline.GetHashCode() ? _stateCache : RebuildState();
- public ObservableCollection<StateEventResponse> Timeline {
+ public ObservableCollection<MatrixEventResponse> Timeline {
get => _timeline;
set {
if (Equals(value, _timeline)) return;
@@ -140,7 +140,7 @@ public class RoomStore {
// we dont want to do this as it's rebuilt when the state is accessed
// if (args.Action == NotifyCollectionChangedAction.Add) {
- // foreach (StateEventResponse state in args.NewItems) {
+ // foreach (MatrixEventResponse state in args.NewItems) {
// if (state.StateKey is not null)
// // we want state to be deduplicated by type and key, and we want the latest state to be the one that is returned
// RebuildState();
@@ -154,7 +154,7 @@ public class RoomStore {
}
}
- public ObservableDictionary<string, List<StateEventResponse>> AccountData {
+ public ObservableDictionary<string, List<MatrixEventResponse>> AccountData {
get => _accountData;
set {
if (Equals(value, _accountData)) return;
@@ -164,7 +164,7 @@ public class RoomStore {
}
}
- public ImmutableList<StateEventResponse> JoinedMembers =>
+ public ImmutableList<MatrixEventResponse> JoinedMembers =>
State.Where(s => s is { Type: RoomMemberEventContent.EventId, TypedContent: RoomMemberEventContent { Membership: "join" } }).ToImmutableList();
public ObservableDictionary<string, ReadMarkersData> ReadMarkers {
@@ -177,8 +177,8 @@ public class RoomStore {
}
}
- internal StateEventResponse SetStateInternal(StateEvent request, string? senderId = null, UserStore.User? user = null) {
- var state = request as StateEventResponse ?? new StateEventResponse() {
+ internal MatrixEventResponse SetStateInternal(MatrixEvent request, string? senderId = null, UserStore.User? user = null) {
+ var state = request as MatrixEventResponse ?? new MatrixEventResponse() {
Type = request.Type,
StateKey = request.StateKey ?? "",
EventId = "$" + Guid.NewGuid().ToString(),
@@ -195,7 +195,7 @@ public class RoomStore {
return state;
}
- public StateEventResponse AddUser(string userId) {
+ public MatrixEventResponse AddUser(string userId) {
var state = SetStateInternal(new() {
Type = RoomMemberEventContent.EventId,
StateKey = userId,
@@ -245,15 +245,15 @@ public class RoomStore {
private SemaphoreSlim stateRebuildSemaphore = new(1, 1);
- private FrozenSet<StateEventResponse> RebuildState() {
+ private FrozenSet<MatrixEventResponse> RebuildState() {
stateRebuildSemaphore.Wait();
while (true)
try {
Console.WriteLine($"Rebuilding state for room {RoomId}");
// ReSharper disable once RedundantEnumerableCastCall - This sometimes happens when the collection is modified during enumeration
- List<StateEventResponse>? timeline = null;
+ List<MatrixEventResponse>? timeline = null;
lock (_timeline) {
- timeline = Timeline.OfType<StateEventResponse>().ToList();
+ timeline = Timeline.OfType<MatrixEventResponse>().ToList();
}
foreach (var evt in timeline) {
@@ -284,7 +284,7 @@ public class RoomStore {
}
}
- public List<StateEventResponse> GetRoomsByMember(string userId) {
+ public List<MatrixEventResponse> GetRoomsByMember(string userId) {
// return _rooms
// // .Where(r => r.State.Any(s => s.Type == RoomMemberEventContent.EventId && s.StateKey == userId))
// .Select(r => (Room: r, MemberEvent: r.State.SingleOrDefault(s => s.Type == RoomMemberEventContent.EventId && s.StateKey == userId)))
diff --git a/Utilities/LibMatrix.HomeserverEmulator/Services/UserStore.cs b/Utilities/LibMatrix.HomeserverEmulator/Services/UserStore.cs
index 7f211e3..124a082 100644
--- a/Utilities/LibMatrix.HomeserverEmulator/Services/UserStore.cs
+++ b/Utilities/LibMatrix.HomeserverEmulator/Services/UserStore.cs
@@ -75,19 +75,18 @@ public class UserStore {
UserId = $"@{localPart}:{_config.ServerName}",
IsGuest = kind == "guest",
AccountData = new() {
- new StateEventResponse() {
+ new MatrixEventResponse() {
Type = "im.vector.analytics",
RawContent = new JsonObject() {
["pseudonymousAnalyticsOptIn"] = false
},
},
- new StateEventResponse() {
+ new MatrixEventResponse() {
Type = "im.vector.web.settings",
RawContent = new JsonObject() {
["developerMode"] = true,
["alwaysShowTimestamps"] = true,
["SpotlightSearch.showNsfwPublicRooms"] = true,
-
}
},
new() {
@@ -135,7 +134,7 @@ public class UserStore {
private ObservableDictionary<string, SessionInfo> _accessTokens;
private ObservableDictionary<string, SyncFilter> _filters;
private ObservableDictionary<string, object> _profile;
- private ObservableCollection<StateEventResponse> _accountData;
+ private ObservableCollection<MatrixEventResponse> _accountData;
private ObservableDictionary<string, RoomKeysResponse> _roomKeys;
private ObservableDictionary<string, LoginResponse> _authorizedSessions;
@@ -174,7 +173,7 @@ public class UserStore {
}
}
- public ObservableCollection<StateEventResponse> AccountData {
+ public ObservableCollection<MatrixEventResponse> AccountData {
get => _accountData;
set {
if (value == _accountData) return;
diff --git a/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs b/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs
index 71ecbed..4da6df2 100644
--- a/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs
@@ -7,7 +7,7 @@ namespace LibMatrix.Utilities.Bot.Interfaces;
public class CommandContext {
public required GenericRoom Room { get; set; }
- public required StateEventResponse MessageEvent { get; set; }
+ public required MatrixEventResponse MessageEvent { get; set; }
public string MessageContentWithoutReply =>
(MessageEvent.TypedContent as RoomMessageEventContent)!
diff --git a/Utilities/LibMatrix.Utilities.Bot/Interfaces/RoomInviteContext.cs b/Utilities/LibMatrix.Utilities.Bot/Interfaces/RoomInviteContext.cs
index 380c1c7..c5ffc7c 100644
--- a/Utilities/LibMatrix.Utilities.Bot/Interfaces/RoomInviteContext.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/Interfaces/RoomInviteContext.cs
@@ -7,7 +7,7 @@ namespace LibMatrix.Utilities.Bot.Interfaces;
public class RoomInviteContext {
public required string RoomId { get; init; }
public required AuthenticatedHomeserverGeneric Homeserver { get; init; }
- public required StateEventResponse MemberEvent { get; init; }
+ public required MatrixEventResponse MemberEvent { get; init; }
public required SyncResponse.RoomsDataStructure.InvitedRoomDataStructure InviteData { get; init; }
public async Task<string> TryGetInviterNameAsync() {
diff --git a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
index 7a5f408..5b697de 100644
--- a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
@@ -119,7 +119,7 @@ public class CommandListenerHostedService(
await _cts.CancelAsync();
}
- private async Task<string?> GetUsedPrefix(StateEventResponse evt) {
+ private async Task<string?> GetUsedPrefix(MatrixEventResponse evt) {
var messageContent = evt.TypedContent as RoomMessageEventContent;
var message = messageContent!.BodyWithoutReplyFallback;
var prefix = config.Prefixes.OrderByDescending(x => x.Length).FirstOrDefault(message.StartsWith);
@@ -139,7 +139,7 @@ public class CommandListenerHostedService(
return prefix;
}
- private async Task<CommandResult> InvokeCommand(StateEventResponse evt, string usedPrefix) {
+ private async Task<CommandResult> InvokeCommand(MatrixEventResponse evt, string usedPrefix) {
var message = evt.TypedContent as RoomMessageEventContent;
var room = hs.GetRoom(evt.RoomId!);
|