From 52aaf1d46bacabcc7ebd50be278532f36ff3d031 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Thu, 4 Jul 2024 11:10:56 +0300 Subject: [PATCH 1/2] fixed wrong filtering logic for allowed types --- .../adapter-message/matrix.message.adapter.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/service/src/services/matrix/adapter-message/matrix.message.adapter.ts b/service/src/services/matrix/adapter-message/matrix.message.adapter.ts index 3248cec..3f72bcb 100644 --- a/service/src/services/matrix/adapter-message/matrix.message.adapter.ts +++ b/service/src/services/matrix/adapter-message/matrix.message.adapter.ts @@ -8,7 +8,7 @@ import { EventType } from 'matrix-js-sdk'; @Injectable() export class MatrixMessageAdapter { - readonly FILTERED_EVENT_TYPES = [EventType.RoomMessage, EventType.Reaction]; + readonly ALLOWED_EVENT_TYPES = [EventType.RoomMessage, EventType.Reaction]; constructor( @Inject(WINSTON_MODULE_NEST_PROVIDER) @@ -87,16 +87,15 @@ export class MatrixMessageAdapter { isEventToIgnore(message: MatrixRoomResponseMessage): boolean { const event = message.event; - if (event.type) { - for (const type of this.FILTERED_EVENT_TYPES) { - if (event.type === type) { - this.logger.verbose?.( - `[Timeline] Ignoring event of type: ${event.type} as it is not one of '${this.FILTERED_EVENT_TYPES}' types `, - LogContext.COMMUNICATION - ); - return true; - } - } + if ( + event.type && + !this.ALLOWED_EVENT_TYPES.every(type => event.type !== type) + ) { + this.logger.verbose?.( + `[Timeline] Ignoring event of type: ${event.type} as it is not one of '${this.ALLOWED_EVENT_TYPES}' types `, + LogContext.COMMUNICATION + ); + return true; } const content = message.getContent(); From 68a0114c3d5def4c8c7045ae0d379e9fee028299 Mon Sep 17 00:00:00 2001 From: Svetoslav Petkov Date: Thu, 4 Jul 2024 11:20:21 +0300 Subject: [PATCH 2/2] version bump (#39) --- service/package-lock.json | 4 ++-- service/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/service/package-lock.json b/service/package-lock.json index 7ba38de..aca6dc4 100644 --- a/service/package-lock.json +++ b/service/package-lock.json @@ -1,12 +1,12 @@ { "name": "alkemio-matrix-adapter", - "version": "0.4.0", + "version": "0.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "alkemio-matrix-adapter", - "version": "0.4.0", + "version": "0.4.1", "license": "EUPL-1.2", "dependencies": { "@alkemio/matrix-adapter-lib": "^0.3.6", diff --git a/service/package.json b/service/package.json index c3b11ae..2d97c0f 100644 --- a/service/package.json +++ b/service/package.json @@ -1,6 +1,6 @@ { "name": "alkemio-matrix-adapter", - "version": "0.4.0", + "version": "0.4.1", "description": "Alkemio Matrix Adapter service", "author": "Alkemio Foundation", "private": false,