about summary refs log tree commit diff
path: root/LibMatrix/Homeservers/ImplementationDetails/Synapse/Models/Responses/Destinations.cs
blob: 646a4b5f64a1bbb7583eac773e5e49ad28215cc3 (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
53
54
55
56
using System.Text.Json.Serialization;

namespace LibMatrix.Homeservers.ImplementationDetails.Synapse.Models.Responses;

public class SynapseAdminDestinationListResult : SynapseNextTokenTotalCollectionResult {
    [JsonPropertyName("destinations")]
    public List<SynapseAdminDestinationListResultDestination> Destinations { get; set; } = new();

    public class SynapseAdminDestinationListResultDestination {
        [JsonPropertyName("destination")]
        public string Destination { get; set; }

        [JsonPropertyName("retry_last_ts")]
        public long RetryLastTs { get; set; }

        [JsonPropertyName("retry_interval")]
        public long RetryInterval { get; set; }

        [JsonPropertyName("failure_ts")]
        public long? FailureTs { get; set; }

        [JsonPropertyName("last_successful_stream_ordering")]
        public long? LastSuccessfulStreamOrdering { get; set; }

        [JsonIgnore]
        public DateTime? FailureTsDateTime {
            get => FailureTs.HasValue ? DateTimeOffset.FromUnixTimeMilliseconds(FailureTs.Value).DateTime : null;
            set => FailureTs = value.HasValue ? new DateTimeOffset(value.Value).ToUnixTimeMilliseconds() : null;
        }

        [JsonIgnore]
        public DateTime? RetryLastTsDateTime {
            get => DateTimeOffset.FromUnixTimeMilliseconds(RetryLastTs).DateTime;
            set => RetryLastTs = new DateTimeOffset(value.Value).ToUnixTimeMilliseconds();
        }

        [JsonIgnore]
        public TimeSpan RetryIntervalTimeSpan {
            get => TimeSpan.FromMilliseconds(RetryInterval);
            set => RetryInterval = (long)value.TotalMilliseconds;
        }
    }
}

public class SynapseAdminDestinationRoomListResult : SynapseNextTokenTotalCollectionResult {
    [JsonPropertyName("rooms")]
    public List<SynapseAdminDestinationRoomListResultRoom> Rooms { get; set; } = new();

    public class SynapseAdminDestinationRoomListResultRoom {
        [JsonPropertyName("room_id")]
        public string RoomId { get; set; }

        [JsonPropertyName("stream_ordering")]
        public int StreamOrdering { get; set; }
    }
}