diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-11-09 07:37:10 +0100 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-11-09 07:37:10 +0100 |
commit | aaa3204704b677b59b60dd2719080ead5a0c1274 (patch) | |
tree | 552805fd7e417d3f51bef1da0a51d34c0f2d0036 | |
parent | Cleanup, fixes, fix proxy support (diff) | |
download | LibMatrix-bak-aaa3204704b677b59b60dd2719080ead5a0c1274.tar.xz |
State vs Timeline events
26 files changed, 29 insertions, 26 deletions
diff --git a/LibMatrix/EventTypes/Common/MjolnirShortcodeEventContent.cs b/LibMatrix/EventTypes/Common/MjolnirShortcodeEventContent.cs index 374ddd4..a09a393 100644 --- a/LibMatrix/EventTypes/Common/MjolnirShortcodeEventContent.cs +++ b/LibMatrix/EventTypes/Common/MjolnirShortcodeEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Common; [MatrixEvent(EventName = "org.matrix.mjolnir.shortcode")] -public class MjolnirShortcodeEventContent : EventContent { +public class MjolnirShortcodeEventContent : TimelineEventContent { [JsonPropertyName("shortcode")] public string? Shortcode { get; set; } } diff --git a/LibMatrix/EventTypes/Common/RoomEmotesEventContent.cs b/LibMatrix/EventTypes/Common/RoomEmotesEventContent.cs index 2e824ca..8d05a2e 100644 --- a/LibMatrix/EventTypes/Common/RoomEmotesEventContent.cs +++ b/LibMatrix/EventTypes/Common/RoomEmotesEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Common; [MatrixEvent(EventName = "im.ponies.room_emotes")] -public class RoomEmotesEventContent : EventContent { +public class RoomEmotesEventContent : TimelineEventContent { [JsonPropertyName("emoticons")] public Dictionary<string, EmoticonData>? Emoticons { get; set; } diff --git a/LibMatrix/EventTypes/Spec/Ephemeral/PresenceStateEventContent.cs b/LibMatrix/EventTypes/Spec/Ephemeral/PresenceStateEventContent.cs index 51cfdef..3e4a5cd 100644 --- a/LibMatrix/EventTypes/Spec/Ephemeral/PresenceStateEventContent.cs +++ b/LibMatrix/EventTypes/Spec/Ephemeral/PresenceStateEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.presence")] -public class PresenceEventContent : EventContent { +public class PresenceEventContent : TimelineEventContent { [JsonPropertyName("presence")] public string Presence { get; set; } [JsonPropertyName("last_active_ago")] diff --git a/LibMatrix/EventTypes/Spec/Ephemeral/RoomTypingEventContent.cs b/LibMatrix/EventTypes/Spec/Ephemeral/RoomTypingEventContent.cs index 0ff2cee..661cf63 100644 --- a/LibMatrix/EventTypes/Spec/Ephemeral/RoomTypingEventContent.cs +++ b/LibMatrix/EventTypes/Spec/Ephemeral/RoomTypingEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.typing")] -public class RoomTypingEventContent : EventContent { +public class RoomTypingEventContent : TimelineEventContent { [JsonPropertyName("user_ids")] public string[]? UserIds { get; set; } } diff --git a/LibMatrix/EventTypes/Spec/RoomMessageEventContent.cs b/LibMatrix/EventTypes/Spec/RoomMessageEventContent.cs index 4118785..1938b3e 100644 --- a/LibMatrix/EventTypes/Spec/RoomMessageEventContent.cs +++ b/LibMatrix/EventTypes/Spec/RoomMessageEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec; [MatrixEvent(EventName = "m.room.message")] -public class RoomMessageEventContent : EventContent { +public class RoomMessageEventContent : TimelineEventContent { public RoomMessageEventContent(string? messageType = "m.notice", string? body = null) { MessageType = messageType; Body = body; diff --git a/LibMatrix/EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs b/LibMatrix/EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs index 74bbb71..63f148c 100644 --- a/LibMatrix/EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs @@ -6,7 +6,7 @@ namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.policy.rule.user")] [MatrixEvent(EventName = "m.policy.rule.server")] [MatrixEvent(EventName = "org.matrix.mjolnir.rule.server")] -public class PolicyRuleEventContent : EventContent { +public class PolicyRuleEventContent : TimelineEventContent { /// <summary> /// Entity this ban applies to, can use * and ? as globs. /// </summary> diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomAliasEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomAliasEventContent.cs index b7e54ad..28d525c 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomAliasEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomAliasEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.room.alias")] -public class RoomAliasEventContent : EventContent { +public class RoomAliasEventContent : TimelineEventContent { [JsonPropertyName("aliases")] public List<string>? Aliases { get; set; } } diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomAvatarEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomAvatarEventContent.cs index 5513904..fb05b2a 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomAvatarEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomAvatarEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = EventId)] -public class RoomAvatarEventContent : EventContent { +public class RoomAvatarEventContent : TimelineEventContent { public const string EventId = "m.room.avatar"; [JsonPropertyName("url")] public string? Url { get; set; } diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasEventContent.cs index b677507..a5dec35 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomCanonicalAliasEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.room.canonical_alias")] -public class RoomCanonicalAliasEventContent : EventContent { +public class RoomCanonicalAliasEventContent : TimelineEventContent { [JsonPropertyName("alias")] public string? Alias { get; set; } [JsonPropertyName("alt_aliases")] diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs index 46c4000..41145de 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomCreateEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = EventId)] -public class RoomCreateEventContent : EventContent { +public class RoomCreateEventContent : TimelineEventContent { public const string EventId = "m.room.create"; [JsonPropertyName("room_version")] diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomEncryptionEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomEncryptionEventContent.cs index 774b1eb..a3627f2 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomEncryptionEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomEncryptionEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.room.encryption")] -public class RoomEncryptionEventContent : EventContent { +public class RoomEncryptionEventContent : TimelineEventContent { [JsonPropertyName("algorithm")] public string? Algorithm { get; set; } [JsonPropertyName("rotation_period_ms")] diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomGuestAccessEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomGuestAccessEventContent.cs index abc9ffe..5bad649 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomGuestAccessEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomGuestAccessEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.room.guest_access")] -public class RoomGuestAccessEventContent : EventContent { +public class RoomGuestAccessEventContent : TimelineEventContent { [JsonPropertyName("guest_access")] public string GuestAccess { get; set; } diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityEventContent.cs index 578a866..8f5c7f1 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomHistoryVisibilityEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.room.history_visibility")] -public class RoomHistoryVisibilityEventContent : EventContent { +public class RoomHistoryVisibilityEventContent : TimelineEventContent { [JsonPropertyName("history_visibility")] public string HistoryVisibility { get; set; } } diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs index 1f673fb..2db9e60 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.room.join_rules")] -public class RoomJoinRulesEventContent : EventContent { +public class RoomJoinRulesEventContent : TimelineEventContent { private static string Public = "public"; private static string Invite = "invite"; private static string Knock = "knock"; diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs index da9ab0a..698315e 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomMemberEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = EventId)] -public class RoomMemberEventContent : EventContent { +public class RoomMemberEventContent : TimelineEventContent { public const string EventId = "m.room.member"; [JsonPropertyName("reason")] diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomNameEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomNameEventContent.cs index ea174d7..3eacd44 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomNameEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomNameEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = EventId)] -public class RoomNameEventContent : EventContent { +public class RoomNameEventContent : TimelineEventContent { public const string EventId = "m.room.name"; [JsonPropertyName("name")] diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomPinnedEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomPinnedEventContent.cs index ba73a5e..11fe208 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomPinnedEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomPinnedEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.room.pinned_events")] -public class RoomPinnedEventContent : EventContent { +public class RoomPinnedEventContent : TimelineEventContent { [JsonPropertyName("pinned")] public string[]? PinnedEvents { get; set; } } diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs index a1bf517..6d01b8c 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = EventId)] -public class RoomPowerLevelEventContent : EventContent { +public class RoomPowerLevelEventContent : TimelineEventContent { public const string EventId = "m.room.power_levels"; [JsonPropertyName("ban")] diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomServerACLEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomServerACLEventContent.cs index 1a444fb..cbd2241 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomServerACLEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomServerACLEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.room.server_acl")] -public class RoomServerACLEventContent : EventContent { +public class RoomServerACLEventContent : TimelineEventContent { [JsonPropertyName("allow")] public List<string> Allow { get; set; } // = null!; diff --git a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomTopicEventContent.cs b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomTopicEventContent.cs index 5623865..866eecf 100644 --- a/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomTopicEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/RoomInfo/RoomTopicEventContent.cs @@ -5,7 +5,7 @@ namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.room.topic")] [MatrixEvent(EventName = "org.matrix.msc3765.topic", Legacy = true)] -public class RoomTopicEventContent : EventContent { +public class RoomTopicEventContent : TimelineEventContent { [JsonPropertyName("topic")] public string? Topic { get; set; } } diff --git a/LibMatrix/EventTypes/Spec/State/Space/SpaceChildEventContent.cs b/LibMatrix/EventTypes/Spec/State/Space/SpaceChildEventContent.cs index c52557c..82f4b7f 100644 --- a/LibMatrix/EventTypes/Spec/State/Space/SpaceChildEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/Space/SpaceChildEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.space.child")] -public class SpaceChildEventContent : EventContent { +public class SpaceChildEventContent : TimelineEventContent { [JsonPropertyName("auto_join")] public bool? AutoJoin { get; set; } [JsonPropertyName("via")] diff --git a/LibMatrix/EventTypes/Spec/State/Space/SpaceParentEventContent.cs b/LibMatrix/EventTypes/Spec/State/Space/SpaceParentEventContent.cs index 49f2901..887e91c 100644 --- a/LibMatrix/EventTypes/Spec/State/Space/SpaceParentEventContent.cs +++ b/LibMatrix/EventTypes/Spec/State/Space/SpaceParentEventContent.cs @@ -4,7 +4,7 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes.Spec.State; [MatrixEvent(EventName = "m.space.parent")] -public class SpaceParentEventContent : EventContent { +public class SpaceParentEventContent : TimelineEventContent { [JsonPropertyName("via")] public string[]? Via { get; set; } diff --git a/LibMatrix/EventTypes/UnknownStateEventContent.cs b/LibMatrix/EventTypes/UnknownStateEventContent.cs index 9a276c8..c47dc99 100644 --- a/LibMatrix/EventTypes/UnknownStateEventContent.cs +++ b/LibMatrix/EventTypes/UnknownStateEventContent.cs @@ -2,6 +2,6 @@ using LibMatrix.Interfaces; namespace LibMatrix.EventTypes; -public class UnknownEventContent : EventContent { +public class UnknownEventContent : TimelineEventContent { } diff --git a/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs b/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs index 37696eb..e4b7483 100644 --- a/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs +++ b/LibMatrix/Homeservers/AuthenticatedHomeserverGeneric.cs @@ -48,7 +48,7 @@ public class AuthenticatedHomeserverGeneric(string serverName, string accessToke return instance; } - public WhoAmIResponse? WhoAmI { get; set; } + public WhoAmIResponse WhoAmI { get; set; } public string? UserId => WhoAmI?.UserId; public string? UserLocalpart => UserId?.Split(":")[0][1..]; public string? ServerName => UserId?.Split(":", 2)[1]; diff --git a/LibMatrix/Interfaces/EventContent.cs b/LibMatrix/Interfaces/EventContent.cs index 51671dd..ec09c7e 100644 --- a/LibMatrix/Interfaces/EventContent.cs +++ b/LibMatrix/Interfaces/EventContent.cs @@ -3,11 +3,14 @@ using System.Text.Json.Serialization; namespace LibMatrix.Interfaces; public abstract class EventContent { + +} +public abstract class TimelineEventContent : EventContent { [JsonPropertyName("m.relates_to")] public MessageRelatesTo? RelatesTo { get; set; } // [JsonPropertyName("m.new_content")] - // public EventContent? NewContent { get; set; } + // public TimelineEventContent? NewContent { get; set; } public class MessageRelatesTo { [JsonPropertyName("m.in_reply_to")] diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs index 700e530..b81713a 100644 --- a/LibMatrix/RoomTypes/GenericRoom.cs +++ b/LibMatrix/RoomTypes/GenericRoom.cs @@ -227,7 +227,7 @@ public class GenericRoom { await (await _httpClient.PutAsJsonAsync($"/_matrix/client/v3/rooms/{RoomId}/state/{eventType}/{stateKey}", content)) .Content.ReadFromJsonAsync<EventIdResponse>(); - public async Task<EventIdResponse?> SendTimelineEventAsync(string eventType, EventContent content) { + public async Task<EventIdResponse?> SendTimelineEventAsync(string eventType, TimelineEventContent content) { var res = await _httpClient.PutAsJsonAsync( $"/_matrix/client/v3/rooms/{RoomId}/send/{eventType}/" + Guid.NewGuid(), content, new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull |