mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00

* Remove Sled crypto store, use SQLite by default on account of it being removed from the crypto-sdk * Add changelog * Don't start if Sled store config is set
56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
import { Logger } from "matrix-appservice-bridge";
|
|
import { Appservice, IAppserviceCryptoStorageProvider, IAppserviceRegistration, RustSdkAppserviceCryptoStorageProvider, RustSdkCryptoStoreType } from "matrix-bot-sdk";
|
|
import { BridgeConfig } from "./config/Config";
|
|
import Metrics from "./Metrics";
|
|
import { MemoryStorageProvider } from "./Stores/MemoryStorageProvider";
|
|
import { RedisStorageProvider } from "./Stores/RedisStorageProvider";
|
|
import { IBridgeStorageProvider } from "./Stores/StorageProvider";
|
|
const log = new Logger("Appservice");
|
|
|
|
export function getAppservice(config: BridgeConfig, registration: IAppserviceRegistration) {
|
|
let storage: IBridgeStorageProvider;
|
|
if (config.queue.host && config.queue.port) {
|
|
log.info(`Initialising Redis storage (on ${config.queue.host}:${config.queue.port})`);
|
|
storage = new RedisStorageProvider(config.queue.host, config.queue.port);
|
|
} else {
|
|
log.info('Initialising memory storage');
|
|
storage = new MemoryStorageProvider();
|
|
}
|
|
|
|
let cryptoStorage: IAppserviceCryptoStorageProvider | undefined;
|
|
if (config.encryption?.storagePath) {
|
|
log.info('Initialising crypto storage')
|
|
cryptoStorage = new RustSdkAppserviceCryptoStorageProvider(
|
|
config.encryption.storagePath,
|
|
RustSdkCryptoStoreType.Sqlite,
|
|
);
|
|
}
|
|
|
|
const appservice = 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,
|
|
});
|
|
|
|
Metrics.registerMatrixSdkMetrics(appservice);
|
|
|
|
return {appservice, storage, cryptoStorage};
|
|
} |