Skip to content

Commit

Permalink
Merge pull request #38 from alkem-io/allowed-types
Browse files Browse the repository at this point in the history
Fixed wrong filtering logic for allowed types
  • Loading branch information
techsmyth authored Jul 4, 2024
2 parents 20879d6 + 52aaf1d commit 98238b3
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 98238b3

Please sign in to comment.