-
Notifications
You must be signed in to change notification settings - Fork 65
/
appservice.ts
30 lines (28 loc) · 1.23 KB
/
appservice.ts
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
import { Appservice, IAppserviceRegistration, IAppserviceStorageProvider, RustSdkAppserviceCryptoStorageProvider } from "matrix-bot-sdk";
import { BridgeConfig } from "./Config/Config";
export function getAppservice(config: BridgeConfig, registration: IAppserviceRegistration, storage: IAppserviceStorageProvider) {
const cryptoStorage = config.encryption?.storagePath ? new RustSdkAppserviceCryptoStorageProvider(config.encryption.storagePath) : undefined;
return new Appservice({
homeserverName: config.bridge.domain,
homeserverUrl: config.bridge.url,
port: config.bridge.port,
bindAddress: config.bridge.bindAddress,
registration: {
...registration,
namespaces: {
// Support multiple users
users: [{
regex: '(' + registration.namespaces.users.map((r) => r.regex).join(')|(') + ')',
exclusive: true,
}],
aliases: registration.namespaces.aliases,
rooms: registration.namespaces.rooms,
}
},
storage: storage,
intentOptions: {
encryption: !!config.encryption,
},
cryptoStorage: cryptoStorage,
});
}