diff --git a/src/app.ts b/src/app.ts index 107ee64..dc50312 100644 --- a/src/app.ts +++ b/src/app.ts @@ -9,6 +9,7 @@ import log from './helpers/logger' import { initStorage } from './helpers/storage' import { whoami } from './helpers/synapse' import { Entity, entities } from './Entities' +import { AxiosError } from 'axios' log.info('rocketchat2matrix starts.') @@ -49,7 +50,13 @@ async function main() { await loadRcExport(Entity.Messages) log.info('Done.') } catch (error) { - log.error(`Encountered an error while booting up: ${error}`, error) + if (error instanceof AxiosError) { + log.error(`Error during request: ${error.message}`) + log.error(`Request: ${error.request?.method} ${error.request?.path}`) + log.error(`Response: ${error.response?.status}`, error.response?.data) + } else { + log.error(`Encountered an error while booting up: ${error}`, error) + } } } diff --git a/src/handlers/messages.ts b/src/handlers/messages.ts index 683a976..cdc72e8 100644 --- a/src/handlers/messages.ts +++ b/src/handlers/messages.ts @@ -13,6 +13,7 @@ if (!applicationServiceToken) { export type RcMessage = { _id: string + t?: string // Event type rid: string // The unique id for the room msg: string // The content of the message. tmid?: string @@ -84,9 +85,14 @@ export async function createMessage( } export async function handle(rcMessage: RcMessage): Promise { + if (rcMessage.t) { + log.warn(`Message ${rcMessage._id} is of type ${rcMessage.t}, skipping.`) + return + } + const room_id = (await getRoomId(rcMessage.rid)) || '' if (!room_id) { - log.info( + log.warn( `Could not find room ${rcMessage.rid} for message ${rcMessage._id}, skipping.` ) return @@ -94,7 +100,7 @@ export async function handle(rcMessage: RcMessage): Promise { const user_id = (await getUserId(rcMessage.u._id)) || '' if (!user_id) { - log.info( + log.warn( `Could not find author ${rcMessage.u.username} for message ${rcMessage._id}, skipping.` ) return