RocketChat/Rocket.Chat

View on GitHub
apps/meteor/app/importer/server/classes/ImporterWebsocket.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { IImportProgress } from '@rocket.chat/core-typings';
import type { IStreamer } from 'meteor/rocketchat:streamer';

import notifications from '../../../notifications/server/lib/Notifications';

class ImporterWebsocketDef {
    private streamer: IStreamer<'importers'>;

    constructor() {
        this.streamer = notifications.streamImporters;
    }

    /**
     * Called when the progress is updated.
     *
     * @param {Progress} progress The progress of the import.
     */
    progressUpdated(progress: { rate: number } | IImportProgress) {
        this.streamer.emit('progress', progress);
    }
}

export const ImporterWebsocket = new ImporterWebsocketDef();