Add storage dummy
This commit is contained in:
parent
3edc835deb
commit
15697f3897
25
src/app.ts
25
src/app.ts
@ -2,6 +2,8 @@ import fs from 'node:fs'
|
||||
import readline from 'node:readline'
|
||||
import log from './logger'
|
||||
import { whoami } from './synapse'
|
||||
import { storage } from './storage'
|
||||
|
||||
log.info('rocketchat2matrix starts.')
|
||||
|
||||
const enum Entities {
|
||||
@ -22,7 +24,28 @@ function loadRcExport(entity: Entities) {
|
||||
const item = JSON.parse(line)
|
||||
switch (entity) {
|
||||
case Entities.Users:
|
||||
log.debug(`User: ${item.name}`)
|
||||
log.info(`User: ${item.name}: ${item._id}`)
|
||||
|
||||
// Check for exclusion
|
||||
if (storage.exclusionsLists.users.includes(item._id)) {
|
||||
log.debug('User excluded. Skipping.')
|
||||
break
|
||||
}
|
||||
|
||||
// Lookup
|
||||
let userMapping = storage.users.find((e) => e.rcId === item._id)
|
||||
if (userMapping) {
|
||||
log.debug('Mapping exists:', userMapping)
|
||||
} else {
|
||||
userMapping = {
|
||||
rcId: item._id,
|
||||
matrixId: `@${item.username}:localhost`,
|
||||
rcRooms: item.__rooms,
|
||||
}
|
||||
storage.users.push(userMapping)
|
||||
log.debug('Mapping added:', userMapping)
|
||||
}
|
||||
|
||||
break
|
||||
|
||||
case Entities.Rooms:
|
||||
|
||||
40
src/storage.ts
Normal file
40
src/storage.ts
Normal file
@ -0,0 +1,40 @@
|
||||
export interface storage {
|
||||
users: {
|
||||
rcId: string
|
||||
matrixId: string
|
||||
rcRooms: string[]
|
||||
}[]
|
||||
rooms: {
|
||||
rcId: string
|
||||
matrixId: string
|
||||
}[]
|
||||
messages: {
|
||||
rcId: string
|
||||
matrixId: string
|
||||
}[]
|
||||
exclusionsLists: {
|
||||
users: string[]
|
||||
rooms: string[]
|
||||
messages: string[]
|
||||
}
|
||||
}
|
||||
|
||||
export const storage: storage = {
|
||||
users: [
|
||||
{
|
||||
rcId: '2ziHK8P748TeESitX',
|
||||
matrixId: '@herhde:locahlost',
|
||||
rcRooms: [],
|
||||
},
|
||||
],
|
||||
rooms: [],
|
||||
messages: [],
|
||||
exclusionsLists: {
|
||||
users: [
|
||||
'rocket.cat',
|
||||
'5kdLWNTys3u2MhB2H', // verdiadmin
|
||||
],
|
||||
rooms: [],
|
||||
messages: [],
|
||||
},
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user