Add ignore other event types and more error logging
This commit is contained in:
parent
d711b81f23
commit
b5605e64f7
@ -9,6 +9,7 @@ import log from './helpers/logger'
|
|||||||
import { initStorage } from './helpers/storage'
|
import { initStorage } from './helpers/storage'
|
||||||
import { whoami } from './helpers/synapse'
|
import { whoami } from './helpers/synapse'
|
||||||
import { Entity, entities } from './Entities'
|
import { Entity, entities } from './Entities'
|
||||||
|
import { AxiosError } from 'axios'
|
||||||
|
|
||||||
log.info('rocketchat2matrix starts.')
|
log.info('rocketchat2matrix starts.')
|
||||||
|
|
||||||
@ -49,8 +50,14 @@ async function main() {
|
|||||||
await loadRcExport(Entity.Messages)
|
await loadRcExport(Entity.Messages)
|
||||||
log.info('Done.')
|
log.info('Done.')
|
||||||
} catch (error) {
|
} catch (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)
|
log.error(`Encountered an error while booting up: ${error}`, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
@ -13,6 +13,7 @@ if (!applicationServiceToken) {
|
|||||||
|
|
||||||
export type RcMessage = {
|
export type RcMessage = {
|
||||||
_id: string
|
_id: string
|
||||||
|
t?: string // Event type
|
||||||
rid: string // The unique id for the room
|
rid: string // The unique id for the room
|
||||||
msg: string // The content of the message.
|
msg: string // The content of the message.
|
||||||
tmid?: string
|
tmid?: string
|
||||||
@ -84,9 +85,14 @@ export async function createMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function handle(rcMessage: RcMessage): Promise<void> {
|
export async function handle(rcMessage: RcMessage): Promise<void> {
|
||||||
|
if (rcMessage.t) {
|
||||||
|
log.warn(`Message ${rcMessage._id} is of type ${rcMessage.t}, skipping.`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const room_id = (await getRoomId(rcMessage.rid)) || ''
|
const room_id = (await getRoomId(rcMessage.rid)) || ''
|
||||||
if (!room_id) {
|
if (!room_id) {
|
||||||
log.info(
|
log.warn(
|
||||||
`Could not find room ${rcMessage.rid} for message ${rcMessage._id}, skipping.`
|
`Could not find room ${rcMessage.rid} for message ${rcMessage._id}, skipping.`
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -94,7 +100,7 @@ export async function handle(rcMessage: RcMessage): Promise<void> {
|
|||||||
|
|
||||||
const user_id = (await getUserId(rcMessage.u._id)) || ''
|
const user_id = (await getUserId(rcMessage.u._id)) || ''
|
||||||
if (!user_id) {
|
if (!user_id) {
|
||||||
log.info(
|
log.warn(
|
||||||
`Could not find author ${rcMessage.u.username} for message ${rcMessage._id}, skipping.`
|
`Could not find author ${rcMessage.u.username} for message ${rcMessage._id}, skipping.`
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user