diff --git a/LibMatrix.LegacyEvents.EventTypes/Common/MjolnirShortcodeEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Common/MjolnirShortcodeLegacyEventContent.cs
index be8c154..25c53a6 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Common/MjolnirShortcodeEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Common/MjolnirShortcodeLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Common;
-[MatrixEvent(EventName = EventId)]
-public class MjolnirShortcodeEventContent : TimelineEventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class MjolnirShortcodeLegacyEventContent : TimelineLegacyEventContent {
public const string EventId = "org.matrix.mjolnir.shortcode";
[JsonPropertyName("shortcode")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Common/RoomEmotesEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Common/RoomEmotesLegacyEventContent.cs
index ee268d9..a884359 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Common/RoomEmotesEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Common/RoomEmotesLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Common;
-[MatrixEvent(EventName = EventId)]
-public class RoomEmotesEventContent : TimelineEventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomEmotesLegacyEventContent : TimelineLegacyEventContent {
public const string EventId = "im.ponies.room_emotes";
[JsonPropertyName("emoticons")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/EventContent.cs b/LibMatrix.LegacyEvents.EventTypes/LegacyEventContent.cs
index 3e76459..002a85f 100644
--- a/LibMatrix.LegacyEvents.EventTypes/EventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/LegacyEventContent.cs
@@ -4,18 +4,18 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes;
-public abstract class EventContent;
+public abstract class LegacyEventContent;
-public class UnknownEventContent : TimelineEventContent;
+public class UnknownLegacyEventContent : TimelineLegacyEventContent;
-public abstract class TimelineEventContent : EventContent {
+public abstract class TimelineLegacyEventContent : LegacyEventContent {
[JsonPropertyName("m.relates_to")]
public MessageRelatesTo? RelatesTo { get; set; }
[JsonPropertyName("m.new_content")]
public JsonObject? NewContent { get; set; }
- public TimelineEventContent SetReplaceRelation(string eventId) {
+ public TimelineLegacyEventContent SetReplaceRelation(string eventId) {
NewContent = JsonSerializer.SerializeToNode(this, GetType())!.AsObject();
// NewContent = JsonSerializer.Deserialize(jsonText, GetType());
RelatesTo = new MessageRelatesTo {
@@ -25,7 +25,7 @@ public abstract class TimelineEventContent : EventContent {
return this;
}
- public T SetReplaceRelation<T>(string eventId) where T : TimelineEventContent => SetReplaceRelation(eventId) as T ?? throw new InvalidOperationException();
+ public T SetReplaceRelation<T>(string eventId) where T : TimelineLegacyEventContent => SetReplaceRelation(eventId) as T ?? throw new InvalidOperationException();
public class MessageRelatesTo {
[JsonPropertyName("m.in_reply_to")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/MatrixEventAttribute.cs b/LibMatrix.LegacyEvents.EventTypes/LegacyMatrixEventAttribute.cs
index 708dad1..bfcc6f8 100644
--- a/LibMatrix.LegacyEvents.EventTypes/MatrixEventAttribute.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/LegacyMatrixEventAttribute.cs
@@ -1,7 +1,7 @@
namespace LibMatrix.LegacyEvents.EventTypes;
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
-public class MatrixEventAttribute : Attribute {
+public class LegacyMatrixEventAttribute : Attribute {
public required string EventName { get; set; }
public bool Legacy { get; set; }
}
\ No newline at end of file
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/Ephemeral/PresenceStateEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/Ephemeral/PresenceLegacyEventContent.cs
index 676f36d..136b69a 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/Ephemeral/PresenceStateEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/Ephemeral/PresenceLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.Ephemeral;
-[MatrixEvent(EventName = EventId)]
-public class PresenceEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class PresenceLegacyEventContent : LegacyEventContent {
public const string EventId = "m.presence";
[JsonPropertyName("presence")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/Ephemeral/RoomTypingEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/Ephemeral/RoomTypingLegacyEventContent.cs
index 97b86fc..a44b6a5 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/Ephemeral/RoomTypingEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/Ephemeral/RoomTypingLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class RoomTypingEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomTypingLegacyEventContent : LegacyEventContent {
public const string EventId = "m.typing";
[JsonPropertyName("user_ids")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/RoomMessageEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/RoomMessageLegacyEventContent.cs
index ef26ab0..a4de54e 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/RoomMessageEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/RoomMessageLegacyEventContent.cs
@@ -2,11 +2,11 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec;
-[MatrixEvent(EventName = EventId)]
-public class RoomMessageEventContent : TimelineEventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomMessageLegacyEventContent : TimelineLegacyEventContent {
public const string EventId = "m.room.message";
- public RoomMessageEventContent(string messageType = "m.notice", string? body = null) {
+ public RoomMessageLegacyEventContent(string messageType = "m.notice", string? body = null) {
MessageType = messageType;
Body = body ?? "";
}
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/RoomMessageReactionEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/RoomMessageReactionEventContent.cs
deleted file mode 100644
index 3649a6b..0000000
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/RoomMessageReactionEventContent.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace LibMatrix.LegacyEvents.EventTypes.Spec;
-
-[MatrixEvent(EventName = EventId)]
-public class RoomMessageReactionEventContent : TimelineEventContent {
- public const string EventId = "m.reaction";
-}
\ No newline at end of file
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/RoomMessageReactionLegacyEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/RoomMessageReactionLegacyEventContent.cs
new file mode 100644
index 0000000..185f2db
--- /dev/null
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/RoomMessageReactionLegacyEventContent.cs
@@ -0,0 +1,6 @@
+namespace LibMatrix.LegacyEvents.EventTypes.Spec;
+
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomMessageReactionLegacyEventContent : TimelineLegacyEventContent {
+ public const string EventId = "m.reaction";
+}
\ No newline at end of file
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs
index c61f2bf..60b1dff 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs
@@ -4,32 +4,32 @@ using ArcaneLibs.Attributes;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State.Policy;
//spec
-[MatrixEvent(EventName = EventId)] //spec
-[MatrixEvent(EventName = "m.room.rule.server", Legacy = true)] //???
-[MatrixEvent(EventName = "org.matrix.mjolnir.rule.server", Legacy = true)] //legacy
+[LegacyMatrixEvent(EventName = EventId)] //spec
+[LegacyMatrixEvent(EventName = "m.room.rule.server", Legacy = true)] //???
+[LegacyMatrixEvent(EventName = "org.matrix.mjolnir.rule.server", Legacy = true)] //legacy
[FriendlyName(Name = "Server policy", NamePlural = "Server policies")]
-public class ServerPolicyRuleEventContent : PolicyRuleEventContent {
+public class ServerPolicyRuleLegacyEventContent : PolicyRuleLegacyEventContent {
public const string EventId = "m.policy.rule.server";
}
-[MatrixEvent(EventName = EventId)] //spec
-[MatrixEvent(EventName = "m.room.rule.user", Legacy = true)] //???
-[MatrixEvent(EventName = "org.matrix.mjolnir.rule.user", Legacy = true)] //legacy
+[LegacyMatrixEvent(EventName = EventId)] //spec
+[LegacyMatrixEvent(EventName = "m.room.rule.user", Legacy = true)] //???
+[LegacyMatrixEvent(EventName = "org.matrix.mjolnir.rule.user", Legacy = true)] //legacy
[FriendlyName(Name = "User policy", NamePlural = "User policies")]
-public class UserPolicyRuleEventContent : PolicyRuleEventContent {
+public class UserPolicyRuleLegacyEventContent : PolicyRuleLegacyEventContent {
public const string EventId = "m.policy.rule.user";
}
-[MatrixEvent(EventName = EventId)] //spec
-[MatrixEvent(EventName = "m.room.rule.room", Legacy = true)] //???
-[MatrixEvent(EventName = "org.matrix.mjolnir.rule.room", Legacy = true)] //legacy
+[LegacyMatrixEvent(EventName = EventId)] //spec
+[LegacyMatrixEvent(EventName = "m.room.rule.room", Legacy = true)] //???
+[LegacyMatrixEvent(EventName = "org.matrix.mjolnir.rule.room", Legacy = true)] //legacy
[FriendlyName(Name = "Room policy", NamePlural = "Room policies")]
-public class RoomPolicyRuleEventContent : PolicyRuleEventContent {
+public class RoomPolicyRuleLegacyEventContent : PolicyRuleLegacyEventContent {
public const string EventId = "m.policy.rule.room";
}
-public abstract class PolicyRuleEventContent : EventContent {
- public PolicyRuleEventContent() => Console.WriteLine($"init policy {GetType().Name}");
+public abstract class PolicyRuleLegacyEventContent : LegacyEventContent {
+ public PolicyRuleLegacyEventContent() => Console.WriteLine($"init policy {GetType().Name}");
private string? _reason;
/// <summary>
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomAliasEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomAliasLegacyEventContent.cs
index 197fe4b..34ff49e 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomAliasEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomAliasLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State.RoomInfo;
-[MatrixEvent(EventName = EventId)]
-public class RoomAliasEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomAliasLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.alias";
[JsonPropertyName("aliases")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomAvatarEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomAvatarLegacyEventContent.cs
index bc70d65..99d8b39 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomAvatarEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomAvatarLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State.RoomInfo;
-[MatrixEvent(EventName = EventId)]
-public class RoomAvatarEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomAvatarLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.avatar";
[JsonPropertyName("url")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasLegacyEventContent.cs
index 790f80b..9d27079 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class RoomCanonicalAliasEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomCanonicalAliasLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.canonical_alias";
[JsonPropertyName("alias")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomCreateLegacyEventContent.cs
index c6d259d..9f0a693 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomCreateLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class RoomCreateEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomCreateLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.create";
[JsonPropertyName("room_version")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomEncryptionEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomEncryptionLegacyEventContent.cs
index 2fed1f3..34bd4fe 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomEncryptionEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomEncryptionLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class RoomEncryptionEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomEncryptionLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.encryption";
[JsonPropertyName("algorithm")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomGuestAccessEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomGuestAccessLegacyEventContent.cs
index be66dbf..923b8ee 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomGuestAccessEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomGuestAccessLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class RoomGuestAccessEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomGuestAccessLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.guest_access";
[JsonPropertyName("guest_access")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityLegacyEventContent.cs
index 0be42d6..ab11dfc 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class RoomHistoryVisibilityEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomHistoryVisibilityLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.history_visibility";
[JsonPropertyName("history_visibility")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomJoinRulesLegacyEventContent.cs
index 48202a5..4330697 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomJoinRulesLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class RoomJoinRulesEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomJoinRulesLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.join_rules";
/// <summary>
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomMemberLegacyEventContent.cs
index 1926417..d716425 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomMemberLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class RoomMemberEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomMemberLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.member";
[JsonPropertyName("reason")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomNameEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomNameLegacyEventContent.cs
index 165a1a3..29646fe 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomNameEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomNameLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class RoomNameEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomNameLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.name";
[JsonPropertyName("name")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomPinnedEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomPinnedLegacyEventContent.cs
index 4c08396..bbef3de 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomPinnedEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomPinnedLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class RoomPinnedEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomPinnedLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.pinned_events";
[JsonPropertyName("pinned")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomPowerLevelLegacyEventContent.cs
index e7b58ee..cf41b6d 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomPowerLevelLegacyEventContent.cs
@@ -2,9 +2,9 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
+[LegacyMatrixEvent(EventName = EventId)]
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
-public class RoomPowerLevelEventContent : EventContent {
+public class RoomPowerLevelLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.power_levels";
[JsonPropertyName("ban")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomServerACLEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomServerAclLegacyEventContent.cs
index 506203f..d9cedd4 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomServerACLEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomServerAclLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class RoomServerACLEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class RoomServerAclLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.server_acl";
[JsonPropertyName("allow")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomTopicEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomTopicLegacyEventContent.cs
index d9e1ba9..fbd5124 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomTopicEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/RoomInfo/RoomTopicLegacyEventContent.cs
@@ -2,9 +2,9 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-[MatrixEvent(EventName = "org.matrix.msc3765.topic", Legacy = true)]
-public class RoomTopicEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+[LegacyMatrixEvent(EventName = "org.matrix.msc3765.topic", Legacy = true)]
+public class RoomTopicLegacyEventContent : LegacyEventContent {
public const string EventId = "m.room.topic";
[JsonPropertyName("topic")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/Space/SpaceChildEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/Space/SpaceChildLegacyEventContent.cs
index bd8ff64..75440e5 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/Space/SpaceChildEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/Space/SpaceChildLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class SpaceChildEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class SpaceChildLegacyEventContent : LegacyEventContent {
public const string EventId = "m.space.child";
[JsonPropertyName("auto_join")]
diff --git a/LibMatrix.LegacyEvents.EventTypes/Spec/State/Space/SpaceParentEventContent.cs b/LibMatrix.LegacyEvents.EventTypes/Spec/State/Space/SpaceParentLegacyEventContent.cs
index 4e9903f..f58143a 100644
--- a/LibMatrix.LegacyEvents.EventTypes/Spec/State/Space/SpaceParentEventContent.cs
+++ b/LibMatrix.LegacyEvents.EventTypes/Spec/State/Space/SpaceParentLegacyEventContent.cs
@@ -2,8 +2,8 @@ using System.Text.Json.Serialization;
namespace LibMatrix.LegacyEvents.EventTypes.Spec.State;
-[MatrixEvent(EventName = EventId)]
-public class SpaceParentEventContent : EventContent {
+[LegacyMatrixEvent(EventName = EventId)]
+public class SpaceParentLegacyEventContent : LegacyEventContent {
public const string EventId = "m.space.parent";
[JsonPropertyName("via")]
diff --git a/LibMatrix/Helpers/MessageBuilder.cs b/LibMatrix/Helpers/MessageBuilder.cs
index 54de7ad..0ed0339 100644
--- a/LibMatrix/Helpers/MessageBuilder.cs
+++ b/LibMatrix/Helpers/MessageBuilder.cs
@@ -3,12 +3,12 @@ using LibMatrix.LegacyEvents.EventTypes.Spec;
namespace LibMatrix.Helpers;
public class MessageBuilder(string msgType = "m.text", string format = "org.matrix.custom.html") {
- private RoomMessageEventContent Content { get; set; } = new() {
+ private RoomMessageLegacyEventContent Content { get; set; } = new() {
MessageType = msgType,
Format = format
};
- public RoomMessageEventContent Build() => Content;
+ public RoomMessageLegacyEventContent Build() => Content;
public MessageBuilder WithBody(string body) {
Content.Body += body;
diff --git a/LibMatrix/Helpers/MessageFormatter.cs b/LibMatrix/Helpers/MessageFormatter.cs
index f234d8f..2c5021e 100644
--- a/LibMatrix/Helpers/MessageFormatter.cs
+++ b/LibMatrix/Helpers/MessageFormatter.cs
@@ -4,25 +4,25 @@ using LibMatrix.LegacyEvents.EventTypes.Spec;
namespace LibMatrix.Helpers;
public static class MessageFormatter {
- public static RoomMessageEventContent FormatError(string error) =>
+ public static RoomMessageLegacyEventContent FormatError(string error) =>
new(body: error, messageType: "m.text") {
FormattedBody = $"<font color=\"#EE4444\">{error}</font>",
Format = "org.matrix.custom.html"
};
- public static RoomMessageEventContent FormatException(string error, Exception e) =>
+ public static RoomMessageLegacyEventContent FormatException(string error, Exception e) =>
new(body: $"{error}: {e.Message}", messageType: "m.text") {
FormattedBody = $"<font color=\"#EE4444\">{error}: <pre><code>{e.Message}</code></pre></font>",
Format = "org.matrix.custom.html"
};
- public static RoomMessageEventContent FormatSuccess(string text) =>
+ public static RoomMessageLegacyEventContent FormatSuccess(string text) =>
new(body: text, messageType: "m.text") {
FormattedBody = $"<font color=\"#00FF00\">{text}</font>",
Format = "org.matrix.custom.html"
};
- public static RoomMessageEventContent FormatSuccessJson(string text, object data) =>
+ public static RoomMessageLegacyEventContent FormatSuccessJson(string text, object data) =>
new(body: text, messageType: "m.text") {
FormattedBody = $"<font color=\"#00FF00\">{text}: <pre><code>{data.ToJson(ignoreNull: true)}</code></pre></font>",
Format = "org.matrix.custom.html"
@@ -37,29 +37,29 @@ public static class MessageFormatter {
#region Extension functions
- public static RoomMessageEventContent ToMatrixMessage(this Exception e, string error) => FormatException(error, e);
+ public static RoomMessageLegacyEventContent ToMatrixMessage(this Exception e, string error) => FormatException(error, e);
#endregion
- public static RoomMessageEventContent FormatWarning(string warning) =>
+ public static RoomMessageLegacyEventContent FormatWarning(string warning) =>
new(body: warning, messageType: "m.text") {
FormattedBody = $"<font color=\"#FFFF00\">{warning}</font>",
Format = "org.matrix.custom.html"
};
- public static RoomMessageEventContent FormatWarningJson(string warning, object data) =>
+ public static RoomMessageLegacyEventContent FormatWarningJson(string warning, object data) =>
new(body: warning, messageType: "m.text") {
FormattedBody = $"<font color=\"#FFFF00\">{warning}: <pre><code>{data.ToJson(ignoreNull: true)}</code></pre></font>",
Format = "org.matrix.custom.html"
};
- public static RoomMessageEventContent Concat(this RoomMessageEventContent a, RoomMessageEventContent b) =>
+ public static RoomMessageLegacyEventContent Concat(this RoomMessageLegacyEventContent a, RoomMessageLegacyEventContent b) =>
new(body: $"{a.Body}{b.Body}", messageType: a.MessageType) {
FormattedBody = $"{a.FormattedBody}{b.FormattedBody}",
Format = a.Format
};
- public static RoomMessageEventContent ConcatLine(this RoomMessageEventContent a, RoomMessageEventContent b) =>
+ public static RoomMessageLegacyEventContent ConcatLine(this RoomMessageLegacyEventContent a, RoomMessageLegacyEventContent b) =>
new(body: $"{a.Body}\n{b.Body}", messageType: "m.text") {
FormattedBody = $"{a.FormattedBody}<br/>{b.FormattedBody}",
Format = "org.matrix.custom.html"
diff --git a/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs b/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs
index 86977ec..db76985 100644
--- a/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs
+++ b/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs
@@ -190,7 +190,7 @@ public class AuthenticatedHomeserverGeneric : RemoteHomeserver {
if (newProfile is null) return;
Console.WriteLine($"Updating profile for {WhoAmI.UserId} to {newProfile.ToJson(ignoreNull: true)} (preserving room profiles: {preserveCustomRoomProfile})");
var oldProfile = await GetProfileAsync(WhoAmI.UserId!);
- Dictionary<string, RoomMemberEventContent> expectedRoomProfiles = new();
+ Dictionary<string, RoomMemberLegacyEventContent> expectedRoomProfiles = new();
var syncHelper = new SyncHelper(this) {
Filter = new SyncFilter {
AccountData = new SyncFilter.EventFilter() {
@@ -209,7 +209,7 @@ public class AuthenticatedHomeserverGeneric : RemoteHomeserver {
targetSyncCount = rooms.Count;
await foreach (var (roomId, currentRoomProfile) in roomProfiles)
try {
- // var currentRoomProfile = await room.GetStateAsync<RoomMemberEventContent>("m.room.member", WhoAmI.UserId!);
+ // var currentRoomProfile = await room.GetStateAsync<RoomMemberLegacyEventContent>("m.room.member", WhoAmI.UserId!);
//build new profiles
if (currentRoomProfile.DisplayName == oldProfile.DisplayName) currentRoomProfile.DisplayName = newProfile.DisplayName;
@@ -243,7 +243,7 @@ public class AuthenticatedHomeserverGeneric : RemoteHomeserver {
foreach (var (roomId, roomData) in sync.Rooms.Join)
if (roomData.State is { Events.Count: > 0 }) {
var incommingRoomProfile =
- roomData.State?.Events?.FirstOrDefault(x => x.Type == "m.room.member" && x.StateKey == WhoAmI.UserId)?.TypedContent as RoomMemberEventContent;
+ roomData.State?.Events?.FirstOrDefault(x => x.Type == "m.room.member" && x.StateKey == WhoAmI.UserId)?.TypedContent as RoomMemberLegacyEventContent;
if (incommingRoomProfile is null) continue;
if (!expectedRoomProfiles.ContainsKey(roomId)) continue;
var targetRoomProfileOverride = expectedRoomProfiles[roomId];
@@ -276,7 +276,7 @@ public class AuthenticatedHomeserverGeneric : RemoteHomeserver {
}
}
- public async IAsyncEnumerable<KeyValuePair<string, RoomMemberEventContent>> GetRoomProfilesAsync() {
+ public async IAsyncEnumerable<KeyValuePair<string, RoomMemberLegacyEventContent>> GetRoomProfilesAsync() {
var rooms = await GetJoinedRooms();
var results = rooms.Select(GetOwnRoomProfileWithIdAsync).ToAsyncEnumerable();
await foreach (var res in results) yield return res;
@@ -295,8 +295,8 @@ public class AuthenticatedHomeserverGeneric : RemoteHomeserver {
#region Room Profile Utility
- private async Task<KeyValuePair<string, RoomMemberEventContent>> GetOwnRoomProfileWithIdAsync(GenericRoom room) =>
- new(room.RoomId, await room.GetStateAsync<RoomMemberEventContent>("m.room.member", WhoAmI.UserId!));
+ private async Task<KeyValuePair<string, RoomMemberLegacyEventContent>> GetOwnRoomProfileWithIdAsync(GenericRoom room) =>
+ new(room.RoomId, await room.GetStateAsync<RoomMemberLegacyEventContent>("m.room.member", WhoAmI.UserId!));
#endregion
diff --git a/LibMatrix/LegacyMatrixEvent.cs b/LibMatrix/LegacyMatrixEvent.cs
index 1c1ebf3..5433da3 100644
--- a/LibMatrix/LegacyMatrixEvent.cs
+++ b/LibMatrix/LegacyMatrixEvent.cs
@@ -13,12 +13,12 @@ using LibMatrix.Extensions;
namespace LibMatrix;
public class LegacyMatrixEvent {
- public static FrozenSet<Type> KnownStateEventTypes { get; } = new ClassCollector<EventContent>().ResolveFromAllAccessibleAssemblies().ToFrozenSet();
+ public static FrozenSet<Type> KnownStateEventTypes { get; } = new ClassCollector<LegacyEventContent>().ResolveFromAllAccessibleAssemblies().ToFrozenSet();
public static FrozenDictionary<string, Type> KnownStateEventTypesByName { get; } = KnownStateEventTypes.Aggregate(
new Dictionary<string, Type>(),
(dict, type) => {
- var attrs = type.GetCustomAttributes<MatrixEventAttribute>();
+ var attrs = type.GetCustomAttributes<LegacyMatrixEventAttribute>();
foreach (var attr in attrs) {
if (dict.TryGetValue(attr.EventName, out var existing))
Console.WriteLine($"Duplicate event type '{attr.EventName}' registered for types '{existing.Name}' and '{type.Name}'");
@@ -29,13 +29,13 @@ public class LegacyMatrixEvent {
}).OrderBy(x => x.Key).ToFrozenDictionary();
public static Type GetStateEventType(string? type) =>
- string.IsNullOrWhiteSpace(type) ? typeof(UnknownEventContent) : KnownStateEventTypesByName.GetValueOrDefault(type) ?? typeof(UnknownEventContent);
+ string.IsNullOrWhiteSpace(type) ? typeof(UnknownLegacyEventContent) : KnownStateEventTypesByName.GetValueOrDefault(type) ?? typeof(UnknownLegacyEventContent);
[JsonIgnore]
public Type MappedType => GetStateEventType(Type);
[JsonIgnore]
- public bool IsLegacyType => MappedType.GetCustomAttributes<MatrixEventAttribute>().FirstOrDefault(x => x.EventName == Type)?.Legacy ?? false;
+ public bool IsLegacyType => MappedType.GetCustomAttributes<LegacyMatrixEventAttribute>().FirstOrDefault(x => x.EventName == Type)?.Legacy ?? false;
[JsonIgnore]
public string FriendlyTypeName => MappedType.GetFriendlyNameOrNull() ?? Type;
@@ -53,16 +53,16 @@ public class LegacyMatrixEvent {
[JsonIgnore]
[SuppressMessage("ReSharper", "PropertyCanBeMadeInitOnly.Global")]
- public EventContent? TypedContent {
+ public LegacyEventContent? TypedContent {
get {
// if (Type == "m.receipt") {
// return null;
// }
try {
var mappedType = GetStateEventType(Type);
- if (mappedType == typeof(UnknownEventContent))
+ if (mappedType == typeof(UnknownLegacyEventContent))
Console.WriteLine($"Warning: unknown event type '{Type}'");
- var deserialisedContent = (EventContent)RawContent.Deserialize(mappedType, TypedContentSerializerOptions)!;
+ var deserialisedContent = (LegacyEventContent)RawContent.Deserialize(mappedType, TypedContentSerializerOptions)!;
return deserialisedContent;
}
catch (JsonException e) {
diff --git a/LibMatrix/Responses/CreateRoomRequest.cs b/LibMatrix/Responses/CreateRoomRequest.cs
index 6919b84..cae2a04 100644
--- a/LibMatrix/Responses/CreateRoomRequest.cs
+++ b/LibMatrix/Responses/CreateRoomRequest.cs
@@ -38,7 +38,7 @@ public class CreateRoomRequest {
public string? Visibility { get; set; }
[JsonPropertyName("power_level_content_override")]
- public RoomPowerLevelEventContent? PowerLevelContentOverride { get; set; } = null!;
+ public RoomPowerLevelLegacyEventContent? PowerLevelContentOverride { get; set; } = null!;
[JsonPropertyName("creation_content")]
public JsonObject CreationContent { get; set; } = new();
@@ -57,10 +57,10 @@ public class CreateRoomRequest {
InitialState.Add(stateEvent = new LegacyMatrixEvent {
Type = eventType,
StateKey = eventKey,
- TypedContent = (EventContent)Activator.CreateInstance(
+ TypedContent = (LegacyEventContent)Activator.CreateInstance(
LegacyMatrixEvent.KnownStateEventTypes.FirstOrDefault(x =>
- x.GetCustomAttributes<MatrixEventAttribute>()?
- .Any(y => y.EventName == eventType) ?? false) ?? typeof(UnknownEventContent)
+ x.GetCustomAttributes<LegacyMatrixEventAttribute>()?
+ .Any(y => y.EventName == eventType) ?? false) ?? typeof(UnknownLegacyEventContent)
)!
});
@@ -89,7 +89,7 @@ public class CreateRoomRequest {
Name = name ?? "New public Room",
Visibility = "public",
CreationContent = new JsonObject(),
- PowerLevelContentOverride = new RoomPowerLevelEventContent {
+ PowerLevelContentOverride = new RoomPowerLevelLegacyEventContent {
EventsDefault = 0,
UsersDefault = 0,
Kick = 50,
@@ -97,7 +97,7 @@ public class CreateRoomRequest {
Invite = 25,
StateDefault = 10,
Redact = 50,
- NotificationsPl = new RoomPowerLevelEventContent.NotificationsPL {
+ NotificationsPl = new RoomPowerLevelLegacyEventContent.NotificationsPL {
Room = 10
},
Events = new Dictionary<string, long> {
@@ -129,7 +129,7 @@ public class CreateRoomRequest {
Name = name ?? "New private Room",
Visibility = "private",
CreationContent = new JsonObject(),
- PowerLevelContentOverride = new RoomPowerLevelEventContent {
+ PowerLevelContentOverride = new RoomPowerLevelLegacyEventContent {
EventsDefault = 0,
UsersDefault = 0,
Kick = 50,
@@ -137,7 +137,7 @@ public class CreateRoomRequest {
Invite = 25,
StateDefault = 10,
Redact = 50,
- NotificationsPl = new RoomPowerLevelEventContent.NotificationsPL {
+ NotificationsPl = new RoomPowerLevelLegacyEventContent.NotificationsPL {
Room = 10
},
Events = new Dictionary<string, long> {
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<string?> GetNameAsync() => (await GetStateOrNullAsync<RoomNameEventContent>("m.room.name"))?.Name;
+ public async Task<string?> GetNameAsync() => (await GetStateOrNullAsync<RoomNameLegacyEventContent>("m.room.name"))?.Name;
public async Task<RoomIdResponse> JoinAsync(string[]? homeservers = null, string? reason = null, bool checkIfAlreadyMember = true) {
if (checkIfAlreadyMember)
@@ -279,42 +279,42 @@ public class GenericRoom {
#region Utility shortcuts
- public Task<EventIdResponse> SendMessageEventAsync(RoomMessageEventContent content) =>
+ public Task<EventIdResponse> SendMessageEventAsync(RoomMessageLegacyEventContent content) =>
SendTimelineEventAsync("m.room.message", content);
public async Task<List<string>?> GetAliasesAsync() {
- var res = await GetStateAsync<RoomAliasEventContent>("m.room.aliases");
+ var res = await GetStateAsync<RoomAliasLegacyEventContent>("m.room.aliases");
return res.Aliases;
}
- public Task<RoomCanonicalAliasEventContent?> GetCanonicalAliasAsync() =>
- GetStateAsync<RoomCanonicalAliasEventContent>("m.room.canonical_alias");
+ public Task<RoomCanonicalAliasLegacyEventContent?> GetCanonicalAliasAsync() =>
+ GetStateAsync<RoomCanonicalAliasLegacyEventContent>("m.room.canonical_alias");
- public Task<RoomTopicEventContent?> GetTopicAsync() =>
- GetStateAsync<RoomTopicEventContent>("m.room.topic");
+ public Task<RoomTopicLegacyEventContent?> GetTopicAsync() =>
+ GetStateAsync<RoomTopicLegacyEventContent>("m.room.topic");
- public Task<RoomAvatarEventContent?> GetAvatarUrlAsync() =>
- GetStateAsync<RoomAvatarEventContent>("m.room.avatar");
+ public Task<RoomAvatarLegacyEventContent?> GetAvatarUrlAsync() =>
+ GetStateAsync<RoomAvatarLegacyEventContent>("m.room.avatar");
- public Task<RoomJoinRulesEventContent?> GetJoinRuleAsync() =>
- GetStateAsync<RoomJoinRulesEventContent>("m.room.join_rules");
+ public Task<RoomJoinRulesLegacyEventContent?> GetJoinRuleAsync() =>
+ GetStateAsync<RoomJoinRulesLegacyEventContent>("m.room.join_rules");
- public Task<RoomHistoryVisibilityEventContent?> GetHistoryVisibilityAsync() =>
- GetStateAsync<RoomHistoryVisibilityEventContent?>("m.room.history_visibility");
+ public Task<RoomHistoryVisibilityLegacyEventContent?> GetHistoryVisibilityAsync() =>
+ GetStateAsync<RoomHistoryVisibilityLegacyEventContent?>("m.room.history_visibility");
- public Task<RoomGuestAccessEventContent?> GetGuestAccessAsync() =>
- GetStateAsync<RoomGuestAccessEventContent>("m.room.guest_access");
+ public Task<RoomGuestAccessLegacyEventContent?> GetGuestAccessAsync() =>
+ GetStateAsync<RoomGuestAccessLegacyEventContent>("m.room.guest_access");
- public Task<RoomCreateEventContent?> GetCreateEventAsync() =>
- GetStateAsync<RoomCreateEventContent>("m.room.create");
+ public Task<RoomCreateLegacyEventContent?> GetCreateEventAsync() =>
+ GetStateAsync<RoomCreateLegacyEventContent>("m.room.create");
public async Task<string?> GetRoomType() {
- var res = await GetStateAsync<RoomCreateEventContent>("m.room.create");
+ var res = await GetStateAsync<RoomCreateLegacyEventContent>("m.room.create");
return res.Type;
}
- public Task<RoomPowerLevelEventContent?> GetPowerLevelsAsync() =>
- GetStateAsync<RoomPowerLevelEventContent>("m.room.power_levels");
+ public Task<RoomPowerLevelLegacyEventContent?> GetPowerLevelsAsync() =>
+ GetStateAsync<RoomPowerLevelLegacyEventContent>("m.room.power_levels");
public async Task<string> 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<RoomMemberEventContent>("m.room.member", userId) is not null)
+ if (skipExisting && await GetStateAsync<RoomMemberLegacyEventContent>("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<EventIdResponse>();
- public async Task<EventIdResponse> SendTimelineEventAsync(string eventType, TimelineEventContent content) {
+ public async Task<EventIdResponse> 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<EventIdResponse?> 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
}
diff --git a/LibMatrix/Utilities/CommonSyncFilters.cs b/LibMatrix/Utilities/CommonSyncFilters.cs
index 401850c..d07c225 100644
--- a/LibMatrix/Utilities/CommonSyncFilters.cs
+++ b/LibMatrix/Utilities/CommonSyncFilters.cs
@@ -37,11 +37,11 @@ public static class CommonSyncFilters {
Ephemeral = new SyncFilter.RoomFilter.StateFilter(rooms: []),
State = new SyncFilter.RoomFilter.StateFilter {
Types = new List<string> {
- RoomCreateEventContent.EventId,
- RoomNameEventContent.EventId,
- RoomAvatarEventContent.EventId,
- MjolnirShortcodeEventContent.EventId,
- RoomPowerLevelEventContent.EventId
+ RoomCreateLegacyEventContent.EventId,
+ RoomNameLegacyEventContent.EventId,
+ RoomAvatarLegacyEventContent.EventId,
+ MjolnirShortcodeLegacyEventContent.EventId,
+ RoomPowerLevelLegacyEventContent.EventId
},
LazyLoadMembers = true, IncludeRedundantMembers = false
},
@@ -57,8 +57,8 @@ public static class CommonSyncFilters {
Ephemeral = new SyncFilter.RoomFilter.StateFilter(rooms: []),
State = new SyncFilter.RoomFilter.StateFilter {
Types = new List<string> {
- SpaceChildEventContent.EventId,
- SpaceParentEventContent.EventId
+ SpaceChildLegacyEventContent.EventId,
+ SpaceParentLegacyEventContent.EventId
},
LazyLoadMembers = true, IncludeRedundantMembers = false
},
@@ -74,7 +74,7 @@ public static class CommonSyncFilters {
Ephemeral = new SyncFilter.RoomFilter.StateFilter(rooms: []),
State = new SyncFilter.RoomFilter.StateFilter {
Types = new List<string> {
- RoomMemberEventContent.EventId
+ RoomMemberLegacyEventContent.EventId
},
LazyLoadMembers = true, IncludeRedundantMembers = false,
Senders = ["@me"]
diff --git a/Tests/TestDataGenerator/Bot/DataFetcher.cs b/Tests/TestDataGenerator/Bot/DataFetcher.cs
index 1367e1c..f80d10a 100644
--- a/Tests/TestDataGenerator/Bot/DataFetcher.cs
+++ b/Tests/TestDataGenerator/Bot/DataFetcher.cs
@@ -26,19 +26,19 @@ public class DataFetcher(AuthenticatedHomeserverGeneric hs, ILogger<DataFetcher>
Directory.GetFiles("bot_data/cache").ToList().ForEach(File.Delete);
_logRoom = hs.GetRoom(botConfiguration.LogRoom!);
- await _logRoom.SendMessageEventAsync(new RoomMessageEventContent(body: "Test data collector started!"));
- await _logRoom.SendMessageEventAsync(new RoomMessageEventContent(body: "Fetching rooms..."));
+ await _logRoom.SendMessageEventAsync(new RoomMessageLegacyEventContent(body: "Test data collector started!"));
+ await _logRoom.SendMessageEventAsync(new RoomMessageLegacyEventContent(body: "Fetching rooms..."));
var rooms = await hs.GetJoinedRooms();
- await _logRoom.SendMessageEventAsync(new RoomMessageEventContent(body: $"Fetched {rooms.Count} rooms!"));
+ await _logRoom.SendMessageEventAsync(new RoomMessageLegacyEventContent(body: $"Fetched {rooms.Count} rooms!"));
- await _logRoom.SendMessageEventAsync(new RoomMessageEventContent(body: "Fetching room data..."));
+ await _logRoom.SendMessageEventAsync(new RoomMessageLegacyEventContent(body: "Fetching room data..."));
var roomAliasTasks = rooms.Select(room => room.GetCanonicalAliasAsync()).ToAsyncEnumerable();
List<Task<(string, string)>> aliasResolutionTasks = new();
await foreach (var @event in roomAliasTasks)
if (@event?.Alias != null) {
- await _logRoom.SendMessageEventAsync(new RoomMessageEventContent(body: $"Fetched room alias {@event.Alias}!"));
+ await _logRoom.SendMessageEventAsync(new RoomMessageLegacyEventContent(body: $"Fetched room alias {@event.Alias}!"));
aliasResolutionTasks.Add(Task.Run(async () => {
var alias = await hs.ResolveRoomAliasAsync(@event.Alias);
return (@event.Alias, alias.RoomId);
@@ -47,7 +47,7 @@ public class DataFetcher(AuthenticatedHomeserverGeneric hs, ILogger<DataFetcher>
var aliasResolutionTaskEnumerator = aliasResolutionTasks.ToAsyncEnumerable();
await foreach (var result in aliasResolutionTaskEnumerator)
- await _logRoom.SendMessageEventAsync(new RoomMessageEventContent(body: $"Resolved room alias {result.Item1} to {result.Item2}!"));
+ await _logRoom.SendMessageEventAsync(new RoomMessageLegacyEventContent(body: $"Resolved room alias {result.Item1} to {result.Item2}!"));
}
/// <summary>Triggered when the application host is performing a graceful shutdown.</summary>
diff --git a/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs b/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs
index 6348085..95af553 100644
--- a/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs
+++ b/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs
@@ -7,7 +7,7 @@ using LibMatrix.LegacyEvents.EventTypes;
// var asm = Assembly.LoadFrom(binary);
File.Delete("EventSerializerContexts.g.cs");
var stream = File.OpenWrite("EventSerializerContexts.g.cs");
-var eventContentTypes = new ClassCollector<EventContent>().ResolveFromAllAccessibleAssemblies();
+var eventContentTypes = new ClassCollector<LegacyEventContent>().ResolveFromAllAccessibleAssemblies();
stream.WriteString("using System.Text.Json.Serialization;\n");
diff --git a/Utilities/LibMatrix.Utilities.Bot/Commands/AliassesCommand.cs b/Utilities/LibMatrix.Utilities.Bot/Commands/AliassesCommand.cs
index 68fc884..aaa61ed 100644
--- a/Utilities/LibMatrix.Utilities.Bot/Commands/AliassesCommand.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/Commands/AliassesCommand.cs
@@ -19,7 +19,7 @@ public class AliassesCommand(IServiceProvider services) : ICommand {
var commands = services.GetServices<ICommand>().Where(x => !x.Unlisted).ToList();
foreach (var command in commands) sb.AppendLine($"- {command.Name}: {command.Description}");
- await ctx.Room.SendMessageEventAsync(new RoomMessageEventContent("m.notice", sb.ToString()));
+ await ctx.Room.SendMessageEventAsync(new RoomMessageLegacyEventContent("m.notice", sb.ToString()));
var msb = new MessageBuilder("m.notice");
msb.WithHtmlTag("table", tb => {
diff --git a/Utilities/LibMatrix.Utilities.Bot/Commands/PingCommand.cs b/Utilities/LibMatrix.Utilities.Bot/Commands/PingCommand.cs
index 04d5124..15a1ea1 100644
--- a/Utilities/LibMatrix.Utilities.Bot/Commands/PingCommand.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/Commands/PingCommand.cs
@@ -9,5 +9,5 @@ public class PingCommand : ICommand {
public string Description { get; } = "Pong!";
public bool Unlisted { get; }
- public async Task Invoke(CommandContext ctx) => await ctx.Room.SendMessageEventAsync(new RoomMessageEventContent(body: "pong!"));
+ public async Task Invoke(CommandContext ctx) => await ctx.Room.SendMessageEventAsync(new RoomMessageLegacyEventContent(body: "pong!"));
}
\ No newline at end of file
diff --git a/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs b/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs
index c171dfe..1b69c89 100644
--- a/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/Interfaces/CommandContext.cs
@@ -9,7 +9,7 @@ public class CommandContext {
public required LegacyMatrixEventResponse MessageEvent { get; set; }
public string MessageContentWithoutReply =>
- (MessageEvent.TypedContent as RoomMessageEventContent)!
+ (MessageEvent.TypedContent as RoomMessageLegacyEventContent)!
.Body.Split('\n')
.SkipWhile(x => x.StartsWith(">"))
.Aggregate((x, y) => $"{x}\n{y}");
@@ -18,7 +18,7 @@ public class CommandContext {
public required string[] Args;
public required AuthenticatedHomeserverGeneric Homeserver { get; set; }
- public async Task<EventIdResponse> Reply(RoomMessageEventContent content) => await Room.SendMessageEventAsync(content);
+ public async Task<EventIdResponse> Reply(RoomMessageLegacyEventContent content) => await Room.SendMessageEventAsync(content);
}
public class CommandResult {
diff --git a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
index feb174b..46638e4 100644
--- a/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
+++ b/Utilities/LibMatrix.Utilities.Bot/Services/CommandListenerHostedService.cs
@@ -61,7 +61,7 @@ public class CommandListenerHostedService : IHostedService {
try {
var room = _hs.GetRoom(@event.RoomId);
// _logger.LogInformation(eventResponse.ToJson(indent: false));
- if (@event is { Type: "m.room.message", TypedContent: RoomMessageEventContent message })
+ if (@event is { Type: "m.room.message", TypedContent: RoomMessageLegacyEventContent message })
if (message is { MessageType: "m.text" }) {
var usedPrefix = await GetUsedPrefix(@event);
if (usedPrefix is null) return;
@@ -89,12 +89,12 @@ public class CommandListenerHostedService : IHostedService {
}
private async Task<string?> GetUsedPrefix(LegacyMatrixEventResponse evt) {
- var messageContent = evt.TypedContent as RoomMessageEventContent;
+ var messageContent = evt.TypedContent as RoomMessageLegacyEventContent;
var message = messageContent!.BodyWithoutReplyFallback;
var prefix = _config.Prefixes.OrderByDescending(x => x.Length).FirstOrDefault(message.StartsWith);
if (prefix is null && _config.MentionPrefix) {
var profile = await _hs.GetProfileAsync(_hs.WhoAmI.UserId);
- var roomProfile = await _hs.GetRoom(evt.RoomId!).GetStateAsync<RoomMemberEventContent>(RoomMemberEventContent.EventId, _hs.WhoAmI.UserId);
+ var roomProfile = await _hs.GetRoom(evt.RoomId!).GetStateAsync<RoomMemberLegacyEventContent>(RoomMemberLegacyEventContent.EventId, _hs.WhoAmI.UserId);
if (message.StartsWith(_hs.WhoAmI.UserId + ": ")) prefix = profile.DisplayName + ": "; // `@bot:server.xyz: `
else if (message.StartsWith(_hs.WhoAmI.UserId + " ")) prefix = profile.DisplayName + " "; // `@bot:server.xyz `
else if (!string.IsNullOrWhiteSpace(roomProfile?.DisplayName) && message.StartsWith(roomProfile.DisplayName + ": "))
@@ -109,7 +109,7 @@ public class CommandListenerHostedService : IHostedService {
}
private async Task<CommandResult> InvokeCommand(LegacyMatrixEventResponse evt, string usedPrefix) {
- var message = evt.TypedContent as RoomMessageEventContent;
+ var message = evt.TypedContent as RoomMessageLegacyEventContent;
var room = _hs.GetRoom(evt.RoomId!);
var commandWithoutPrefix = message.BodyWithoutReplyFallback[usedPrefix.Length..].Trim();
@@ -124,7 +124,7 @@ public class CommandListenerHostedService : IHostedService {
var command = _commands.SingleOrDefault(x => x.Name == commandWithoutPrefix.Split(' ')[0] || x.Aliases?.Contains(commandWithoutPrefix.Split(' ')[0]) == true);
if (command == null) {
await room.SendMessageEventAsync(
- new RoomMessageEventContent("m.notice", $"Command \"{ctx.CommandName}\" not found!"));
+ new RoomMessageLegacyEventContent("m.notice", $"Command \"{ctx.CommandName}\" not found!"));
return new() {
Success = false,
Result = CommandResult.CommandResultType.Failure_InvalidCommand,
@@ -153,7 +153,7 @@ public class CommandListenerHostedService : IHostedService {
Success = false
};
// await room.SendMessageEventAsync(
- // new RoomMessageEventContent("m.notice", "You do not have permission to run this command!"));
+ // new RoomMessageLegacyEventContent("m.notice", "You do not have permission to run this command!"));
return new CommandResult() {
Context = ctx,
@@ -176,8 +176,8 @@ public class CommandListenerHostedService : IHostedService {
var room = res.Context.Room;
var msg = res.Result switch {
CommandResult.CommandResultType.Failure_Exception => MessageFormatter.FormatException("An error occurred during the execution of this command", res.Exception!),
- CommandResult.CommandResultType.Failure_NoPermission => new RoomMessageEventContent("m.notice", "You do not have permission to run this command!"),
- CommandResult.CommandResultType.Failure_InvalidCommand => new RoomMessageEventContent("m.notice", $"Command \"{res.Context.CommandName}\" not found!"),
+ CommandResult.CommandResultType.Failure_NoPermission => new RoomMessageLegacyEventContent("m.notice", "You do not have permission to run this command!"),
+ CommandResult.CommandResultType.Failure_InvalidCommand => new RoomMessageLegacyEventContent("m.notice", $"Command \"{res.Context.CommandName}\" not found!"),
_ => throw new ArgumentOutOfRangeException()
};
|