import * as dotenv from'dotenv'; import LogService from './core/LogService'; import { Account } from '../model/Account'; import Message from '../model/Message'; import MessageMapper from './core/MessageMapper'; export class LogClient { private LOGS = process.env.LOGS; private logService: LogService; constructor() { if (this.LOGS && this.LOGS === 'true') { this.logService = LogService.getInstance(); } } public async getAccountDetails(accountAddress: string): Promise { if (this.LOGS && this.LOGS === 'true') { let accountData = await this.logService.findAccount(accountAddress); if (accountData) { return new Account(accountData.account_address) .setLanguage(accountData.language); } return null; } else return null; } public async getThread(accountAddress: string, parentMessageId: string): Promise { if (this.LOGS && this.LOGS === 'true') { let thread = await this.logService.getThread(accountAddress, parentMessageId); let mapper = new MessageMapper(); return thread.messages.map((message: any) => mapper.toMessage(message)); } else return null; } }