MatrixChat: Create an event index and start crawling for events.
This patch adds support to create an event index if the clients platform supports it and starts an event crawler. The event crawler goes through the room history of encrypted rooms and eventually indexes the whole room history of such rooms. It does this by first creating crawling checkpoints and storing them inside a database. A checkpoint consists of a room_id, direction and token. After the checkpoints are added the client starts a crawler method in the background. The crawler goes through checkpoints in a round-robin way and uses them to fetch historic room messages using the rooms/roomId/messages API endpoint. Every time messages are fetched a new checkpoint is created that will be stored in the database with the fetched events in an atomic way, the old checkpoint is deleted at the same time as well.
This commit is contained in:
parent
b8a3ee1841
commit
9ce478cb0e
2 changed files with 235 additions and 0 deletions
|
@ -30,6 +30,7 @@ import {verificationMethods} from 'matrix-js-sdk/lib/crypto';
|
|||
import MatrixClientBackedSettingsHandler from "./settings/handlers/MatrixClientBackedSettingsHandler";
|
||||
import * as StorageManager from './utils/StorageManager';
|
||||
import IdentityAuthClient from './IdentityAuthClient';
|
||||
import PlatformPeg from "./PlatformPeg";
|
||||
|
||||
interface MatrixClientCreds {
|
||||
homeserverUrl: string,
|
||||
|
@ -222,6 +223,9 @@ class MatrixClientPeg {
|
|||
|
||||
this.matrixClient = createMatrixClient(opts);
|
||||
|
||||
const platform = PlatformPeg.get();
|
||||
if (platform.supportsEventIndexing()) platform.initEventIndex(creds.userId);
|
||||
|
||||
// we're going to add eventlisteners for each matrix event tile, so the
|
||||
// potential number of event listeners is quite high.
|
||||
this.matrixClient.setMaxListeners(500);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue