refactor(server/source-handling): Altered how we handle source

These changes are made in case source is not guranteed to remain the same

Due to how JS should operate, this shouldn't be an issue but this just ensures that
This commit is contained in:
Taso committed 2021-02-14 20:17:41 -05:00
1 parent acb8e056c3
commit 1aa6a383ab
12 files changed
+222 -140

No files matched your search

+12 -6
View File
@@ -1,7 +1,12 @@
import { ESX } from './server';
import { pool } from './db';
import config from '../utils/config';
import { getIdentifierByPhoneNumber, usePhoneNumber } from './functions';
import {
getIdentifier,
getIdentifierByPhoneNumber,
getSource,
usePhoneNumber,
} from './functions';
import { mainLogger } from './sv_logger';
//db = DatabaseConfig //helper variable for use in server function
@@ -66,13 +71,14 @@ onNet('esx:playerLoaded', async (playerId: number, xPlayer: any) => {
});
onNet('phone:getCredentials', async () => {
const _source = getSource();
try {
const _source = (global as any).source;
const xPlayer = ESX.GetPlayerFromId(_source);
const _identifier = xPlayer.getIdentifier();
const number = await getCredentials(_identifier);
const identifier = getIdentifier(_source);
const number = await getCredentials(identifier);
emitNet('phone:sendCredentials', _source, number);
} catch (e) {
mainLogger.error(`Failed to get a number, ${e.message}`);
mainLogger.error(`Failed to get a number, ${e.message}`, {
source: _source,
});
}
});