From 698062c7f15e3786320e20066bbf0aee05f8945b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=BCttemann?= Date: Thu, 25 Jul 2024 17:45:14 +0200 Subject: [PATCH] Revert current concurrency implementation (#147) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Too many problems arose, primarily the [problems with the message order](https://github.com/verdigado/rocketchat2matrix/issues/22). For now, this implementation is reverted. Reviewed-on: https://git.verdigado.com/NB-Public/rocketchat2matrix/pulls/147 Co-authored-by: Henrik Hüttemann Co-committed-by: Henrik Hüttemann --- package-lock.json | 3 ++- package.json | 1 - src/Entities.ts | 5 ----- src/app.ts | 20 ++------------------ 4 files changed, 4 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1251f7b..2b46771 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,6 @@ "dotenv": "^16.4.5", "n-readlines": "^1.0.1", "node-emoji": "^2.1.3", - "p-limit": "^3.0.0", "reflect-metadata": "^0.2.2", "showdown": "^2.1.0", "sqlite3": "^5.1.7", @@ -5123,6 +5122,7 @@ }, "node_modules/p-limit": { "version": "3.1.0", + "dev": true, "license": "MIT", "dependencies": { "yocto-queue": "^0.1.0" @@ -6948,6 +6948,7 @@ }, "node_modules/yocto-queue": { "version": "0.1.0", + "dev": true, "license": "MIT", "engines": { "node": ">=10" diff --git a/package.json b/package.json index 18ed68b..7e40ec8 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ "dotenv": "^16.4.5", "n-readlines": "^1.0.1", "node-emoji": "^2.1.3", - "p-limit": "^3.0.0", "reflect-metadata": "^0.2.2", "showdown": "^2.1.0", "sqlite3": "^5.1.7", diff --git a/src/Entities.ts b/src/Entities.ts index fd692da..331b44e 100644 --- a/src/Entities.ts +++ b/src/Entities.ts @@ -2,7 +2,6 @@ export const enum Entity { Users = 'users', Rooms = 'rooms', Messages = 'messages', - ThreadMessages = 'threadmessages', } type EntityConfig = { @@ -25,8 +24,4 @@ export const entities: { filename: 'rocketchat_message.json', mappingType: 2, }, - threadmessages: { - filename: 'rocketchat_message.json', - mappingType: 2, - }, } as const diff --git a/src/app.ts b/src/app.ts index 16e074b..3e6611e 100644 --- a/src/app.ts +++ b/src/app.ts @@ -3,7 +3,6 @@ dotenv.config() import { AxiosError } from 'axios' import lineByLine from 'n-readlines' import { exit } from 'node:process' -import pLimit from 'p-limit' import 'reflect-metadata' import { Entity, entities } from './Entities' import { handleDirectChats } from './handlers/directChats' @@ -25,9 +24,6 @@ log.info('rocketchat2matrix starts.') async function loadRcExport(entity: Entity) { const rl = new lineByLine(`./inputs/${entities[entity].filename}`) - const limit = pLimit(parseInt(process.env.CONCURRENCY_LIMIT || '50')) - const queue = [] - let line: false | Buffer while ((line = rl.next())) { const item = JSON.parse(line.toString()) @@ -37,27 +33,17 @@ async function loadRcExport(entity: Entity) { break case Entity.Rooms: - queue.push(limit(() => handleRoom(item))) + await handleRoom(item) break case Entity.Messages: - if (!item.tmid) { - queue.push(limit(() => handleMessage(item))) - } - break - - case Entity.ThreadMessages: - if (item.tmid) { - queue.push(limit(() => handleMessage(item))) - } + await handleMessage(item) break default: throw new Error(`Unhandled Entity: ${entity}`) } } - - await Promise.all(queue) } async function main() { @@ -71,8 +57,6 @@ async function main() { await loadRcExport(Entity.Rooms) log.info('Parsing messages') await loadRcExport(Entity.Messages) - log.info('Parsing threaded messages') - await loadRcExport(Entity.ThreadMessages) log.info('Setting direct chats to be displayed as such for each user') await handleDirectChats() log.info('Setting pinned messages in rooms')