about summary refs log tree commit diff
path: root/LibMatrix/StateEventTypes/Spec/RoomMessageEventData.cs
blob: d13c27340ad37970282ed9058b7a63bd648e9ae7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Text.Json.Serialization;
using ArcaneLibs.Extensions;
using LibMatrix.Helpers;
using LibMatrix.Interfaces;

namespace LibMatrix.StateEventTypes.Spec;

[MatrixEvent(EventName = "m.room.message")]
public class RoomMessageEventData : IStateEventType {
    public RoomMessageEventData() { }

    public RoomMessageEventData(string messageType, string body) {
        MessageType = messageType;
        Body = body;
    }

    public RoomMessageEventData(string body) : this() {
        Body = body;
        MessageType = "m.notice";
    }

    [JsonPropertyName("body")]
    public string Body { get; set; }

    [JsonPropertyName("msgtype")]
    public string MessageType { get; set; } = "m.notice";

    [JsonPropertyName("formatted_body")]
    public string FormattedBody { get; set; }

    [JsonPropertyName("format")]
    public string Format { get; set; }

    [JsonPropertyName("m.relates_to")]
    public MessageRelatesTo? RelatesTo { get; set; }

    /// <summary>
    /// Media URI for this message, if any
    /// </summary>
    [JsonPropertyName("url")]
    public string? Url { get; set; }

    public class MessageRelatesTo {
        [JsonPropertyName("m.in_reply_to")]
        public MessageInReplyTo? InReplyTo { get; set; }

        public class MessageInReplyTo {
            [JsonPropertyName("event_id")]
            public string EventId { get; set; }
        }
    }
}