Files
new-phone-who-dis/resources/server/sv_email.ts
T
2021-03-30 02:07:04 -03:00

29 lines
807 B
TypeScript

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);
}
});