mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Merge pull request #93 from project-error/enhance/source-changes
refactor(server/source-handling): Altered how we handle source
This commit is contained in:
12 files changed
+221
-139
No files matched your search
Whitespace-only changes.
@@ -16,10 +16,10 @@ export async function usePhoneNumber(identifier: string): Promise<string> {
|
|||||||
return phoneNumber[0].phone_number;
|
return phoneNumber[0].phone_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getSource = () => parseInt(source);
|
export const getSource = () => (global as any).source;
|
||||||
|
|
||||||
export async function useIdentifier(): Promise<string> {
|
export function getIdentifier(source: number): string {
|
||||||
return ESX.GetPlayerFromId(getSource()).getIdentifier();
|
return ESX.GetPlayerFromId(source).getIdentifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getIdentifierByPhoneNumber(
|
export async function getIdentifierByPhoneNumber(
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import { mainLogger } from './sv_logger';
|
|||||||
|
|
||||||
export let ESX: Server = null;
|
export let ESX: Server = null;
|
||||||
|
|
||||||
export const getSource = () => (global as any).source;
|
|
||||||
|
|
||||||
emit('esx:getSharedObject', (obj: Server) => (ESX = obj));
|
emit('esx:getSharedObject', (obj: Server) => (ESX = obj));
|
||||||
|
|
||||||
on('onServerResourceStart', (resource: string) => {
|
on('onServerResourceStart', (resource: string) => {
|
||||||
|
|||||||
+18
-10
@@ -6,7 +6,7 @@ import {
|
|||||||
Transfer,
|
Transfer,
|
||||||
IBankCredentials,
|
IBankCredentials,
|
||||||
} from '../../phone/src/common/typings/bank';
|
} from '../../phone/src/common/typings/bank';
|
||||||
import { useIdentifier } from './functions';
|
import { getIdentifier } from './functions';
|
||||||
import { mainLogger } from './sv_logger';
|
import { mainLogger } from './sv_logger';
|
||||||
|
|
||||||
const bankLogger = mainLogger.child({ module: 'bank' });
|
const bankLogger = mainLogger.child({ module: 'bank' });
|
||||||
@@ -85,35 +85,43 @@ async function getTransfer(transferId: number): Promise<Transfer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _source = (global as any).source;
|
const _identifier = await getIdentifier(_source);
|
||||||
const _identifier = await useIdentifier();
|
|
||||||
const transfer = await fetchAllTransactions(_identifier);
|
const transfer = await fetchAllTransactions(_identifier);
|
||||||
|
|
||||||
emitNet(events.BANK_SEND_TRANSFERS, _source, transfer);
|
emitNet(events.BANK_SEND_TRANSFERS, _source, transfer);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bankLogger.error(`Failed to fetch transactions, ${e.message}`);
|
bankLogger.error(`Failed to fetch transactions, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
||||||
|
const _source = getSource();
|
||||||
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
|
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
|
||||||
try {
|
try {
|
||||||
const _identifier = await useIdentifier();
|
const _identifier = getIdentifier(_source);
|
||||||
const transferNotify = await addTransfer(_identifier, transfer);
|
const transferNotify = await addTransfer(_identifier, transfer);
|
||||||
emitNet(events.BANK_TRANSACTION_NOTIFICATION, xTarget, transferNotify);
|
emitNet(events.BANK_TRANSACTION_NOTIFICATION, xTarget, transferNotify);
|
||||||
emitNet(events.BANK_ADD_TRANSFER_SUCCESS, getSource());
|
emitNet(events.BANK_ADD_TRANSFER_SUCCESS, _source);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bankLogger.error(`Failed to add transaction, ${e.message}`);
|
bankLogger.error(`Failed to add transaction, ${e.message}`, {
|
||||||
emitNet(events.BANK_TRANSACTION_ALERT, getSource(), false);
|
source: _source,
|
||||||
|
});
|
||||||
|
emitNet(events.BANK_TRANSACTION_ALERT, _source, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.BANK_GET_CREDENTIALS, () => {
|
onNet(events.BANK_GET_CREDENTIALS, () => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const credentials = fetchCredentials();
|
const credentials = fetchCredentials();
|
||||||
emitNet(events.BANK_SEND_CREDENTIALS, getSource(), credentials);
|
emitNet(events.BANK_SEND_CREDENTIALS, _source, credentials);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bankLogger.error(`Failed to fetch credentials, ${e.message}`);
|
bankLogger.error(`Failed to fetch credentials, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
+17
-11
@@ -3,7 +3,8 @@ import events from '../utils/events';
|
|||||||
import {
|
import {
|
||||||
getIdentifierByPhoneNumber,
|
getIdentifierByPhoneNumber,
|
||||||
usePhoneNumber,
|
usePhoneNumber,
|
||||||
useIdentifier,
|
getIdentifier,
|
||||||
|
getSource,
|
||||||
} from './functions';
|
} from './functions';
|
||||||
import { XPlayer } from 'esx.js/@types/server';
|
import { XPlayer } from 'esx.js/@types/server';
|
||||||
import { ICall } from '../../phone/src/common/typings/call';
|
import { ICall } from '../../phone/src/common/typings/call';
|
||||||
@@ -66,7 +67,7 @@ let calls: Map<string, ICall> = new Map();
|
|||||||
onNet(
|
onNet(
|
||||||
events.PHONE_INITIALIZE_CALL,
|
events.PHONE_INITIALIZE_CALL,
|
||||||
async (phoneNumber: string, timestamp: number) => {
|
async (phoneNumber: string, timestamp: number) => {
|
||||||
const _source = (global as any).source;
|
const _source = getSource();
|
||||||
|
|
||||||
const callIdentifier = uuidv4();
|
const callIdentifier = uuidv4();
|
||||||
|
|
||||||
@@ -115,9 +116,8 @@ onNet(
|
|||||||
);
|
);
|
||||||
|
|
||||||
onNet(events.PHONE_ACCEPT_CALL, async (transmitterNumber: string) => {
|
onNet(events.PHONE_ACCEPT_CALL, async (transmitterNumber: string) => {
|
||||||
|
const pSource = getSource();
|
||||||
try {
|
try {
|
||||||
const pSource = (global as any).source;
|
|
||||||
|
|
||||||
const currentCall = calls.get(transmitterNumber);
|
const currentCall = calls.get(transmitterNumber);
|
||||||
const channelId = pSource;
|
const channelId = pSource;
|
||||||
|
|
||||||
@@ -141,15 +141,17 @@ onNet(events.PHONE_ACCEPT_CALL, async (transmitterNumber: string) => {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
callLogger.error('Accepting Call Error', e.message);
|
callLogger.error('Accepting Call Error', e.message, {
|
||||||
|
source: pSource,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(
|
onNet(
|
||||||
events.PHONE_CALL_REJECTED,
|
events.PHONE_CALL_REJECTED,
|
||||||
async (transmitterNumber: string, timestamp: number) => {
|
async (transmitterNumber: string, timestamp: number) => {
|
||||||
|
const pSource = getSource();
|
||||||
try {
|
try {
|
||||||
const pSource = (global as any).source;
|
|
||||||
const currentCall = calls.get(transmitterNumber);
|
const currentCall = calls.get(transmitterNumber);
|
||||||
|
|
||||||
await updateCall(currentCall, false, timestamp);
|
await updateCall(currentCall, false, timestamp);
|
||||||
@@ -159,7 +161,9 @@ onNet(
|
|||||||
// player who is calling
|
// player who is calling
|
||||||
emitNet(events.PHONE_CALL_WAS_REJECTED, currentCall.transmitterSource);
|
emitNet(events.PHONE_CALL_WAS_REJECTED, currentCall.transmitterSource);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
callLogger.error(`Phone Call Rejected Event Error ${e.message}`);
|
callLogger.error(`Phone Call Rejected Event Error ${e.message}`, {
|
||||||
|
source: pSource,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -167,8 +171,8 @@ onNet(
|
|||||||
onNet(
|
onNet(
|
||||||
events.PHONE_END_CALL,
|
events.PHONE_END_CALL,
|
||||||
async (transmitterNumber: string, timestamp: number) => {
|
async (transmitterNumber: string, timestamp: number) => {
|
||||||
|
const pSource = getSource();
|
||||||
try {
|
try {
|
||||||
const pSource = (global as any).source;
|
|
||||||
const currentCall = calls.get(transmitterNumber);
|
const currentCall = calls.get(transmitterNumber);
|
||||||
|
|
||||||
const endTime = timestamp / 1000;
|
const endTime = timestamp / 1000;
|
||||||
@@ -182,14 +186,16 @@ onNet(
|
|||||||
|
|
||||||
calls.delete(transmitterNumber);
|
calls.delete(transmitterNumber);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
callLogger.error(`Error ending Phone Call, ${e.message}`);
|
callLogger.error(`Error ending Phone Call, ${e.message}`, {
|
||||||
|
source: pSource,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
onNet(events.PHONE_CALL_FETCH_CALLS, async () => {
|
onNet(events.PHONE_CALL_FETCH_CALLS, async () => {
|
||||||
const _source = (global as any).source;
|
const _source = getSource();
|
||||||
const identifier = await useIdentifier();
|
const identifier = await getIdentifier(_source);
|
||||||
const phoneNumber = await usePhoneNumber(identifier);
|
const phoneNumber = await usePhoneNumber(identifier);
|
||||||
|
|
||||||
const calls = await fetchCalls(phoneNumber);
|
const calls = await fetchCalls(phoneNumber);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ESX } from './server';
|
import { ESX } from './server';
|
||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import events from '../utils/events';
|
import events from '../utils/events';
|
||||||
import { useIdentifier, getSource } from './functions';
|
import { getIdentifier, getSource } from './functions';
|
||||||
import { mainLogger } from './sv_logger';
|
import { mainLogger } from './sv_logger';
|
||||||
|
|
||||||
const contactsLogger = mainLogger.child({ module: 'contact' });
|
const contactsLogger = mainLogger.child({ module: 'contact' });
|
||||||
@@ -66,10 +66,9 @@ async function deleteContact(
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _source = (global as any).source;
|
const _identifier = getIdentifier(_source);
|
||||||
const xPlayer = ESX.GetPlayerFromId(_source);
|
|
||||||
const _identifier = xPlayer.getIdentifier();
|
|
||||||
|
|
||||||
const contacts = await fetchAllContacts(_identifier);
|
const contacts = await fetchAllContacts(_identifier);
|
||||||
emitNet(events.CONTACTS_SEND_CONTACTS, _source, contacts);
|
emitNet(events.CONTACTS_SEND_CONTACTS, _source, contacts);
|
||||||
@@ -81,23 +80,24 @@ onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
|||||||
onNet(
|
onNet(
|
||||||
events.CONTACTS_ADD_CONTACT,
|
events.CONTACTS_ADD_CONTACT,
|
||||||
async (number: string, display: string, avatar: string) => {
|
async (number: string, display: string, avatar: string) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _source = (global as any).source;
|
const _identifier = getIdentifier(_source);
|
||||||
const _identifier = await useIdentifier();
|
await addContact(_identifier, number, display, avatar);
|
||||||
addContact(_identifier, number, display, avatar);
|
|
||||||
emitNet(events.CONTACTS_ADD_CONTACT_SUCCESS, _source);
|
emitNet(events.CONTACTS_ADD_CONTACT_SUCCESS, _source);
|
||||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_ADD_SUCCESS');
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_ADD_SUCCESS');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const _source = (global as any).source;
|
|
||||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_ADD_FAILED');
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_ADD_FAILED');
|
||||||
contactsLogger.error(`Failed to add contact, ${e.message}`);
|
contactsLogger.error(`Failed to add contact, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _source = (global as any).source;
|
|
||||||
const _identifier = ESX.GetPlayerFromId(_source).getIdentifier();
|
const _identifier = ESX.GetPlayerFromId(_source).getIdentifier();
|
||||||
// console.log('nice identifier bro', _identifier);
|
// console.log('nice identifier bro', _identifier);
|
||||||
await updateContact(contact, _identifier);
|
await updateContact(contact, _identifier);
|
||||||
@@ -111,26 +111,23 @@ onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
const _source = (global as any).source;
|
const _source = (global as any).source;
|
||||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_UPDATE_FAILED');
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_UPDATE_FAILED');
|
||||||
contactsLogger.error(`Failed to update contact, ${e.message}`);
|
contactsLogger.error(`Failed to update contact, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
|
onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = await useIdentifier();
|
const _identifier = await getIdentifier(_source);
|
||||||
deleteContact(contact, _identifier);
|
await deleteContact(contact, _identifier);
|
||||||
emitNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, getSource());
|
emitNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, _source);
|
||||||
emitNet(
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_DELETE_SUCCESS');
|
||||||
events.CONTACTS_ACTION_RESULT,
|
|
||||||
getSource(),
|
|
||||||
'CONTACT_DELETE_SUCCESS'
|
|
||||||
);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
contactsLogger.error(`Failed to delete contact, ${e.message}`);
|
contactsLogger.error(`Failed to delete contact, ${e.message}`, {
|
||||||
emitNet(
|
source: _source,
|
||||||
events.CONTACTS_ACTION_RESULT,
|
});
|
||||||
getSource(),
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, 'CONTACT_DELETE_FAILED');
|
||||||
'CONTACT_DELETE_FAILED'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
import { ESX } from './server';
|
import { ESX } from './server';
|
||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import config from '../utils/config';
|
import config from '../utils/config';
|
||||||
import { getIdentifierByPhoneNumber, usePhoneNumber } from './functions';
|
import {
|
||||||
|
getIdentifier,
|
||||||
|
getIdentifierByPhoneNumber,
|
||||||
|
getSource,
|
||||||
|
usePhoneNumber,
|
||||||
|
} from './functions';
|
||||||
import { mainLogger } from './sv_logger';
|
import { mainLogger } from './sv_logger';
|
||||||
|
|
||||||
//db = DatabaseConfig //helper variable for use in server function
|
//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 () => {
|
onNet('phone:getCredentials', async () => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _source = (global as any).source;
|
const identifier = getIdentifier(_source);
|
||||||
const xPlayer = ESX.GetPlayerFromId(_source);
|
const number = await getCredentials(identifier);
|
||||||
const _identifier = xPlayer.getIdentifier();
|
|
||||||
const number = await getCredentials(_identifier);
|
|
||||||
emitNet('phone:sendCredentials', _source, number);
|
emitNet('phone:sendCredentials', _source, number);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
mainLogger.error(`Failed to get a number, ${e.message}`);
|
mainLogger.error(`Failed to get a number, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
CreateMessageGroupResult,
|
CreateMessageGroupResult,
|
||||||
} from '../../phone/src/common/typings/messages';
|
} from '../../phone/src/common/typings/messages';
|
||||||
import { pool, withTransaction } from './db';
|
import { pool, withTransaction } from './db';
|
||||||
import { getSource, useIdentifier } from './functions';
|
import { getSource, getIdentifier } from './functions';
|
||||||
import { mainLogger } from './sv_logger';
|
import { mainLogger } from './sv_logger';
|
||||||
|
|
||||||
const messageLogger = mainLogger.child({ module: 'messages' });
|
const messageLogger = mainLogger.child({ module: 'messages' });
|
||||||
@@ -376,16 +376,17 @@ async function createMessageGroupsFromPhoneNumbers(
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS, async () => {
|
onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS, async () => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = await useIdentifier();
|
const identifier = getIdentifier(_source);
|
||||||
const messageGroups = await getFormattedMessageGroups(_identifier);
|
const messageGroups = await getFormattedMessageGroups(identifier);
|
||||||
emitNet(
|
emitNet(
|
||||||
events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS,
|
events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS,
|
||||||
getSource(),
|
getSource(),
|
||||||
messageGroups
|
messageGroups
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_FAILED, getSource());
|
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_FAILED, _source);
|
||||||
messageLogger.error(`Failed to fetch messages groups, ${e.message}`);
|
messageLogger.error(`Failed to fetch messages groups, ${e.message}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -393,8 +394,9 @@ onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS, async () => {
|
|||||||
onNet(
|
onNet(
|
||||||
events.MESSAGES_CREATE_MESSAGE_GROUP,
|
events.MESSAGES_CREATE_MESSAGE_GROUP,
|
||||||
async (phoneNumbers: string[], label: string = null) => {
|
async (phoneNumbers: string[], label: string = null) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = await useIdentifier();
|
const _identifier = await getIdentifier(_source);
|
||||||
const result = await createMessageGroupsFromPhoneNumbers(
|
const result = await createMessageGroupsFromPhoneNumbers(
|
||||||
_identifier,
|
_identifier,
|
||||||
phoneNumbers,
|
phoneNumbers,
|
||||||
@@ -416,32 +418,40 @@ onNet(
|
|||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, getSource());
|
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, getSource());
|
||||||
messageLogger.error(`Failed to create message group, ${e.message}`);
|
messageLogger.error(`Failed to create message group, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
onNet(events.MESSAGES_FETCH_MESSAGES, async (groupId: string) => {
|
onNet(events.MESSAGES_FETCH_MESSAGES, async (groupId: string) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = await useIdentifier();
|
const _identifier = await getIdentifier(_source);
|
||||||
const messages = await getMessages(_identifier, groupId);
|
const messages = await getMessages(_identifier, groupId);
|
||||||
emitNet(events.MESSAGES_FETCH_MESSAGES_SUCCESS, getSource(), messages);
|
emitNet(events.MESSAGES_FETCH_MESSAGES_SUCCESS, _source, messages);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emitNet(events.MESSAGES_FETCH_MESSAGES_FAILED, getSource());
|
emitNet(events.MESSAGES_FETCH_MESSAGES_FAILED, _source);
|
||||||
messageLogger.error(`Failed to fetch messages, ${e.message}`);
|
messageLogger.error(`Failed to fetch messages, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(
|
onNet(
|
||||||
events.MESSAGES_SEND_MESSAGE,
|
events.MESSAGES_SEND_MESSAGE,
|
||||||
async (groupId: string, message: string) => {
|
async (groupId: string, message: string) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = await useIdentifier();
|
const _identifier = getIdentifier(_source);
|
||||||
await createMessage(_identifier, groupId, message);
|
await createMessage(_identifier, groupId, message);
|
||||||
emitNet(events.MESSAGES_SEND_MESSAGE_SUCCESS, getSource(), groupId);
|
emitNet(events.MESSAGES_SEND_MESSAGE_SUCCESS, _source, groupId);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emitNet(events.MESSAGES_SEND_MESSAGE_FAILED, getSource());
|
emitNet(events.MESSAGES_SEND_MESSAGE_FAILED, _source);
|
||||||
messageLogger.error(`Failed to send message, ${e.message}`);
|
messageLogger.error(`Failed to send message, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import events from '../utils/events';
|
import events from '../utils/events';
|
||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import { useIdentifier } from './functions';
|
import { getIdentifier, getSource } from './functions';
|
||||||
import { Note, NoteId } from '../../phone/src/common/typings/notes';
|
import { Note, NoteId } from '../../phone/src/common/typings/notes';
|
||||||
import { mainLogger } from './sv_logger';
|
import { mainLogger } from './sv_logger';
|
||||||
|
|
||||||
@@ -31,56 +31,79 @@ async function updateNote(note: Note, identifier: string): Promise<any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
||||||
|
const pSource = getSource();
|
||||||
try {
|
try {
|
||||||
const pSource = (global as any).source;
|
const _identifier = getIdentifier(pSource);
|
||||||
const _identifier = await useIdentifier();
|
|
||||||
await addNote(_identifier, note);
|
await addNote(_identifier, note);
|
||||||
emitNet(events.NOTE_SEND_NOTE_SUCCESS, pSource);
|
emitNet(events.NOTE_SEND_NOTE_SUCCESS, pSource);
|
||||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_ADD_SUCCESS', type: 'success' })
|
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||||
|
message: 'NOTES_ADD_SUCCESS',
|
||||||
|
type: 'success',
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const pSource = (global as any).source;
|
notesLogger.error(`Failed to add note ${e.message}`, {
|
||||||
notesLogger.error(`Failed to add note ${e.message}`);
|
source: pSource,
|
||||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_ADD_FAILED', type: 'error' })
|
});
|
||||||
|
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||||
|
message: 'NOTES_ADD_FAILED',
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.NOTE_FETCH_ALL_NOTES, async () => {
|
onNet(events.NOTE_FETCH_ALL_NOTES, async () => {
|
||||||
|
const pSource = getSource();
|
||||||
try {
|
try {
|
||||||
const pSource = (global as any).source;
|
const _identifier = await getIdentifier(pSource);
|
||||||
const _identifier = await useIdentifier();
|
|
||||||
const notes = await fetchAllNotes(_identifier);
|
const notes = await fetchAllNotes(_identifier);
|
||||||
emitNet(events.NOTE_SEND_NOTE, pSource, notes);
|
emitNet(events.NOTE_SEND_NOTE, pSource, notes);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
notesLogger.error(`Failed to fetch notes ${e.message}`);
|
notesLogger.error(`Failed to fetch notes ${e.message}`, {
|
||||||
|
source: pSource,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.NOTE_DELETE_NOTE, async (noteId: NoteId) => {
|
onNet(events.NOTE_DELETE_NOTE, async (noteId: NoteId) => {
|
||||||
|
const pSource = getSource();
|
||||||
try {
|
try {
|
||||||
const pSource = (global as any).source;
|
const _identifier = getIdentifier(pSource);
|
||||||
const _identifier = await useIdentifier();
|
|
||||||
await deleteNote(noteId.id, _identifier);
|
await deleteNote(noteId.id, _identifier);
|
||||||
|
|
||||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_DELETE_SUCCESS', type: 'success' })
|
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||||
|
message: 'NOTES_DELETE_SUCCESS',
|
||||||
|
type: 'success',
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const pSource = (global as any).source;
|
const pSource = (global as any).source;
|
||||||
notesLogger.error(`Failed to delete note, ${e.message}`);
|
notesLogger.error(`Failed to delete note, ${e.message}`);
|
||||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_DELETE_FAILED', type: 'error' })
|
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||||
|
message: 'NOTES_DELETE_FAILED',
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => {
|
onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => {
|
||||||
|
const pSource = getSource();
|
||||||
try {
|
try {
|
||||||
const pSource = (global as any).source;
|
const _identifier = await getIdentifier(pSource);
|
||||||
const _identifier = await useIdentifier();
|
|
||||||
await updateNote(note, _identifier);
|
await updateNote(note, _identifier);
|
||||||
emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, pSource);
|
emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, pSource);
|
||||||
|
|
||||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_UPDATE_SUCCESS', type: 'success' })
|
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||||
|
message: 'NOTES_UPDATE_SUCCESS',
|
||||||
|
type: 'success',
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const pSource = (global as any).source;
|
const pSource = (global as any).source;
|
||||||
emitNet(events.NOTE_UPDATE_NOTE_FAILURE, pSource);
|
emitNet(events.NOTE_UPDATE_NOTE_FAILURE, pSource);
|
||||||
notesLogger.error(`Failed to update note, ${e.message}`);
|
notesLogger.error(`Failed to update note, ${e.message}`, {
|
||||||
emitNet(events.NOTE_ACTION_RESULT, pSource, { message: 'NOTES_UPDATE_FAILED', type: 'error' })
|
source: pSource,
|
||||||
|
});
|
||||||
|
emitNet(events.NOTE_ACTION_RESULT, pSource, {
|
||||||
|
message: 'NOTES_UPDATE_FAILED',
|
||||||
|
type: 'error',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import events from '../utils/events';
|
import events from '../utils/events';
|
||||||
import { getSource } from './server';
|
|
||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import { useIdentifier } from './functions';
|
import { getIdentifier, getSource } from './functions';
|
||||||
import { IPhoto } from '../../phone/src/common/typings/photo';
|
import { IPhoto } from '../../phone/src/common/typings/photo';
|
||||||
import { mainLogger } from './sv_logger';
|
import { mainLogger } from './sv_logger';
|
||||||
|
|
||||||
@@ -28,28 +27,34 @@ async function deletePhoto(photo: IPhoto, identifier: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNet(events.CAMERA_UPLOAD_PHOTO, async (image: string) => {
|
onNet(events.CAMERA_UPLOAD_PHOTO, async (image: string) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const pSource = (global as any).source;
|
const identifier = getIdentifier(_source);
|
||||||
const identifier = await useIdentifier();
|
|
||||||
await uploadPhoto(identifier, image);
|
await uploadPhoto(identifier, image);
|
||||||
emitNet(events.CAMERA_UPLOAD_PHOTO_SUCCESS, pSource);
|
emitNet(events.CAMERA_UPLOAD_PHOTO_SUCCESS, _source);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
photoLogger.error(`Failed to upload photo, ${e.message}`);
|
photoLogger.error(`Failed to upload photo, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.CAMERA_FETCH_PHOTOS, async () => {
|
onNet(events.CAMERA_FETCH_PHOTOS, async () => {
|
||||||
const identifier = await useIdentifier();
|
const _source = getSource();
|
||||||
|
const identifier = getIdentifier(_source);
|
||||||
const photos = await getPhotosByIdentifier(identifier);
|
const photos = await getPhotosByIdentifier(identifier);
|
||||||
emitNet(events.CAMERA_SEND_PHOTOS, getSource(), photos);
|
emitNet(events.CAMERA_SEND_PHOTOS, source, photos);
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.CAMERA_DELETE_PHOTO, async (photo: IPhoto) => {
|
onNet(events.CAMERA_DELETE_PHOTO, async (photo: IPhoto) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const identifier = await useIdentifier();
|
const identifier = getIdentifier(_source);
|
||||||
await deletePhoto(photo, identifier);
|
await deletePhoto(photo, identifier);
|
||||||
emitNet(events.CAMERA_DELETE_PHOTO_SUCCESS, getSource());
|
emitNet(events.CAMERA_DELETE_PHOTO_SUCCESS, _source);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
photoLogger.error(`Failed to fetch photos, ${e.message}`);
|
photoLogger.error(`Failed to fetch photos, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -42,24 +42,29 @@ async function addListing(
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNet(events.SELLOUT_FETCH_LISTING, async () => {
|
onNet(events.SELLOUT_FETCH_LISTING, async () => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _source = (global as any).source;
|
|
||||||
const listings = await fetchAllListings();
|
const listings = await fetchAllListings();
|
||||||
emitNet(events.SELLOUT_SEND_LISTING, _source, listings);
|
emitNet(events.SELLOUT_SEND_LISTING, _source, listings);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
selloutLogger.error(`Failed to fetch listings, ${e.message}`);
|
selloutLogger.error(`Failed to fetch listings, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.SELLOUT_ADD_LISTING, async (listing: Listing) => {
|
onNet(events.SELLOUT_ADD_LISTING, async (listing: Listing) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const xPlayer = ESX.GetPlayerFromId(getSource());
|
const xPlayer = ESX.GetPlayerFromId(_source);
|
||||||
const _identifier = xPlayer.getIdentifier();
|
const _identifier = xPlayer.getIdentifier();
|
||||||
const name = xPlayer.getName();
|
const name = xPlayer.getName();
|
||||||
|
|
||||||
const phoneNumber = await usePhoneNumber(_identifier);
|
const phoneNumber = await usePhoneNumber(_identifier);
|
||||||
addListing(_identifier, name, phoneNumber, listing);
|
await addListing(_identifier, name, phoneNumber, listing);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
selloutLogger.error(`Failed to add listing ${e.message}`);
|
selloutLogger.error(`Failed to add listing ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import { ESX } from './server';
|
import { ESX } from './server';
|
||||||
import { getSource } from './functions';
|
import { getIdentifier, getSource } from './functions';
|
||||||
import { Tweet, Profile } from '../../phone/src/common/typings/twitter';
|
import { Tweet, Profile } from '../../phone/src/common/typings/twitter';
|
||||||
import events from '../utils/events';
|
import events from '../utils/events';
|
||||||
import config from '../utils/config';
|
import config from '../utils/config';
|
||||||
@@ -293,79 +293,98 @@ async function doesReportExist(
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNet(events.TWITTER_GET_OR_CREATE_PROFILE, async () => {
|
onNet(events.TWITTER_GET_OR_CREATE_PROFILE, async () => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const identifier = ESX.GetPlayerFromId(getSource()).getIdentifier();
|
const identifier = getIdentifier(_source);
|
||||||
const profile = await getOrCreateProfile(identifier);
|
const profile = await getOrCreateProfile(identifier);
|
||||||
emitNet(events.TWITTER_GET_OR_CREATE_PROFILE_SUCCESS, getSource(), profile);
|
emitNet(events.TWITTER_GET_OR_CREATE_PROFILE_SUCCESS, _source, profile);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
twitterLogger.error(`Failed to get or create profile, ${e.message}`);
|
twitterLogger.error(`Failed to get or create profile, ${e.message}`, {
|
||||||
emitNet(events.TWITTER_GET_OR_CREATE_PROFILE_FAILURE, getSource());
|
source: _source,
|
||||||
|
});
|
||||||
|
emitNet(events.TWITTER_GET_OR_CREATE_PROFILE_FAILURE, _source);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.TWITTER_UPDATE_PROFILE, async (profile: Profile) => {
|
onNet(events.TWITTER_UPDATE_PROFILE, async (profile: Profile) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const identifier = ESX.GetPlayerFromId(getSource()).getIdentifier();
|
const identifier = getIdentifier(_source);
|
||||||
await updateProfile(identifier, profile);
|
await updateProfile(identifier, profile);
|
||||||
emitNet(events.TWITTER_UPDATE_PROFILE_RESULT, getSource(), true);
|
emitNet(events.TWITTER_UPDATE_PROFILE_RESULT, _source, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
twitterLogger.error(`Failed to update twitter profile: ${e.message}`);
|
twitterLogger.error(`Failed to update twitter profile: ${e.message}`, {
|
||||||
emitNet(events.TWITTER_UPDATE_PROFILE_RESULT, getSource(), false);
|
source: _source,
|
||||||
|
});
|
||||||
|
emitNet(events.TWITTER_UPDATE_PROFILE_RESULT, _source, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.TWITTER_FETCH_TWEETS, async () => {
|
onNet(events.TWITTER_FETCH_TWEETS, async () => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const identifier = ESX.GetPlayerFromId(getSource()).getIdentifier();
|
const identifier = getIdentifier(_source);
|
||||||
const profile = await getProfile(identifier);
|
const profile = await getProfile(identifier);
|
||||||
const tweets = await fetchAllTweets(profile.id);
|
const tweets = await fetchAllTweets(profile.id);
|
||||||
emitNet(events.TWITTER_FETCH_TWEETS_SUCCESS, getSource(), tweets);
|
emitNet(events.TWITTER_FETCH_TWEETS_SUCCESS, _source, tweets);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
twitterLogger.error(`Fetching tweets failed, ${e.message}`);
|
twitterLogger.error(`Fetching tweets failed, ${e.message}`, {
|
||||||
emitNet(events.TWITTER_FETCH_TWEETS_FAILURE, getSource());
|
source: _source,
|
||||||
|
});
|
||||||
|
emitNet(events.TWITTER_FETCH_TWEETS_FAILURE, _source);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.TWITTER_FETCH_TWEETS_FILTERED, async (searchValue: string) => {
|
onNet(events.TWITTER_FETCH_TWEETS_FILTERED, async (searchValue: string) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const identifier = ESX.GetPlayerFromId(getSource()).getIdentifier();
|
const identifier = getIdentifier(_source);
|
||||||
const profile = await getProfile(identifier);
|
const profile = await getProfile(identifier);
|
||||||
const tweets = await fetchTweetsFiltered(profile.id, searchValue);
|
const tweets = await fetchTweetsFiltered(profile.id, searchValue);
|
||||||
emitNet(events.TWITTER_FETCH_TWEETS_FILTERED_SUCCESS, getSource(), tweets);
|
emitNet(events.TWITTER_FETCH_TWEETS_FILTERED_SUCCESS, _source, tweets);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
twitterLogger.error(`Fetch filtered tweets failed, ${e.message}`);
|
twitterLogger.error(`Fetch filtered tweets failed, ${e.message}`, {
|
||||||
emitNet(events.TWITTER_FETCH_TWEETS_FILTERED_FAILURE, getSource());
|
source: _source,
|
||||||
|
});
|
||||||
|
emitNet(events.TWITTER_FETCH_TWEETS_FILTERED_FAILURE, _source);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.TWITTER_CREATE_TWEET, async (tweet: Tweet) => {
|
onNet(events.TWITTER_CREATE_TWEET, async (tweet: Tweet) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const identifier = ESX.GetPlayerFromId(getSource()).getIdentifier();
|
const identifier = getIdentifier(_source);
|
||||||
const createdTweet = await createTweet(identifier, tweet);
|
const createdTweet = await createTweet(identifier, tweet);
|
||||||
|
|
||||||
emitNet(events.TWITTER_CREATE_TWEET_RESULT, getSource(), true);
|
emitNet(events.TWITTER_CREATE_TWEET_RESULT, _source, true);
|
||||||
emitNet(events.TWITTER_CREATE_TWEET_BROADCAST, -1, createdTweet);
|
emitNet(events.TWITTER_CREATE_TWEET_BROADCAST, -1, createdTweet);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
twitterLogger.error(`Create tweet failed, ${e.message}`);
|
twitterLogger.error(`Create tweet failed, ${e.message}`, {
|
||||||
emitNet(events.TWITTER_CREATE_TWEET_RESULT, getSource(), false);
|
source: _source,
|
||||||
|
});
|
||||||
|
emitNet(events.TWITTER_CREATE_TWEET_RESULT, _source, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.TWITTER_DELETE_TWEET, async (tweetId: number) => {
|
onNet(events.TWITTER_DELETE_TWEET, async (tweetId: number) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const identifier = ESX.GetPlayerFromId(getSource()).getIdentifier();
|
const identifier = getIdentifier(_source);
|
||||||
await deleteTweet(identifier, tweetId);
|
await deleteTweet(identifier, tweetId);
|
||||||
|
|
||||||
emitNet(events.TWITTER_DELETE_TWEET_SUCCESS, getSource());
|
emitNet(events.TWITTER_DELETE_TWEET_SUCCESS, _source);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
twitterLogger.error(`Delete tweet failed, ${e.message}`);
|
twitterLogger.error(`Delete tweet failed, ${e.message}`, {
|
||||||
emitNet(events.TWITTER_DELETE_TWEET_FAILURE, getSource());
|
source: _source,
|
||||||
|
});
|
||||||
|
emitNet(events.TWITTER_DELETE_TWEET_FAILURE, _source);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.TWITTER_TOGGLE_LIKE, async (tweetId: number) => {
|
onNet(events.TWITTER_TOGGLE_LIKE, async (tweetId: number) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const identifier = ESX.GetPlayerFromId(getSource()).getIdentifier();
|
const identifier = getIdentifier(_source);
|
||||||
const profile = await getOrCreateProfile(identifier);
|
const profile = await getOrCreateProfile(identifier);
|
||||||
const likeExists = await doesLikeExist(profile.id, tweetId);
|
const likeExists = await doesLikeExist(profile.id, tweetId);
|
||||||
if (likeExists) {
|
if (likeExists) {
|
||||||
@@ -373,16 +392,19 @@ onNet(events.TWITTER_TOGGLE_LIKE, async (tweetId: number) => {
|
|||||||
} else {
|
} else {
|
||||||
await createLike(profile.id, tweetId);
|
await createLike(profile.id, tweetId);
|
||||||
}
|
}
|
||||||
emitNet(events.TWITTER_TOGGLE_LIKE_SUCCESS, getSource());
|
emitNet(events.TWITTER_TOGGLE_LIKE_SUCCESS, _source);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
twitterLogger.error(`Like failed, ${e.message}`);
|
twitterLogger.error(`Like failed, ${e.message}`, {
|
||||||
emitNet(events.TWITTER_TOGGLE_LIKE_FAILURE, getSource());
|
source: _source,
|
||||||
|
});
|
||||||
|
emitNet(events.TWITTER_TOGGLE_LIKE_FAILURE, _source);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(events.TWITTER_REPORT, async (tweetId: number) => {
|
onNet(events.TWITTER_REPORT, async (tweetId: number) => {
|
||||||
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const identifier = ESX.GetPlayerFromId(getSource()).getIdentifier();
|
const identifier = getIdentifier(_source);
|
||||||
const profile = await getProfile(identifier);
|
const profile = await getProfile(identifier);
|
||||||
const tweet = await getTweet(profile.id, tweetId);
|
const tweet = await getTweet(profile.id, tweetId);
|
||||||
|
|
||||||
@@ -394,9 +416,11 @@ onNet(events.TWITTER_REPORT, async (tweetId: number) => {
|
|||||||
await reportTweetToDiscord(tweet, profile);
|
await reportTweetToDiscord(tweet, profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
emitNet(events.TWITTER_REPORT_SUCCESS, getSource());
|
emitNet(events.TWITTER_REPORT_SUCCESS, _source);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emitNet(events.TWITTER_REPORT_FAILURE, getSource());
|
emitNet(events.TWITTER_REPORT_FAILURE, _source);
|
||||||
twitterLogger.error(`Twitter report failed, ${e.message}`);
|
twitterLogger.error(`Twitter report failed, ${e.message}`, {
|
||||||
|
source: _source,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user