blob: b6d28e61e225f3541e301cbe98d78e8343ac4605 (
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
57
58
59
60
|
using System.Collections.Frozen;
using System.Collections.ObjectModel;
using System.Security.Cryptography;
using System.Text.Json.Serialization;
namespace ModAS.Server;
public class AppServiceRegistration {
private const string ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
private const string ExtendedValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~+/";
[JsonPropertyName("as_token")]
public string AppServiceToken { get; set; } = RandomNumberGenerator.GetString(ExtendedValidChars, RandomNumberGenerator.GetInt32(512, 1024));
[JsonPropertyName("hs_token")]
public string HomeserverToken { get; set; } = RandomNumberGenerator.GetString(ExtendedValidChars, RandomNumberGenerator.GetInt32(512, 1024));
[JsonPropertyName("id")]
public string Id { get; set; } = "ModAS-" + RandomNumberGenerator.GetString(ValidChars, 5);
[JsonPropertyName("namespaces")]
public NamespacesObject Namespaces { get; set; } = new() {
Users = [new() { Exclusive = false, Regex = "@.*" }],
Aliases = [new() { Exclusive = false, Regex = "#.*" }],
Rooms = [new() { Exclusive = false, Regex = "!.*" }]
};
[JsonPropertyName("protocols")]
public Collection<string> Protocols { get; set; } = new(new[] {
"ModAS"
});
[JsonPropertyName("rate_limited")]
public bool RateLimited { get; set; } = false;
[JsonPropertyName("sender_localpart")]
public string SenderLocalpart { get; set; } = "ModAS";
[JsonPropertyName("url")]
public string Url { get; set; } = "http://localhost:5071";
public class NamespacesObject {
[JsonPropertyName("users")]
public List<NamespaceObject> Users { get; set; } = new();
[JsonPropertyName("aliases")]
public List<NamespaceObject> Aliases { get; set; } = new();
[JsonPropertyName("rooms")]
public List<NamespaceObject> Rooms { get; set; } = new();
}
public class NamespaceObject {
[JsonPropertyName("exclusive")]
public bool Exclusive { get; set; } = false;
[JsonPropertyName("regex")]
public string Regex { get; set; } = "*";
}
}
|