From 4fb240b39a245ce5b8372e44cf1f1ebdfb06c993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=BCttemann?= Date: Wed, 13 Sep 2023 16:42:14 +0200 Subject: [PATCH] Use warning log level for skipped entities --- src/handlers/messages.ts | 2 +- src/handlers/rooms.test.ts | 4 +++- src/handlers/rooms.ts | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/handlers/messages.ts b/src/handlers/messages.ts index 5ca612c..999a512 100644 --- a/src/handlers/messages.ts +++ b/src/handlers/messages.ts @@ -161,7 +161,7 @@ export async function handle(rcMessage: RcMessage): Promise { case 'added-user-to-team': // Added user to team case 'r': // Room name changed case 'rm': // Message removed - log.info( + log.warn( `Message ${rcMessage._id} is of type ${rcMessage.t}, for which Rocket.Chat does not provide the initial state information, skipping.` ) return diff --git a/src/handlers/rooms.test.ts b/src/handlers/rooms.test.ts index d2f3fc6..1f0ef2e 100644 --- a/src/handlers/rooms.test.ts +++ b/src/handlers/rooms.test.ts @@ -106,7 +106,9 @@ test('mapping private rooms', () => { test('mapping live chats', () => { expect(() => mapRoom({ _id: 'liveChatId', t: RcRoomTypes.live }) - ).toThrowError('Room type l is unknown') + ).toThrowError( + 'Room with ID: liveChatId is a live chat. Migration not implemented' + ) }) test('getting creator', () => { diff --git a/src/handlers/rooms.ts b/src/handlers/rooms.ts index 9568372..d5b46e5 100644 --- a/src/handlers/rooms.ts +++ b/src/handlers/rooms.ts @@ -83,10 +83,18 @@ export function mapRoom(rcRoom: RcRoom): MatrixRoom { break case RcRoomTypes.live: + const messageLivechat = `Room ${ + rcRoom.name || 'with ID: ' + rcRoom._id + } is a live chat. Migration not implemented` + log.warn(messageLivechat) + throw new Error(messageLivechat) + default: - const message = `Room type ${rcRoom.t} is unknown or unimplemented` - log.error(message) - throw new Error(message) + const messageUnknownRoom = `Room ${ + rcRoom.name || 'with ID: ' + rcRoom._id + } is of type ${rcRoom.t}, which is unknown or unimplemented` + log.error(messageUnknownRoom) + throw new Error(messageUnknownRoom) } return room } @@ -98,7 +106,7 @@ export function getCreator(rcRoom: RcRoom): string { return rcRoom.uids[0] } else { log.warn( - `Creator ID could not be determined for room ${rcRoom.name} of type ${rcRoom.t}. This is normal for the default room.` + `Creator ID could not be determined for room ${rcRoom.name} of type ${rcRoom.t}. This is normal for the default room. Using admin user.` ) return '' }