This commit is contained in:
J Francisco Rader committed 2021-03-30 02:07:04 -03:00
1 parent ff4381fa01
commit a97d858f99
21 files changed
+659 -161

No files matched your search

-2
View File
@@ -3,8 +3,6 @@ import { getIdentifier, getSource } from './functions';
import { mainLogger } from './sv_logger';
import { ContactEvents } from '../../typings/contact';
const contactsLogger = mainLogger.child({ module: 'contact' });
interface Contacts {
id?: number;
display: string;
+28
View File
@@ -0,0 +1,28 @@
import events from '../utils/events';
import { mainLogger } from './sv_logger';
import { getSource } from './functions';
import { pool } from './db';
const emailLogger = mainLogger.child({ module: 'contact' });
async function fetchInbox(email: string): Promise<any> {
const query = `
SELECT * FROM npwd_emails WHERE id = ?
`;
const result = await pool.query(query, [email]);
return result[0];
}
onNet(events.EMAIL_FETCH_INBOX, async () => {
const _source = getSource();
try {
const email = '[email protected]';
const inbox = await fetchInbox(email);
emitNet(events.EMAIL_FETCH_INBOX_SUCCESS, inbox);
} catch (e) {
emailLogger.error(`Failed to fetch email inbox, ${e.message}`, {
source: _source,
});
emitNet(events.EMAIL_FETCH_INBOX_ERROR, e);
}
});