mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
feat(resources): remove all esx code, almost
This commit is contained in:
1 parent
6b6080c4b2
commit
c99d0780ae
12 files changed
+117
-80
No files matched your search
@@ -5,6 +5,13 @@ import { phoneCloseAnim, phoneOpenAnim, removePhoneProp } from './functions';
|
|||||||
let isPhoneOpen = false;
|
let isPhoneOpen = false;
|
||||||
let isPhoneReady = false;
|
let isPhoneReady = false;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (NetworkIsPlayerActive(PlayerId())) {
|
||||||
|
emitNet(events.PHONE_IS_READY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* * * * * * * * * * * * *
|
/* * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Phone initialize data
|
* Phone initialize data
|
||||||
@@ -19,7 +26,7 @@ function fetchOnInitialize() {
|
|||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
app: 'PHONE',
|
app: 'PHONE',
|
||||||
method: 'setPhoneReady',
|
method: 'setPhoneReady',
|
||||||
data: true,
|
data: isPhoneReady,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -110,7 +117,8 @@ async function Phone(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onNet('esx:playerLoaded', fetchOnInitialize);
|
// triggerd when the player is ready
|
||||||
|
onNet(events.PHONE_IS_READY, fetchOnInitialize);
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function (resource: string) {
|
AddEventHandler('onResourceStop', function (resource: string) {
|
||||||
if (resource === GetCurrentResourceName()) {
|
if (resource === GetCurrentResourceName()) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import { IPlayer } from '../typings/players';
|
||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import { ESX } from './server';
|
import { Players } from './sv_main';
|
||||||
import { XPlayer } from 'esx.js/@types/server';
|
|
||||||
|
|
||||||
interface IPhoneNumber {
|
interface IPhoneNumber {
|
||||||
phone_number: string;
|
phone_number: string;
|
||||||
@@ -10,11 +10,27 @@ interface Identifier {
|
|||||||
identifier: string;
|
identifier: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function usePhoneNumber(identifier: string): Promise<string> {
|
export async function usePlayer(
|
||||||
const query = 'SELECT phone_number FROM users WHERE identifier = ?';
|
identifier: string,
|
||||||
|
): Promise<Pick<IPlayer, 'name' | 'phone_number'>> {
|
||||||
|
const query = `SELECT firstname, lastname, phone_number FROM users WHERE identifier = ?`;
|
||||||
const [results] = await pool.query(query, [identifier]);
|
const [results] = await pool.query(query, [identifier]);
|
||||||
const phoneNumber = <IPhoneNumber[]>results;
|
const creds = <{ firstname: string; lastname: string; phone_number: string }[]>results;
|
||||||
return phoneNumber[0].phone_number;
|
|
||||||
|
const name = `${creds[0].firstname} ${creds[0].lastname}`;
|
||||||
|
const phone_number = creds[0].phone_number;
|
||||||
|
|
||||||
|
return { name, phone_number };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function usePhoneNumber(identifier: string) {
|
||||||
|
const player = getPlayerFromIdentifier(identifier);
|
||||||
|
return player?.phone_number || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useName(identifer: string) {
|
||||||
|
const player = getPlayerFromIdentifier(identifer);
|
||||||
|
return player?.name || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getSource = () => (global as any).source;
|
export const getSource = () => (global as any).source;
|
||||||
@@ -22,7 +38,8 @@ export const getSource = () => (global as any).source;
|
|||||||
// we might need to run a db query on this.
|
// we might need to run a db query on this.
|
||||||
// to make it more standalone
|
// to make it more standalone
|
||||||
export function getIdentifier(source: number): string {
|
export function getIdentifier(source: number): string {
|
||||||
return ESX.GetPlayerFromId(source).getIdentifier();
|
const player = getPlayerBySource(source);
|
||||||
|
return player?.identifier || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getIdentifierByPhoneNumber(phoneNumber: string): Promise<string> {
|
export async function getIdentifierByPhoneNumber(phoneNumber: string): Promise<string> {
|
||||||
@@ -32,26 +49,19 @@ export async function getIdentifierByPhoneNumber(phoneNumber: string): Promise<s
|
|||||||
return identifier[0].identifier;
|
return identifier[0].identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getPlayerBySource = (source: any) => {
|
||||||
|
return Players.get(source);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player phoneNumber for a passed identifier
|
* Returns the player phoneNumber for a passed identifier
|
||||||
* @param identifier The players phone number
|
* @param identifier The players phone number
|
||||||
*/
|
*/
|
||||||
export async function getPlayerFromIdentifier(
|
export function getPlayerFromIdentifier(identifier: string) {
|
||||||
identifier: string
|
for (const player of Array.from(Players.entries())) {
|
||||||
): Promise<XPlayer> {
|
if (player[1].identifier === identifier) {
|
||||||
return new Promise((res, rej) => {
|
return player[1];
|
||||||
const xPlayers = ESX.GetPlayers();
|
|
||||||
|
|
||||||
for (const player of xPlayers) {
|
|
||||||
const xPlayer = ESX.GetPlayerFromId(player);
|
|
||||||
if (
|
|
||||||
xPlayer.getIdentifier() != null &&
|
|
||||||
xPlayer.getIdentifier() == identifier
|
|
||||||
) {
|
|
||||||
res(xPlayer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
rej(new Error('Call Target Identifier was not found in xPlayers array'));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ async function getTransfer(transferId: number): Promise<Transfer> {
|
|||||||
onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = await getIdentifier(_source);
|
const _identifier = getIdentifier(_source);
|
||||||
const transfer = await fetchAllTransactions(_identifier);
|
const transfer = await fetchAllTransactions(_identifier);
|
||||||
|
|
||||||
emitNet(events.BANK_SEND_TRANSFERS, _source, transfer);
|
emitNet(events.BANK_SEND_TRANSFERS, _source, transfer);
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
import { ESX } from './server';
|
|
||||||
import events from '../utils/events';
|
import events from '../utils/events';
|
||||||
import {
|
import { getIdentifierByPhoneNumber, usePhoneNumber, getIdentifier, getSource } from './functions';
|
||||||
getIdentifierByPhoneNumber,
|
|
||||||
usePhoneNumber,
|
|
||||||
getIdentifier,
|
|
||||||
getSource,
|
|
||||||
} from './functions';
|
|
||||||
|
|
||||||
import { getPlayerFromIdentifier } from './functions'
|
import { getPlayerFromIdentifier } from './functions';
|
||||||
import { ICall } from '../../phone/src/common/typings/call';
|
import { ICall } from '../../phone/src/common/typings/call';
|
||||||
|
|
||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
@@ -42,12 +36,11 @@ onNet(events.PHONE_INITIALIZE_CALL, async (phoneNumber: string, timestamp: numbe
|
|||||||
const callIdentifier = uuidv4();
|
const callIdentifier = uuidv4();
|
||||||
|
|
||||||
// the client that is calling
|
// the client that is calling
|
||||||
const xTransmitter = ESX.GetPlayerFromId(_source);
|
const transmitterNumber = usePhoneNumber(getIdentifier(_source));
|
||||||
const transmitterNumber = await usePhoneNumber(xTransmitter.getIdentifier());
|
|
||||||
|
|
||||||
// player who is being called
|
// player who is being called
|
||||||
const receiverIdentifier = await getIdentifierByPhoneNumber(phoneNumber);
|
const receiverIdentifier = await getIdentifierByPhoneNumber(phoneNumber);
|
||||||
const xReceiver = await getPlayerFromIdentifier(receiverIdentifier);
|
const xReceiver = getPlayerFromIdentifier(receiverIdentifier);
|
||||||
const receiverNumber = phoneNumber;
|
const receiverNumber = phoneNumber;
|
||||||
|
|
||||||
calls.set(transmitterNumber, {
|
calls.set(transmitterNumber, {
|
||||||
@@ -144,8 +137,8 @@ onNet(events.PHONE_END_CALL, async (transmitterNumber: string, timestamp: number
|
|||||||
onNet(events.PHONE_CALL_FETCH_CALLS, async () => {
|
onNet(events.PHONE_CALL_FETCH_CALLS, async () => {
|
||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const identifier = await getIdentifier(_source);
|
const identifier = getIdentifier(_source);
|
||||||
const phoneNumber = await usePhoneNumber(identifier);
|
const phoneNumber = usePhoneNumber(identifier);
|
||||||
const calls = await fetchCalls(phoneNumber);
|
const calls = await fetchCalls(phoneNumber);
|
||||||
emitNet(events.PHONE_CALL_SEND_HISTORY, _source, calls);
|
emitNet(events.PHONE_CALL_SEND_HISTORY, _source, calls);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { ESX } from './server';
|
|
||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import events from '../utils/events';
|
import events from '../utils/events';
|
||||||
import { getIdentifier, getSource } from './functions';
|
import { getIdentifier, getSource } from './functions';
|
||||||
@@ -89,7 +88,7 @@ onNet(events.CONTACTS_ADD_CONTACT, async (number: string, display: string, avata
|
|||||||
onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = ESX.GetPlayerFromId(_source).getIdentifier();
|
const _identifier = getIdentifier(_source);
|
||||||
await updateContact(contact, _identifier);
|
await updateContact(contact, _identifier);
|
||||||
|
|
||||||
emitNet(events.CONTACTS_UPDATE_CONTACT_SUCCESS, _source);
|
emitNet(events.CONTACTS_UPDATE_CONTACT_SUCCESS, _source);
|
||||||
@@ -113,7 +112,7 @@ onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
|||||||
onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
|
onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => {
|
||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = await getIdentifier(_source);
|
const _identifier = getIdentifier(_source);
|
||||||
await deleteContact(contact, _identifier);
|
await deleteContact(contact, _identifier);
|
||||||
emitNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, _source);
|
emitNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, _source);
|
||||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||||
|
|||||||
+46
-20
@@ -1,10 +1,10 @@
|
|||||||
import { ESX } from './server';
|
|
||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import config from '../utils/config';
|
import config from '../utils/config';
|
||||||
import { getIdentifier, getIdentifierByPhoneNumber, getSource, usePhoneNumber } from './functions';
|
import { getIdentifier, getIdentifierByPhoneNumber, getSource, usePlayer } from './functions';
|
||||||
import { getOrCreateProfile } from './sv_twitter';
|
|
||||||
import { mainLogger } from './sv_logger';
|
import { mainLogger } from './sv_logger';
|
||||||
|
import { IPlayer } from '../typings/players';
|
||||||
import events from '../utils/events';
|
import events from '../utils/events';
|
||||||
|
import { getOrCreateProfile } from './sv_twitter';
|
||||||
|
|
||||||
//db = DatabaseConfig //helper variable for use in server function
|
//db = DatabaseConfig //helper variable for use in server function
|
||||||
|
|
||||||
@@ -18,6 +18,43 @@ interface Credentials {
|
|||||||
phone_number: string;
|
phone_number: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const Players = new Map<string, IPlayer>();
|
||||||
|
|
||||||
|
// gets the identifers
|
||||||
|
onNet(events.PHONE_IS_READY, async () => {
|
||||||
|
const pSource = (global as any).source;
|
||||||
|
|
||||||
|
let identifier = null;
|
||||||
|
|
||||||
|
for (let i = 0; i < GetNumPlayerIdentifiers(pSource); i++) {
|
||||||
|
const identifiers = GetPlayerIdentifier(pSource, i);
|
||||||
|
|
||||||
|
if (identifiers.includes('license')) {
|
||||||
|
identifier = identifiers.split(':')[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('PHONE IS READY: ', identifier);
|
||||||
|
|
||||||
|
if (!identifier) {
|
||||||
|
throw new Error('Identifier could not be found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await generatePhoneNumber(identifier);
|
||||||
|
} catch (e) {
|
||||||
|
mainLogger.error(`Failed to generate a phone number, ${e.message}`, {
|
||||||
|
source: pSource,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const { name, phone_number } = await usePlayer(identifier);
|
||||||
|
|
||||||
|
Players.set(pSource, { identifier, source: pSource, name, phone_number });
|
||||||
|
|
||||||
|
emitNet(events.PHONE_IS_READY, pSource);
|
||||||
|
});
|
||||||
|
|
||||||
// Generate phone number
|
// Generate phone number
|
||||||
|
|
||||||
function getRandomPhoneNumber() {
|
function getRandomPhoneNumber() {
|
||||||
@@ -38,7 +75,12 @@ function getRandomPhoneNumber() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function generatePhoneNumber(identifier: string) {
|
async function generatePhoneNumber(identifier: string) {
|
||||||
if (!(await usePhoneNumber(identifier))) {
|
const getQuery = `SELECT phone_number FROM users WHERE identifier = ?`;
|
||||||
|
const [results] = await pool.query(getQuery, [identifier]);
|
||||||
|
const result = <any[]>results;
|
||||||
|
const phoneNumber = result[0]?.phone_number;
|
||||||
|
|
||||||
|
if (!phoneNumber) {
|
||||||
let existingId;
|
let existingId;
|
||||||
let newNumber;
|
let newNumber;
|
||||||
do {
|
do {
|
||||||
@@ -63,22 +105,6 @@ async function getCredentials(identifier: string): Promise<string> {
|
|||||||
return number[0].phone_number;
|
return number[0].phone_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
onNet('esx:playerLoaded', async (playerId: number, xPlayer: any) => {
|
|
||||||
const _source = getSource();
|
|
||||||
const identifier = xPlayer.identifier;
|
|
||||||
try {
|
|
||||||
await generatePhoneNumber(identifier);
|
|
||||||
} catch (e) {
|
|
||||||
mainLogger.error(`Failed to generate a phone number, ${e.message}`, {
|
|
||||||
source: _source,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure a twitter profile exists for this user before
|
|
||||||
// we load the phone
|
|
||||||
await getOrCreateProfile(identifier);
|
|
||||||
});
|
|
||||||
|
|
||||||
onNet('phone:getCredentials', async () => {
|
onNet('phone:getCredentials', async () => {
|
||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ onNet(
|
|||||||
async (phoneNumbers: string[], label: string = null) => {
|
async (phoneNumbers: string[], label: string = null) => {
|
||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = await getIdentifier(_source);
|
const _identifier = getIdentifier(_source);
|
||||||
const result = await createMessageGroupsFromPhoneNumbers(_identifier, phoneNumbers, label);
|
const result = await createMessageGroupsFromPhoneNumbers(_identifier, phoneNumbers, label);
|
||||||
|
|
||||||
if (result.error && result.duplicate) {
|
if (result.error && result.duplicate) {
|
||||||
@@ -439,7 +439,7 @@ onNet(
|
|||||||
for (const participantId of result.identifiers) {
|
for (const participantId of result.identifiers) {
|
||||||
// we don't broadcast to the source of the event.
|
// we don't broadcast to the source of the event.
|
||||||
if (participantId !== _identifier) {
|
if (participantId !== _identifier) {
|
||||||
const participantPlayer = await getPlayerFromIdentifier(participantId);
|
const participantPlayer = getPlayerFromIdentifier(participantId);
|
||||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS, participantPlayer.source);
|
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS, participantPlayer.source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -463,7 +463,7 @@ onNet(
|
|||||||
onNet(events.MESSAGES_FETCH_MESSAGES, async (groupId: string) => {
|
onNet(events.MESSAGES_FETCH_MESSAGES, async (groupId: string) => {
|
||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = await getIdentifier(_source);
|
const _identifier = getIdentifier(_source);
|
||||||
const messages = await getMessages(_identifier, groupId);
|
const messages = await getMessages(_identifier, groupId);
|
||||||
emitNet(events.MESSAGES_FETCH_MESSAGES_SUCCESS, _source, messages);
|
emitNet(events.MESSAGES_FETCH_MESSAGES_SUCCESS, _source, messages);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -489,7 +489,7 @@ onNet(events.MESSAGES_SEND_MESSAGE, async (groupId: string, message: string, gro
|
|||||||
for (const participantId of userParticipants) {
|
for (const participantId of userParticipants) {
|
||||||
// we don't broadcast to the source of the event.
|
// we don't broadcast to the source of the event.
|
||||||
if (participantId !== _identifier) {
|
if (participantId !== _identifier) {
|
||||||
const participantPlayer = await getPlayerFromIdentifier(participantId);
|
const participantPlayer = getPlayerFromIdentifier(participantId);
|
||||||
emitNet(events.MESSAGES_CREATE_MESSAGE_BROADCAST, participantPlayer.source, {
|
emitNet(events.MESSAGES_CREATE_MESSAGE_BROADCAST, participantPlayer.source, {
|
||||||
groupName,
|
groupName,
|
||||||
groupId,
|
groupId,
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
|
|||||||
onNet(events.NOTE_FETCH_ALL_NOTES, async () => {
|
onNet(events.NOTE_FETCH_ALL_NOTES, async () => {
|
||||||
const pSource = getSource();
|
const pSource = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = await getIdentifier(pSource);
|
const _identifier = getIdentifier(pSource);
|
||||||
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) {
|
||||||
@@ -84,7 +84,7 @@ onNet(events.NOTE_DELETE_NOTE, async (noteId: NoteId) => {
|
|||||||
onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => {
|
onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => {
|
||||||
const pSource = getSource();
|
const pSource = getSource();
|
||||||
try {
|
try {
|
||||||
const _identifier = await getIdentifier(pSource);
|
const _identifier = getIdentifier(pSource);
|
||||||
await updateNote(note, _identifier);
|
await updateNote(note, _identifier);
|
||||||
emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, pSource);
|
emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, pSource);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import events from '../utils/events';
|
import events from '../utils/events';
|
||||||
import { ESX } from './server';
|
import { ESX } from './server';
|
||||||
import { getIdentifier, getSource } from './functions';
|
import { getIdentifier, getPlayerBySource, getSource } from './functions';
|
||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import { usePhoneNumber } from './functions';
|
|
||||||
import { mainLogger } from './sv_logger';
|
import { mainLogger } from './sv_logger';
|
||||||
import { MarketplaceListing } from '../../phone/src/common/typings/marketplace';
|
import { MarketplaceListing } from '../../phone/src/common/typings/marketplace';
|
||||||
import { reportListingToDiscord } from './discord';
|
import { reportListingToDiscord } from './discord';
|
||||||
@@ -82,15 +81,12 @@ onNet(events.SELLOUT_FETCH_LISTING, async () => {
|
|||||||
onNet(events.SELLOUT_ADD_LISTING, async (listing: MarketplaceListing) => {
|
onNet(events.SELLOUT_ADD_LISTING, async (listing: MarketplaceListing) => {
|
||||||
const _source = getSource();
|
const _source = getSource();
|
||||||
try {
|
try {
|
||||||
const xPlayer = ESX.GetPlayerFromId(_source);
|
const player = getPlayerBySource(_source);
|
||||||
const _identifier = xPlayer.getIdentifier();
|
|
||||||
const name = xPlayer.getName();
|
|
||||||
|
|
||||||
// This is used as username for the reports
|
// This is used as username for the reports
|
||||||
const playerName = GetPlayerName(_source);
|
const username = GetPlayerName(_source);
|
||||||
|
|
||||||
const phoneNumber = await usePhoneNumber(_identifier);
|
await addListing(player.identifier, username, player.name, player.phone_number, listing);
|
||||||
await addListing(_identifier, playerName, name, phoneNumber, listing);
|
|
||||||
|
|
||||||
emitNet(events.SELLOUT_ADD_LISTING_SUCCESS, _source);
|
emitNet(events.SELLOUT_ADD_LISTING_SUCCESS, _source);
|
||||||
emitNet(events.SELLOUT_ACTION_RESULT, _source, {
|
emitNet(events.SELLOUT_ACTION_RESULT, _source, {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { pool } from './db';
|
import { pool } from './db';
|
||||||
import { ESX } from './server';
|
|
||||||
import { getIdentifier, getSource } from './functions';
|
import { getIdentifier, getSource } from './functions';
|
||||||
import { NewTweet, Tweet, Profile } from '../../phone/src/common/typings/twitter';
|
import { NewTweet, Tweet, Profile } from '../../phone/src/common/typings/twitter';
|
||||||
import events from '../utils/events';
|
import events from '../utils/events';
|
||||||
@@ -38,7 +37,7 @@ const SELECT_FIELDS = `
|
|||||||
npwd_twitter_tweets.createdAt,
|
npwd_twitter_tweets.createdAt,
|
||||||
npwd_twitter_tweets.updatedAt,
|
npwd_twitter_tweets.updatedAt,
|
||||||
TIME_TO_SEC(TIMEDIFF( NOW(), npwd_twitter_tweets.createdAt)) AS seconds_since_tweet
|
TIME_TO_SEC(TIMEDIFF( NOW(), npwd_twitter_tweets.createdAt)) AS seconds_since_tweet
|
||||||
`
|
`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the latest 100 tweets
|
* Retrieve the latest 100 tweets
|
||||||
@@ -204,7 +203,6 @@ export async function getOrCreateProfile(identifier: string): Promise<Profile> {
|
|||||||
return profile || (await createDefaultProfile(identifier));
|
return profile || (await createDefaultProfile(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function updateProfile(identifier: string, profile: Profile) {
|
async function updateProfile(identifier: string, profile: Profile) {
|
||||||
const { avatar_url, profile_name, bio, location, job } = profile;
|
const { avatar_url, profile_name, bio, location, job } = profile;
|
||||||
const query = `
|
const query = `
|
||||||
@@ -299,7 +297,7 @@ async function doesRetweetExist(tweetId: number, identifier: string): Promise<bo
|
|||||||
SELECT COUNT(id) as count
|
SELECT COUNT(id) as count
|
||||||
FROM npwd_twitter_tweets
|
FROM npwd_twitter_tweets
|
||||||
WHERE (id = ? OR retweet = ?) AND identifier = ?
|
WHERE (id = ? OR retweet = ?) AND identifier = ?
|
||||||
`
|
`;
|
||||||
const [results] = await pool.query(query, [tweetId, tweetId, identifier]);
|
const [results] = await pool.query(query, [tweetId, tweetId, identifier]);
|
||||||
const counts = <any[]>results;
|
const counts = <any[]>results;
|
||||||
return counts[0].count > 0;
|
return counts[0].count > 0;
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export interface IPlayer {
|
||||||
|
identifier: string;
|
||||||
|
source: number;
|
||||||
|
name: string;
|
||||||
|
phone_number: string;
|
||||||
|
}
|
||||||
@@ -95,6 +95,7 @@ export default {
|
|||||||
NOTE_ACTION_RESULT: 'phone:notesActionResult',
|
NOTE_ACTION_RESULT: 'phone:notesActionResult',
|
||||||
|
|
||||||
// DO NOT CHANGE WHATS BELOW, PLEASE - CHIP
|
// DO NOT CHANGE WHATS BELOW, PLEASE - CHIP
|
||||||
|
PHONE_IS_READY: 'phone:isReady',
|
||||||
OPEN_APP_CONTACTS: 'phone:app:CONTACTS',
|
OPEN_APP_CONTACTS: 'phone:app:CONTACTS',
|
||||||
OPEN_APP_BANK: 'phone:app:BANK',
|
OPEN_APP_BANK: 'phone:app:BANK',
|
||||||
OPEN_APP_NOTES: 'phone:app:NOTES',
|
OPEN_APP_NOTES: 'phone:app:NOTES',
|
||||||
|
|||||||
Reference in new issue
Block a user