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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using LibMatrix.Homeservers;
using LibMatrix.Responses;
using LibMatrix.Services;
using Microsoft.AspNetCore.Mvc;
namespace LibMatrix.HomeserverEmulator.Controllers;
[ApiController]
[Route("/_matrix/")]
public class VersionsController(ILogger<WellKnownController> logger) : ControllerBase {
[HttpGet("client/versions")]
public async Task<ClientVersionsResponse> GetClientVersions() {
var clientVersions = new ClientVersionsResponse {
Versions = new() {
"r0.0.1",
"r0.1.0",
"r0.2.0",
"r0.3.0",
"r0.4.0",
"r0.5.0",
"r0.6.0",
"r0.6.1",
"v1.1",
"v1.2",
"v1.3",
"v1.4",
"v1.5",
"v1.6",
"v1.7",
"v1.8",
},
UnstableFeatures = new()
};
return clientVersions;
}
[HttpGet("federation/v1/version")]
public async Task<ServerVersionResponse> GetServerVersions() {
var clientVersions = new ServerVersionResponse() {
Server = new() {
Name = "LibMatrix.HomeserverEmulator",
Version = "0.0.0"
}
};
return clientVersions;
}
[HttpGet("client/{version}/capabilities")]
public async Task<CapabilitiesResponse> GetCapabilities() {
return new() {
Capabilities = new() {
ChangePassword = new() {
Enabled = false
},
RoomVersions = new() {
Default = "11",
Available = new() {
["11"] = "unstable"
}
}
}
};
}
}
public class CapabilitiesResponse {
[JsonPropertyName("capabilities")]
public CapabilitiesContent Capabilities { get; set; }
public class CapabilitiesContent {
[JsonPropertyName("m.room_versions")]
public RoomVersionsContent RoomVersions { get; set; }
[JsonPropertyName("m.change_password")]
public ChangePasswordContent ChangePassword { get; set; }
public class ChangePasswordContent {
[JsonPropertyName("enabled")]
public bool Enabled { get; set; }
}
public class RoomVersionsContent {
[JsonPropertyName("default")]
public string Default { get; set; }
[JsonPropertyName("available")]
public Dictionary<string, string> Available { get; set; }
}
}
}
|