From ec1451a9aaff363fcfb1107bea290e77422fce8e Mon Sep 17 00:00:00 2001 From: Taso Date: Wed, 13 Jan 2021 20:32:09 -0500 Subject: [PATCH] Fix: prettier config in `resources\` not being standard. --- resources/.prettierrc | 2 +- resources/client/cl_bank.ts | 18 ++-- resources/client/cl_contacts.ts | 10 +- resources/client/cl_main.ts | 104 ++++++++++---------- resources/client/cl_messages.ts | 6 +- resources/client/cl_notes.ts | 6 +- resources/client/cl_photo.ts | 34 +++---- resources/client/cl_sellout.ts | 8 +- resources/client/cl_twitter.ts | 4 +- resources/client/client.ts | 20 ++-- resources/server/db.ts | 12 +-- resources/server/db_utils.test.ts | 64 ++++++------ resources/server/db_utils.ts | 16 +-- resources/server/discord.ts | 18 ++-- resources/server/functions.ts | 8 +- resources/server/server.ts | 22 ++--- resources/server/sv_bank.ts | 34 +++---- resources/server/sv_contacts.ts | 30 +++--- resources/server/sv_main.ts | 24 ++--- resources/server/sv_messages.ts | 18 ++-- resources/server/sv_notes.ts | 22 ++--- resources/server/sv_photo.ts | 16 +-- resources/server/sv_sellout.ts | 16 +-- resources/server/sv_twitter.ts | 18 ++-- resources/utils/apps.ts | 4 +- resources/utils/config.ts | 4 +- resources/utils/events.ts | 158 +++++++++++++++--------------- resources/utils/messages.ts | 2 +- 28 files changed, 349 insertions(+), 349 deletions(-) diff --git a/resources/.prettierrc b/resources/.prettierrc index f0eb61e..0a72520 100644 --- a/resources/.prettierrc +++ b/resources/.prettierrc @@ -2,5 +2,5 @@ "trailingComma": "es5", "tabWidth": 2, "semi": true, - "singleQuote": false + "singleQuote": true } diff --git a/resources/client/cl_bank.ts b/resources/client/cl_bank.ts index f1951c1..2657cc7 100644 --- a/resources/client/cl_bank.ts +++ b/resources/client/cl_bank.ts @@ -1,10 +1,10 @@ -import events from "../utils/events"; +import events from '../utils/events'; onNet(events.BANK_SEND_TRANSFERS, (transfer: any) => { SendNuiMessage( JSON.stringify({ - app: "BANK", - method: "setTransaction", + app: 'BANK', + method: 'setTransaction', data: transfer, }) ); @@ -13,8 +13,8 @@ onNet(events.BANK_SEND_TRANSFERS, (transfer: any) => { onNet(events.BANK_SEND_CREDENTIALS, (credentials: any) => { SendNuiMessage( JSON.stringify({ - app: "BANK", - method: "setCredentials", + app: 'BANK', + method: 'setCredentials', data: credentials, }) ); @@ -33,8 +33,8 @@ onNet(events.BANK_ADD_TRANSFER_SUCCESS, () => { onNet(events.BANK_TRANSACTION_ALERT, (bool: boolean) => { SendNuiMessage( JSON.stringify({ - app: "BANK", - method: "setAlert", + app: 'BANK', + method: 'setAlert', data: bool, }) ); @@ -43,8 +43,8 @@ onNet(events.BANK_TRANSACTION_ALERT, (bool: boolean) => { onNet(events.BANK_TRANSACTION_NOTIFICATION, (transfer: any) => { SendNuiMessage( JSON.stringify({ - app: "BANK", - method: "setNotification", + app: 'BANK', + method: 'setNotification', data: transfer, }) ); diff --git a/resources/client/cl_contacts.ts b/resources/client/cl_contacts.ts index 8068e5a..a746a60 100644 --- a/resources/client/cl_contacts.ts +++ b/resources/client/cl_contacts.ts @@ -1,10 +1,10 @@ -import events from "../utils/events"; +import events from '../utils/events'; onNet(events.CONTACTS_SEND_CONTACTS, (contacts: any) => { SendNuiMessage( JSON.stringify({ - app: "CONTACTS", - method: "setContacts", + app: 'CONTACTS', + method: 'setContacts', data: contacts, }) ); @@ -45,8 +45,8 @@ onNet(events.CONTACTS_DELETE_CONTACT_SUCCESS, () => { onNet(events.CONTACTS_ACTION_RESULT, (result: string) => { SendNuiMessage( JSON.stringify({ - app: "CONTACTS", - method: "setAlert", + app: 'CONTACTS', + method: 'setAlert', data: result, }) ); diff --git a/resources/client/cl_main.ts b/resources/client/cl_main.ts index 875a173..ab104d8 100644 --- a/resources/client/cl_main.ts +++ b/resources/client/cl_main.ts @@ -1,17 +1,17 @@ -import { ESX } from "../client/client"; -import config from "../utils/config"; -import { Delay } from "../utils/fivem"; -import events from "../utils/events"; +import { ESX } from '../client/client'; +import config from '../utils/config'; +import { Delay } from '../utils/fivem'; +import events from '../utils/events'; RegisterCommand( - "phone:close", + 'phone:close', (source: any, args: string[], raw: any) => { phoneCloseAnim(); SetNuiFocus(false, false); SendNuiMessage( JSON.stringify({ - app: "PHONE", - method: "setVisibility", + app: 'PHONE', + method: 'setVisibility', data: false, }) ); @@ -22,7 +22,7 @@ RegisterCommand( let prop = 0; let isPhoneOpen = false; let propCreated = false; -let phoneModel = "prop_amb_phone"; // Refered to in newphoneProp function. Requires custom phone being streamed. +let phoneModel = 'prop_amb_phone'; // Refered to in newphoneProp function. Requires custom phone being streamed. const newPhoneProp = async () => { //Function for creating the phone prop @@ -31,7 +31,7 @@ const newPhoneProp = async () => { RequestModel(phoneModel); while (!HasModelLoaded(phoneModel)) { await Delay(1); - console.log("MODEL HASNT LOADED"); + console.log('MODEL HASNT LOADED'); } const playerPed = PlayerPedId(); @@ -65,9 +65,9 @@ const newPhoneProp = async () => { true ); //-- Attaches the phone to the player. propCreated = true; - console.log("prop created"); + console.log('prop created'); } else if (propCreated) { - console.log("prop already created"); + console.log('prop already created'); } }; @@ -78,7 +78,7 @@ function deletePhone() { DeleteEntity(prop); prop = 0; propCreated = false; - console.log("prop destroyed"); + console.log('prop destroyed'); } } @@ -92,19 +92,19 @@ async function loadAnimDict(dict: any) { async function phoneOpenAnim() { //Phone Open Animation - console.log("phoneOpenAnim"); //Left for testing purposes. + console.log('phoneOpenAnim'); //Left for testing purposes. const flag = 50; //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94 deletePhone(); //Deleting before creating a new phone where itll be deleted again. if (IsPedInAnyVehicle(GetPlayerPed(-1), true)) { //-- true refers to at get in. - const dict = "anim@cellphone@in_car@ps"; + const dict = 'anim@cellphone@in_car@ps'; ClearPedTasks(GetPlayerPed(-1)); await loadAnimDict(dict); TaskPlayAnim( GetPlayerPed(-1), dict, - "cellphone_text_in", + 'cellphone_text_in', 8.0, -1, -1, @@ -118,14 +118,14 @@ async function phoneOpenAnim() { await newPhoneProp(); //Creates the phone and attaches it. } else { //While not in a vehicle it will use this dict. - const dict = "cellphone@"; + const dict = 'cellphone@'; ClearPedTasks(GetPlayerPed(-1)); await loadAnimDict(dict); TaskPlayAnim( GetPlayerPed(-1), dict, - "cellphone_text_in", + 'cellphone_text_in', 8.0, -1, -1, @@ -142,14 +142,14 @@ async function phoneOpenAnim() { async function phoneCloseAnim() { //Phone Close Animation - console.log("phoneCloseAnim"); //Left for testing purposes. + console.log('phoneCloseAnim'); //Left for testing purposes. const flag = 50; //https://runtime.fivem.net/doc/natives/?_0xEA47FE3719165B94 - const anim = "cellphone_text_out"; + const anim = 'cellphone_text_out'; if (IsPedInAnyVehicle(GetPlayerPed(-1), true)) { //true refers to at get in. - const dict = "anim@cellphone@in_car@ps"; + const dict = 'anim@cellphone@in_car@ps'; - StopAnimTask(GetPlayerPed(-1), dict, "cellphone_text_in", 1.0); //Stop the pull out animation + StopAnimTask(GetPlayerPed(-1), dict, 'cellphone_text_in', 1.0); //Stop the pull out animation deletePhone(); //Deletes the prop early incase they get out of the vehicle. await Delay(250); //lets it get to a certain point loadAnimDict(dict); //loads the new animation @@ -170,9 +170,9 @@ async function phoneCloseAnim() { StopAnimTask(GetPlayerPed(-1), dict, anim, 1.0); //clears the animation } else { //While not in a vehicle it will use this dict. - const dict = "cellphone@"; + const dict = 'cellphone@'; - StopAnimTask(GetPlayerPed(-1), dict, "cellphone_text_in", 1.0); //Stop the pull out animation + StopAnimTask(GetPlayerPed(-1), dict, 'cellphone_text_in', 1.0); //Stop the pull out animation await Delay(100); //lets it get to a certain point loadAnimDict(dict); //loads the new animation TaskPlayAnim( @@ -197,24 +197,24 @@ async function phoneCloseAnim() { async function carryingPhone(cb: any) { if (ESX === null) return cb(0); ESX.TriggerServerCallback( - "phone:getItemAmount", + 'phone:getItemAmount', (qtty: number) => { cb(qtty > 0); }, - "phone" + 'phone' ); } function noPhone() { if (ESX === null) return; - ESX.ShowNotification("Oi Mate, No El Telephono", false, false, 1); + ESX.ShowNotification('Oi Mate, No El Telephono', false, false, 1); } function sendPhoneConfig() { SendNuiMessage( JSON.stringify({ - app: "PHONE", - method: "phoneConfig", + app: 'PHONE', + method: 'phoneConfig', data: config, }) ); @@ -246,20 +246,20 @@ setTick(() => { async function Phone() { if (config.PhoneAsItem) { - console.log("CONFIG ON"); + console.log('CONFIG ON'); carryingPhone(async (carryingPhone: any) => { if (carryingPhone) { if (!isPhoneOpen) { isPhoneOpen = true; await phoneOpenAnim(); // Animation starts before the phone is open - emitNet("phone:getCredentials"); - console.log("Sellout fetched from client side"); // Gets the credentials. Will eventually most likely only get the phone number and name, idk. + emitNet('phone:getCredentials'); + console.log('Sellout fetched from client side'); // Gets the credentials. Will eventually most likely only get the phone number and name, idk. SetCursorLocation(0.9, 0.922); //Experimental let res = GetActiveScreenResolution(); SendNuiMessage( JSON.stringify({ - app: "PHONE", - method: "setVisibility", + app: 'PHONE', + method: 'setVisibility', data: true, }) ); @@ -271,8 +271,8 @@ async function Phone() { SendNuiMessage( //Hides phone JSON.stringify({ - app: "PHONE", - method: "setVisibility", + app: 'PHONE', + method: 'setVisibility', data: false, }) ); @@ -286,18 +286,18 @@ async function Phone() { } }); } else if (!config.PhoneAsItem) { - console.log("CONFIG OFF"); + console.log('CONFIG OFF'); if (!isPhoneOpen) { isPhoneOpen = true; await phoneOpenAnim(); // Animation starts before the phone is open - emitNet("phone:getCredentials"); - console.log("Sellout fetched from client side"); + emitNet('phone:getCredentials'); + console.log('Sellout fetched from client side'); SetCursorLocation(0.936, 0.922); //Experimental let res = GetActiveScreenResolution(); SendNuiMessage( JSON.stringify({ - app: "PHONE", - method: "setVisibility", + app: 'PHONE', + method: 'setVisibility', data: true, }) ); @@ -309,8 +309,8 @@ async function Phone() { SendNuiMessage( //Hides phone JSON.stringify({ - app: "PHONE", - method: "setVisibility", + app: 'PHONE', + method: 'setVisibility', data: false, }) ); @@ -352,7 +352,7 @@ on(`__cfx_nui:${events.OPEN_APP_CAMERA}`, () => { }); RegisterCommand( - "phone", + 'phone', () => { //-- Toggles Phone Phone(); @@ -360,17 +360,17 @@ RegisterCommand( false ); -RegisterNuiCallbackType("phone:close"); +RegisterNuiCallbackType('phone:close'); on(`__cfx_nui:phone:close`, () => { Phone(); }); // Called for when the phone is closed via the UI. -AddEventHandler("onResourceStop", function (resource: string) { +AddEventHandler('onResourceStop', function (resource: string) { if (resource === GetCurrentResourceName()) { SendNuiMessage( JSON.stringify({ - app: "PHONE", - method: "setVisibility", + app: 'PHONE', + method: 'setVisibility', data: false, }) ); @@ -386,11 +386,11 @@ AddEventHandler("onResourceStop", function (resource: string) { function countPhone(cb: any) { if (ESX === null) return cb(0); ESX.TriggerServerCallback( - "phone:getItemAmount", + 'phone:getItemAmount', (qtty: number) => { cb(qtty > 0); }, - "phone" + 'phone' ); } @@ -416,11 +416,11 @@ let destroyedPhone = false; // } // }); -onNet("phone:sendCredentials", (number: string) => { +onNet('phone:sendCredentials', (number: string) => { SendNuiMessage( JSON.stringify({ - app: "SIMCARD", - method: "setNumber", + app: 'SIMCARD', + method: 'setNumber', data: number, }) ); diff --git a/resources/client/cl_messages.ts b/resources/client/cl_messages.ts index 942f887..9fbb212 100644 --- a/resources/client/cl_messages.ts +++ b/resources/client/cl_messages.ts @@ -1,6 +1,6 @@ -import events from "../utils/events"; -import { Message, MessageGroup } from "../../phone/src/common/typings/messages"; -import { sendMessageEvent } from "../utils/messages"; +import events from '../utils/events'; +import { Message, MessageGroup } from '../../phone/src/common/typings/messages'; +import { sendMessageEvent } from '../utils/messages'; /** * Messages get message groups diff --git a/resources/client/cl_notes.ts b/resources/client/cl_notes.ts index 636362f..d1ec160 100644 --- a/resources/client/cl_notes.ts +++ b/resources/client/cl_notes.ts @@ -1,10 +1,10 @@ -import events from "../utils/events"; +import events from '../utils/events'; onNet(events.NOTE_SEND_NOTE, (notes: any) => { SendNuiMessage( JSON.stringify({ - app: "NOTES", - method: "setNotes", + app: 'NOTES', + method: 'setNotes', data: notes, }) ); diff --git a/resources/client/cl_photo.ts b/resources/client/cl_photo.ts index b900adb..8652caf 100644 --- a/resources/client/cl_photo.ts +++ b/resources/client/cl_photo.ts @@ -1,6 +1,6 @@ -import events from "../utils/events"; -import { Delay } from "../utils/fivem"; -const SCREENSHOT_BASIC_TOKEN = GetConvar("SCREENSHOT_BASIC_TOKEN", "none"); +import events from '../utils/events'; +import { Delay } from '../utils/fivem'; +const SCREENSHOT_BASIC_TOKEN = GetConvar('SCREENSHOT_BASIC_TOKEN', 'none'); const exp = (global as any).exports; @@ -8,8 +8,8 @@ function closePhoneTemp() { SendNuiMessage( //Hides phone JSON.stringify({ - app: "PHONE", - method: "setVisibility", + app: 'PHONE', + method: 'setVisibility', data: false, }) ); @@ -19,8 +19,8 @@ function openPhoneTemp() { SendNuiMessage( //Opens phone JSON.stringify({ - app: "PHONE", - method: "setVisibility", + app: 'PHONE', + method: 'setVisibility', data: true, }) ); @@ -29,7 +29,7 @@ function openPhoneTemp() { let takingPhoto = false; function CellFrontCamActivate(activate: any) { - return Citizen.invokeNative("0x2491A93618B7D838", activate); + return Citizen.invokeNative('0x2491A93618B7D838', activate); } RegisterNuiCallbackType(events.CAMERA_TAKE_PHOTO); @@ -57,7 +57,7 @@ on(`__cfx_nui:${events.CAMERA_TAKE_PHOTO}`, async () => { } else if (IsControlJustPressed(1, 176)) { takePhoto(); await Delay(200); - console.log("phone closing"); + console.log('phone closing'); DestroyMobilePhone(); CellCamActivate(false, false); @@ -96,8 +96,8 @@ onNet(events.CAMERA_SEND_PHOTOS, (photos: string[]) => { console.log(photos); SendNuiMessage( JSON.stringify({ - app: "CAMERA", - method: "setPhotos", + app: 'CAMERA', + method: 'setPhotos', data: photos, }) ); @@ -106,18 +106,18 @@ onNet(events.CAMERA_SEND_PHOTOS, (photos: string[]) => { function takePhoto() { const [width, height] = GetActiveScreenResolution(); // Return and log error if screenshot basic token not found - if (SCREENSHOT_BASIC_TOKEN === "none") { + if (SCREENSHOT_BASIC_TOKEN === 'none') { return console.error( - "Screenshot basic token not found. Please set in server.cfg" + 'Screenshot basic token not found. Please set in server.cfg' ); } - exp["screenshot-basic"].requestScreenshotUpload( - "https://api.imgur.com/3/image", - "imgur", + exp['screenshot-basic'].requestScreenshotUpload( + 'https://api.imgur.com/3/image', + 'imgur', { headers: { authorization: `Client-ID ${SCREENSHOT_BASIC_TOKEN}`, - "content-type": "multipart/form-data", + 'content-type': 'multipart/form-data', }, }, (data: string) => { diff --git a/resources/client/cl_sellout.ts b/resources/client/cl_sellout.ts index c3b384f..32f6609 100644 --- a/resources/client/cl_sellout.ts +++ b/resources/client/cl_sellout.ts @@ -1,10 +1,10 @@ -import events from "../utils/events"; +import events from '../utils/events'; onNet(events.SELLOUT_SEND_LISTING, (listing: any) => { SendNuiMessage( JSON.stringify({ - app: "SELLOUT", - method: "setListings", + app: 'SELLOUT', + method: 'setListings', data: listing, }) ); @@ -17,6 +17,6 @@ on(`__cfx_nui:${events.SELLOUT_ADD_LISTING}`, (data: any) => { setTimeout(() => { emitNet(events.SELLOUT_FETCH_LISTING); - console.log("Fetched"); + console.log('Fetched'); }, 500); }); diff --git a/resources/client/cl_twitter.ts b/resources/client/cl_twitter.ts index 2acfca8..4da7527 100644 --- a/resources/client/cl_twitter.ts +++ b/resources/client/cl_twitter.ts @@ -1,5 +1,5 @@ -import events from "../utils/events"; -import { sendTwitterMessage } from "../utils/messages"; +import events from '../utils/events'; +import { sendTwitterMessage } from '../utils/messages'; /** * Twitter get or create profile diff --git a/resources/client/client.ts b/resources/client/client.ts index af372eb..c6ebd75 100644 --- a/resources/client/client.ts +++ b/resources/client/client.ts @@ -1,18 +1,18 @@ -import { Client } from "esx.js"; +import { Client } from 'esx.js'; -import "./cl_main"; -import "./cl_twitter"; -import "./cl_contacts"; -import "./cl_sellout"; -import "./cl_bank"; -import "./cl_notes"; -import "./cl_photo"; -import "./cl_messages"; +import './cl_main'; +import './cl_twitter'; +import './cl_contacts'; +import './cl_sellout'; +import './cl_bank'; +import './cl_notes'; +import './cl_photo'; +import './cl_messages'; export let ESX: Client = null; setTick(() => { while (ESX === null) { - emit("esx:getSharedObject", (obj: Client) => (ESX = obj)); + emit('esx:getSharedObject', (obj: Client) => (ESX = obj)); } }); diff --git a/resources/server/db.ts b/resources/server/db.ts index 8e2ed68..e443859 100644 --- a/resources/server/db.ts +++ b/resources/server/db.ts @@ -1,5 +1,5 @@ -import mysql from "mysql2/promise"; -import { ConnectionStringParser } from "connection-string-parser"; +import mysql from 'mysql2/promise'; +import { ConnectionStringParser } from 'connection-string-parser'; import { CONNECTION_STRING, DEFAULT_PORT, @@ -7,7 +7,7 @@ import { getServerHost, getUserId, getPassword, -} from "./db_utils"; +} from './db_utils'; // we require set mysql_connection_string to be set in the config const mysqlConnectionString = GetConvar(CONNECTION_STRING, null); @@ -26,7 +26,7 @@ if (mysqlConnectionString === null) { * https://brouznouf.github.io/fivem-mysql-async/config/ and we need to handle both of them. */ export function generateConnectionPool() { - if (mysqlConnectionString.includes("database=")) { + if (mysqlConnectionString.includes('database=')) { // This is checking for this format: // set mysql_connection_string "server=127.0.0.1;database=es_extended;userid=user;password=pass" const config = parseSemiColonFormat(mysqlConnectionString); @@ -44,7 +44,7 @@ export function generateConnectionPool() { // This is checking for this format: // set mysql_connection_string "mysql://root:pass@127.0.0.1/es_extended?charset=utf8mb4" const connectionStringParser = new ConnectionStringParser({ - scheme: "mysql", + scheme: 'mysql', hosts: [], }); const connectionOjbect = connectionStringParser.parse( @@ -75,7 +75,7 @@ export async function withTransaction(queries: Promise[]): Promise { await connection.release(); return results; } catch (err) { - console.warn("Error when submitting queries"); + console.warn('Error when submitting queries'); await connection.rollback(); await connection.release(); return Promise.reject(err); diff --git a/resources/server/db_utils.test.ts b/resources/server/db_utils.test.ts index 2d04f34..92c7511 100644 --- a/resources/server/db_utils.test.ts +++ b/resources/server/db_utils.test.ts @@ -1,93 +1,93 @@ -import * as db from "./db_utils"; +import * as db from './db_utils'; -const t = "test value"; +const t = 'test value'; -describe("parseSemiColonFormat", () => { - it("Raises a error with invalid string", () => { - expect(() => db.parseSemiColonFormat("no_variables_here")).toThrowError(); +describe('parseSemiColonFormat', () => { + it('Raises a error with invalid string', () => { + expect(() => db.parseSemiColonFormat('no_variables_here')).toThrowError(); }); - it("Correctly parses configuration options", () => { - const test = "server=127.0.0.1;database=es_extended;userid=user;"; + it('Correctly parses configuration options', () => { + const test = 'server=127.0.0.1;database=es_extended;userid=user;'; const result = db.parseSemiColonFormat(test); - expect(result.server).toEqual("127.0.0.1"); - expect(result.database).toEqual("es_extended"); - expect(result.userid).toEqual("user"); + expect(result.server).toEqual('127.0.0.1'); + expect(result.database).toEqual('es_extended'); + expect(result.userid).toEqual('user'); expect(result.password).toEqual(undefined); }); }); -describe("getServerHost", () => { - it("returns default", () => { +describe('getServerHost', () => { + it('returns default', () => { expect(db.getServerHost({})).toEqual(db.DEFAULT_HOST); }); - it("Correctly returns host", () => { + it('Correctly returns host', () => { expect(db.getServerHost({ host: t })).toEqual(t); }); - it("Correctly returns server", () => { + it('Correctly returns server', () => { expect(db.getServerHost({ server: t })).toEqual(t); }); - it("Correctly returns data source", () => { - expect(db.getServerHost({ "data source": t })).toEqual(t); + it('Correctly returns data source', () => { + expect(db.getServerHost({ 'data source': t })).toEqual(t); }); - it("Correctly returns datasource", () => { + it('Correctly returns datasource', () => { expect(db.getServerHost({ datasource: t })).toEqual(t); }); - it("Correctly returns addr", () => { + it('Correctly returns addr', () => { expect(db.getServerHost({ addr: t })).toEqual(t); }); - it("Correctly returns address", () => { + it('Correctly returns address', () => { expect(db.getServerHost({ address: t })).toEqual(t); }); }); -describe("getUserId", () => { - it("returns default", () => { +describe('getUserId', () => { + it('returns default', () => { expect(db.getUserId({})).toEqual(db.DEFAULT_USER); }); - it("Correctly returns user", () => { + it('Correctly returns user', () => { expect(db.getUserId({ user: t })).toEqual(t); }); - it("Correctly returns user id", () => { - expect(db.getUserId({ "user id": t })).toEqual(t); + it('Correctly returns user id', () => { + expect(db.getUserId({ 'user id': t })).toEqual(t); }); - it("Correctly returns userid", () => { + it('Correctly returns userid', () => { expect(db.getUserId({ userid: t })).toEqual(t); }); - it("Correctly returns user name", () => { - expect(db.getUserId({ "user name": t })).toEqual(t); + it('Correctly returns user name', () => { + expect(db.getUserId({ 'user name': t })).toEqual(t); }); - it("Correctly returns username", () => { + it('Correctly returns username', () => { expect(db.getUserId({ username: t })).toEqual(t); }); - it("Correctly returns uid", () => { + it('Correctly returns uid', () => { expect(db.getUserId({ uid: t })).toEqual(t); }); }); -describe("getPassword", () => { +describe('getPassword', () => { // it("returns default", () => { // expect(() => db.getPassword({})).toThrowError(); // }); - it("Correctly returns password", () => { + it('Correctly returns password', () => { expect(db.getPassword({ password: t })).toEqual(t); }); - it("Correctly returns pwd", () => { + it('Correctly returns pwd', () => { expect(db.getPassword({ pwd: t })).toEqual(t); }); }); diff --git a/resources/server/db_utils.ts b/resources/server/db_utils.ts index a370d0a..c83b19c 100644 --- a/resources/server/db_utils.ts +++ b/resources/server/db_utils.ts @@ -1,7 +1,7 @@ -export const CONNECTION_STRING = "mysql_connection_string"; +export const CONNECTION_STRING = 'mysql_connection_string'; export const DEFAULT_PORT = 3306; -export const DEFAULT_HOST = "localhost"; -export const DEFAULT_USER = "root"; +export const DEFAULT_HOST = 'localhost'; +export const DEFAULT_USER = 'root'; interface Map { [key: string]: string; @@ -12,7 +12,7 @@ interface Map { * @param connectionString - mysql_connection_string value */ export function parseSemiColonFormat(connectionString: string): Map { - const parts = connectionString.split(";"); + const parts = connectionString.split(';'); if (parts.length === 1) { throw new Error( `Connection string ${connectionString} is in the incorrect format. Please follow the README.` @@ -20,7 +20,7 @@ export function parseSemiColonFormat(connectionString: string): Map { } return parts.reduce((connectionInfo: Map, part) => { - const [key, value] = part.split("="); + const [key, value] = part.split('='); connectionInfo[key] = value; return connectionInfo; }, {}); @@ -34,7 +34,7 @@ export function getServerHost(config: Map): string { return ( config.host || config.server || - config["data source"] || + config['data source'] || config.datasource || config.addr || config.address || @@ -49,9 +49,9 @@ export function getServerHost(config: Map): string { export function getUserId(config: Map): string { return ( config.user || - config["user id"] || + config['user id'] || config.userid || - config["user name"] || + config['user name'] || config.username || config.uid || DEFAULT_USER diff --git a/resources/server/discord.ts b/resources/server/discord.ts index 1c0f7ba..641b62e 100644 --- a/resources/server/discord.ts +++ b/resources/server/discord.ts @@ -1,15 +1,15 @@ -import axios from "axios"; +import axios from 'axios'; -import { Tweet, Profile } from "../../phone/src/common/typings/twitter"; -import { IMAGE_DELIMITER } from "../../phone/src/apps/twitter/utils/images"; +import { Tweet, Profile } from '../../phone/src/common/typings/twitter'; +import { IMAGE_DELIMITER } from '../../phone/src/apps/twitter/utils/images'; -const DISCORD_TOKEN_ENV_VAR = "discord_bot_token"; -const DISCORD_TOKEN = GetConvar(DISCORD_TOKEN_ENV_VAR, ""); -const DISCORD_CHANNEL_ENV_VAR = "discord_channel_id"; -const DISCORD_CHANNEL_ID = GetConvar(DISCORD_CHANNEL_ENV_VAR, ""); +const DISCORD_TOKEN_ENV_VAR = 'discord_bot_token'; +const DISCORD_TOKEN = GetConvar(DISCORD_TOKEN_ENV_VAR, ''); +const DISCORD_CHANNEL_ENV_VAR = 'discord_channel_id'; +const DISCORD_CHANNEL_ID = GetConvar(DISCORD_CHANNEL_ENV_VAR, ''); const DISCORD_HEADERS = { authorization: `Bot ${DISCORD_TOKEN}` }; -const BASE_URL = "https://discord.com/api"; +const BASE_URL = 'https://discord.com/api'; const POST_CHANNEL_URL = `${BASE_URL}/channels/${DISCORD_CHANNEL_ID}/messages`; export async function reportTweetToDiscord( @@ -34,7 +34,7 @@ export async function reportTweetToDiscord( ${tweet.message} **Reported Images**: - ${tweet.images.split(IMAGE_DELIMITER).join("\n")} + ${tweet.images.split(IMAGE_DELIMITER).join('\n')} `; return await axios.post( diff --git a/resources/server/functions.ts b/resources/server/functions.ts index 5e0cc31..6a7127b 100644 --- a/resources/server/functions.ts +++ b/resources/server/functions.ts @@ -1,5 +1,5 @@ -import { pool } from "./db"; -import { ESX } from "./server"; +import { pool } from './db'; +import { ESX } from './server'; interface IPhoneNumber { phone_number: string; @@ -10,7 +10,7 @@ interface Iidentifier { } export async function usePhoneNumber(identifier: string): Promise { - const query = "SELECT phone_number FROM users WHERE identifier = ?"; + const query = 'SELECT phone_number FROM users WHERE identifier = ?'; const [results] = await pool.query(query, [identifier]); const phoneNumber = results; return phoneNumber[0].phone_number; @@ -25,7 +25,7 @@ export async function useIdentifier(): Promise { export async function getIdentifierByPhoneNumber( phoneNumber: string ): Promise { - const query = "SELECT identifier FROM users WHERE phone_number = ?"; + const query = 'SELECT identifier FROM users WHERE phone_number = ?'; const [results] = await pool.query(query, [phoneNumber]); const identifier = results; return identifier[0].identifier; diff --git a/resources/server/server.ts b/resources/server/server.ts index 456121c..f0279be 100644 --- a/resources/server/server.ts +++ b/resources/server/server.ts @@ -1,19 +1,19 @@ -import { Server } from "esx.js"; +import { Server } from 'esx.js'; -import "./db"; -import "./sv_twitter"; -import "./sv_main"; -import "./sv_contacts"; -import "./sv_sellout"; -import "./sv_bank"; -import "./sv_notes"; -import "./sv_photo"; -import "./sv_messages"; +import './db'; +import './sv_twitter'; +import './sv_main'; +import './sv_contacts'; +import './sv_sellout'; +import './sv_bank'; +import './sv_notes'; +import './sv_photo'; +import './sv_messages'; 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)); // i llke t-notify diff --git a/resources/server/sv_bank.ts b/resources/server/sv_bank.ts index 66fd951..38e7ae9 100644 --- a/resources/server/sv_bank.ts +++ b/resources/server/sv_bank.ts @@ -1,17 +1,17 @@ -import events from "../utils/events"; -import { ESX } from "./server"; -import { getSource } from "./functions"; -import { pool } from "./db"; +import events from '../utils/events'; +import { ESX } from './server'; +import { getSource } from './functions'; +import { pool } from './db'; import { Transfer, IBankCredentials, -} from "../../phone/src/common/typings/bank"; -import { useIdentifier } from "./functions"; -import { type } from "os"; +} from '../../phone/src/common/typings/bank'; +import { useIdentifier } from './functions'; +import { type } from 'os'; async function fetchAllTransactions(identifier: string): Promise { const query = - "SELECT * FROM npwd_bank_transfers WHERE identifier = ? ORDER BY id DESC"; + 'SELECT * FROM npwd_bank_transfers WHERE identifier = ? ORDER BY id DESC'; const [results] = await pool.query(query, [identifier]); const transactions = results; @@ -20,7 +20,7 @@ async function fetchAllTransactions(identifier: string): Promise { function fetchCredentials(): IBankCredentials { const name = ESX.GetPlayerFromId(getSource()).getName(); - const balance = ESX.GetPlayerFromId(getSource()).getAccount("bank").money; + const balance = ESX.GetPlayerFromId(getSource()).getAccount('bank').money; const result = { name, @@ -35,7 +35,7 @@ async function addTransfer( transfer: Transfer ): Promise { const xPlayer = ESX.GetPlayerFromId(getSource()); - const bankBalance = xPlayer.getAccount("bank").money; + const bankBalance = xPlayer.getAccount('bank').money; const sourceName = xPlayer.getName(); const xTarget = ESX.GetPlayerFromId(transfer.targetID); @@ -45,18 +45,18 @@ async function addTransfer( } else if (transfer.transferAmount < bankBalance) { emitNet(events.BANK_TRANSACTION_ALERT, getSource(), true); - xTarget.addAccountMoney("bank", transfer.transferAmount); - xPlayer.removeAccountMoney("bank", transfer.transferAmount); + xTarget.addAccountMoney('bank', transfer.transferAmount); + xPlayer.removeAccountMoney('bank', transfer.transferAmount); const query = - "INSERT INTO npwd_bank_transfers (identifier, target, amount, message, type, source) VALUES (?, ?, ?, ?, ?, ?)"; + 'INSERT INTO npwd_bank_transfers (identifier, target, amount, message, type, source) VALUES (?, ?, ?, ?, ?, ?)'; const [results] = await pool.query(query, [ identifier, transfer.targetID, transfer.transferAmount, transfer.message, - "Transfer", + 'Transfer', sourceName, ]); const insertData = results; @@ -69,7 +69,7 @@ async function addTransfer( * @param transferId - transfer id */ async function getTransfer(transferId: number): Promise { - const query = "SELECT * FROM npwd_bank_transfers WHERE id = ?"; + const query = 'SELECT * FROM npwd_bank_transfers WHERE id = ?'; const [results] = await pool.query(query, [transferId]); const transfers = results; const transfer = transfers[0]; @@ -84,7 +84,7 @@ onNet(events.BANK_FETCH_TRANSACTIONS, async () => { emitNet(events.BANK_SEND_TRANSFERS, _source, transfer); } catch (error) { - console.log("Failed to fetch transactions"); + console.log('Failed to fetch transactions'); } }); @@ -105,6 +105,6 @@ onNet(events.BANK_GET_CREDENTIALS, () => { const credentials = fetchCredentials(); emitNet(events.BANK_SEND_CREDENTIALS, getSource(), credentials); } catch (error) { - console.log("Failed to fetch credentials"); + console.log('Failed to fetch credentials'); } }); diff --git a/resources/server/sv_contacts.ts b/resources/server/sv_contacts.ts index 80281ef..6be5e20 100644 --- a/resources/server/sv_contacts.ts +++ b/resources/server/sv_contacts.ts @@ -1,7 +1,7 @@ -import { ESX } from "./server"; -import { pool } from "./db"; -import events from "../utils/events"; -import { useIdentifier, getSource } from "./functions"; +import { ESX } from './server'; +import { pool } from './db'; +import events from '../utils/events'; +import { useIdentifier, getSource } from './functions'; interface Contacts { id?: number; @@ -15,7 +15,7 @@ interface ContactId { } async function fetchAllContacts(identifier: string): Promise { - const query = "SELECT * FROM npwd_phone_contacts WHERE identifier = ?"; + const query = 'SELECT * FROM npwd_phone_contacts WHERE identifier = ?'; const [results] = await pool.query(query, [identifier]); const contacts = results; return contacts; @@ -28,7 +28,7 @@ async function addContact( avatar: string ): Promise { const query = - "INSERT INTO npwd_phone_contacts (identifier, number, display, avatar) VALUES (?, ?, ?, ?)"; + 'INSERT INTO npwd_phone_contacts (identifier, number, display, avatar) VALUES (?, ?, ?, ?)'; const [result] = await pool.query(query, [ identifier, @@ -43,7 +43,7 @@ async function updateContact( identifier: string ): Promise { const query = - "UPDATE npwd_phone_contacts SET number = ?, display = ?, avatar = ? WHERE id = ? AND identifier = ?"; + 'UPDATE npwd_phone_contacts SET number = ?, display = ?, avatar = ? WHERE id = ? AND identifier = ?'; await pool.query(query, [ contact.number, contact.display, @@ -58,7 +58,7 @@ async function deleteContact( identifier: string ): Promise { const query = - "DELETE FROM npwd_phone_contacts WHERE id = ? AND identifier = ?"; + 'DELETE FROM npwd_phone_contacts WHERE id = ? AND identifier = ?'; await pool.query(query, [contact.id, identifier]); } @@ -71,7 +71,7 @@ onNet(events.CONTACTS_GET_CONTACTS, async () => { const contacts = await fetchAllContacts(_identifier); emitNet(events.CONTACTS_SEND_CONTACTS, _source, contacts); } catch (error) { - console.log("Failed to fetch contacts: ", error); + console.log('Failed to fetch contacts: ', error); } }); @@ -86,10 +86,10 @@ onNet( emitNet( events.CONTACTS_ACTION_RESULT, getSource(), - "CONTACT_ADD_SUCCESS" + 'CONTACT_ADD_SUCCESS' ); } catch (error) { - emitNet(events.CONTACTS_ACTION_RESULT, getSource(), "CONTACT_ADD_FAILED"); + emitNet(events.CONTACTS_ACTION_RESULT, getSource(), 'CONTACT_ADD_FAILED'); } } ); @@ -103,13 +103,13 @@ onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => { emitNet( events.CONTACTS_ACTION_RESULT, getSource(), - "CONTACT_UPDATE_SUCCESS" + 'CONTACT_UPDATE_SUCCESS' ); } catch (error) { emitNet( events.CONTACTS_ACTION_RESULT, getSource(), - "CONTACT_UPDATE_FAILED" + 'CONTACT_UPDATE_FAILED' ); } }); @@ -122,13 +122,13 @@ onNet(events.CONTACTS_DELETE_CONTACT, async (contact: ContactId) => { emitNet( events.CONTACTS_ACTION_RESULT, getSource(), - "CONTACT_DELETE_SUCCESS" + 'CONTACT_DELETE_SUCCESS' ); } catch (error) { emitNet( events.CONTACTS_ACTION_RESULT, getSource(), - "CONTACT_DELETE_FAILED" + 'CONTACT_DELETE_FAILED' ); } }); diff --git a/resources/server/sv_main.ts b/resources/server/sv_main.ts index 594add1..3f6f853 100644 --- a/resources/server/sv_main.ts +++ b/resources/server/sv_main.ts @@ -1,7 +1,7 @@ -import { ESX } from "./server"; -import { pool } from "./db"; -import config from "../utils/config"; -import { getIdentifierByPhoneNumber, usePhoneNumber } from "./functions"; +import { ESX } from './server'; +import { pool } from './db'; +import config from '../utils/config'; +import { getIdentifierByPhoneNumber, usePhoneNumber } from './functions'; //db = DatabaseConfig //helper variable for use in server function @@ -25,7 +25,7 @@ function getRandomPhoneNumber() { } else { randomNumber = Math.floor(Math.random() * 10000000) .toString() - .replace(/(\d{3})(\d{4})/, "$1-$2"); // ; + .replace(/(\d{3})(\d{4})/, '$1-$2'); // ; // The numbers inside {} in replace() can be changed to how many digits you want on each side of the dash. // Example: 123-4567 } @@ -41,7 +41,7 @@ async function generatePhoneNumber(identifier: string) { do { if (!phoneNumber) { phoneNumber = await getRandomPhoneNumber(); - const query = "UPDATE users SET phone_number = ? WHERE identifier = ?"; + const query = 'UPDATE users SET phone_number = ? WHERE identifier = ?'; await pool.query(query, [phoneNumber, _identifier]); } else { break; @@ -50,26 +50,26 @@ async function generatePhoneNumber(identifier: string) { } async function getCredentials(identifier: string): Promise { - const query = "SELECT phone_number FROM users WHERE identifier = ?"; + const query = 'SELECT phone_number FROM users WHERE identifier = ?'; const [result] = await pool.query(query, [identifier]); const number = result; - if (number.length === 0) return "###-####"; + if (number.length === 0) return '###-####'; return number[0].phone_number; } -onNet("esx:playerLoaded", async (playerId: number, xPlayer: any) => { +onNet('esx:playerLoaded', async (playerId: number, xPlayer: any) => { const identifier = xPlayer.identifier; await generatePhoneNumber(identifier); }); -onNet("phone:getCredentials", async () => { +onNet('phone:getCredentials', async () => { try { const _source = (global as any).source; const xPlayer = ESX.GetPlayerFromId(_source); const _identifier = xPlayer.getIdentifier(); const number = await getCredentials(_identifier); - emitNet("phone:sendCredentials", _source, number); + emitNet('phone:sendCredentials', _source, number); } catch (error) { - console.log("Failed to get number. ", error); + console.log('Failed to get number. ', error); } }); diff --git a/resources/server/sv_messages.ts b/resources/server/sv_messages.ts index 9fb97c2..fcf2501 100644 --- a/resources/server/sv_messages.ts +++ b/resources/server/sv_messages.ts @@ -1,13 +1,13 @@ -import md5 from "md5"; +import md5 from 'md5'; -import events from "../utils/events"; +import events from '../utils/events'; import { Message, MessageGroup, CreateMessageGroupResult, -} from "../../phone/src/common/typings/messages"; -import { pool, withTransaction } from "./db"; -import { getSource, useIdentifier } from "./functions"; +} from '../../phone/src/common/typings/messages'; +import { pool, withTransaction } from './db'; +import { getSource, useIdentifier } from './functions'; /** * Used for the raw npwd_messages_groups row responses @@ -188,7 +188,7 @@ async function getIdentifierFromPhoneNumber( `; const [results] = await pool.query(query, [phoneNumber]); const identifiers = results; - return identifiers[0]["identifier"]; + return identifiers[0]['identifier']; } /** @@ -235,7 +235,7 @@ async function getConsolidatedMessageGroups( (mapping: MessageGroupMapping, messageGroup: UnformattedMessageGroup) => { const groupId = messageGroup.group_id; const displayTerm = - messageGroup.display || messageGroup.phone_number || "???"; + messageGroup.display || messageGroup.phone_number || '???'; if (groupId in mapping) { mapping[groupId].participants = mapping[groupId].participants.concat( @@ -288,7 +288,7 @@ async function getFormattedMessageGroups( return { ...group, groupId, - groupDisplay: group.participants.join(", "), + groupDisplay: group.participants.join(', '), // note that 1 here references how many participants besides the user isGroupChat: group.participants.length > 1, }; @@ -336,7 +336,7 @@ async function createMessageGroupsFromPhoneNumbers( // that this not change! Changing this order can result in the ability // of duplicate message groups being created. identifiers.sort(); - const mergedIdentifiers = identifiers.join("-"); + const mergedIdentifiers = identifiers.join('-'); // we don't need this to be secure. Its purpose is to create a unique // string derived from the identifiers. In this way we can check // that this groupId isn't used before. If it has then it means diff --git a/resources/server/sv_notes.ts b/resources/server/sv_notes.ts index 70a034e..86a5c08 100644 --- a/resources/server/sv_notes.ts +++ b/resources/server/sv_notes.ts @@ -1,30 +1,30 @@ -import events from "../utils/events"; -import { pool } from "./db"; -import { useIdentifier, getSource } from "./functions"; -import { Note, NoteId } from "../../phone/src/common/typings/notes"; +import events from '../utils/events'; +import { pool } from './db'; +import { useIdentifier, getSource } from './functions'; +import { Note, NoteId } from '../../phone/src/common/typings/notes'; async function addNote(identifier: string, note: Note): Promise { const query = - "INSERT INTO npwd_notes (identifier, title, content) VALUES (?, ?, ?)"; + 'INSERT INTO npwd_notes (identifier, title, content) VALUES (?, ?, ?)'; await pool.query(query, [identifier, note.title, note.content]); } async function fetchAllNotes(identifier: string): Promise { const query = - "SELECT * FROM npwd_notes WHERE identifier = ? ORDER BY id DESC"; + 'SELECT * FROM npwd_notes WHERE identifier = ? ORDER BY id DESC'; const [result] = await pool.query(query, [identifier]); const notes = result; return notes; } async function deleteNote(noteId: number, identifier: string) { - const query = "DELETE FROM npwd_notes WHERE id = ? AND identifier = ?"; + const query = 'DELETE FROM npwd_notes WHERE id = ? AND identifier = ?'; await pool.query(query, [noteId, identifier]); } async function updateNote(note: Note, identifier: string): Promise { const query = - "UPDATE npwd_notes SET title = ?, content = ? WHERE id = ? AND identifier = ?"; + 'UPDATE npwd_notes SET title = ?, content = ? WHERE id = ? AND identifier = ?'; await pool.query(query, [note.title, note.content, note.id, identifier]); } @@ -34,7 +34,7 @@ onNet(events.NOTE_ADD_NOTE, async (note: Note) => { addNote(_identifier, note); emitNet(events.NOTE_SEND_NOTE_SUCCESS, getSource()); } catch (error) { - console.log("NOTES ERROR: ", error); + console.log('NOTES ERROR: ', error); } }); @@ -45,7 +45,7 @@ onNet(events.NOTE_FETCH_ALL_NOTES, async () => { const notes = await fetchAllNotes(_identifier); emitNet(events.NOTE_SEND_NOTE, _source, notes); } catch (error) { - console.log("NOTE ERROR: ", error); + console.log('NOTE ERROR: ', error); } }); @@ -55,7 +55,7 @@ onNet(events.NOTE_DELETE_NOTE, async (noteId: NoteId) => { const id = noteId.id; await deleteNote(id, _identifier); } catch (error) { - console.log("NOTE ERROR:", error); + console.log('NOTE ERROR:', error); } }); diff --git a/resources/server/sv_photo.ts b/resources/server/sv_photo.ts index 084508e..2314e7d 100644 --- a/resources/server/sv_photo.ts +++ b/resources/server/sv_photo.ts @@ -1,18 +1,18 @@ -import events from "../utils/events"; -import { ESX, getSource } from "./server"; -import { pool } from "./db"; -import { useIdentifier } from "./functions"; -import { IPhoto } from "../../phone/src/common/typings/photo"; +import events from '../utils/events'; +import { ESX, getSource } from './server'; +import { pool } from './db'; +import { useIdentifier } from './functions'; +import { IPhoto } from '../../phone/src/common/typings/photo'; async function uploadPhoto(identifier: string, image: string) { const query = - "INSERT INTO npwd_phone_gallery (identifier, image) VALUES (?, ?)"; + 'INSERT INTO npwd_phone_gallery (identifier, image) VALUES (?, ?)'; await pool.query(query, [identifier, image]); } async function getPhotosByIdentifier(identifier: string): Promise { const query = - "SELECT id, image FROM npwd_phone_gallery WHERE identifier = ? ORDER BY id DESC"; + 'SELECT id, image FROM npwd_phone_gallery WHERE identifier = ? ORDER BY id DESC'; const [results] = await pool.query(query, [identifier]); const photos = results; return photos; @@ -20,7 +20,7 @@ async function getPhotosByIdentifier(identifier: string): Promise { async function deletePhoto(photo: IPhoto, identifier: string) { const query = - "DELETE FROM npwd_phone_gallery WHERE id = ? AND identifier = ?"; + 'DELETE FROM npwd_phone_gallery WHERE id = ? AND identifier = ?'; await pool.query(query, [photo.id, identifier]); console.log(photo.id); } diff --git a/resources/server/sv_sellout.ts b/resources/server/sv_sellout.ts index 675c65b..38f9242 100644 --- a/resources/server/sv_sellout.ts +++ b/resources/server/sv_sellout.ts @@ -1,8 +1,8 @@ -import events from "../utils/events"; -import { ESX } from "./server"; -import { getSource } from "./functions"; -import { pool } from "./db"; -import { usePhoneNumber } from "./functions"; +import events from '../utils/events'; +import { ESX } from './server'; +import { getSource } from './functions'; +import { pool } from './db'; +import { usePhoneNumber } from './functions'; interface Listing { title: string; @@ -12,7 +12,7 @@ interface Listing { } async function fetchAllListings(): Promise { - const query = "SELECT * FROM npwd_sellout_listings ORDER BY id DESC"; + const query = 'SELECT * FROM npwd_sellout_listings ORDER BY id DESC'; const [results] = await pool.query(query); const listings = results; @@ -27,7 +27,7 @@ async function addListing( listing: Listing ): Promise { const query = - "INSERT INTO npwd_sellout_listings (identifier, name, number, title, url, description) VALUES (?, ?, ?, ?, ?, ?)"; + 'INSERT INTO npwd_sellout_listings (identifier, name, number, title, url, description) VALUES (?, ?, ?, ?, ?, ?)'; await pool.query(query, [ identifier, name, @@ -57,6 +57,6 @@ onNet(events.SELLOUT_ADD_LISTING, async (listing: Listing) => { const phoneNumber = await usePhoneNumber(_identifier); addListing(_identifier, name, phoneNumber, listing); } catch (error) { - console.log("Failed to add contact: ", error); + console.log('Failed to add contact: ', error); } }); diff --git a/resources/server/sv_twitter.ts b/resources/server/sv_twitter.ts index 3017429..23cbdbe 100644 --- a/resources/server/sv_twitter.ts +++ b/resources/server/sv_twitter.ts @@ -1,10 +1,10 @@ -import { pool } from "./db"; -import { ESX } from "./server"; -import { getSource } from "./functions"; -import { Tweet, Profile } from "../../phone/src/common/typings/twitter"; -import events from "../utils/events"; -import config from "../utils/config"; -import { reportTweetToDiscord } from "./discord"; +import { pool } from './db'; +import { ESX } from './server'; +import { getSource } from './functions'; +import { Tweet, Profile } from '../../phone/src/common/typings/twitter'; +import events from '../utils/events'; +import config from '../utils/config'; +import { reportTweetToDiscord } from './discord'; interface ProfileName { profile_name: string; @@ -153,7 +153,7 @@ async function getProfile(identifier: string): Promise { * @param identifier - player's identifier */ async function generateProfileName(identifier: string): Promise { - const defaultProfileName = ""; + const defaultProfileName = ''; if (!config.twitter.generateProfileNameFromUsers) return defaultProfileName; const query = ` @@ -378,7 +378,7 @@ onNet(events.TWITTER_REPORT, async (tweetId: number) => { const reportExists = await doesReportExist(tweet.id, profile.id); if (reportExists) { - console.warn("This profile has already reported this tweet"); + console.warn('This profile has already reported this tweet'); } else { await createTweetReport(tweet.id, profile.id); await reportTweetToDiscord(tweet, profile); diff --git a/resources/utils/apps.ts b/resources/utils/apps.ts index 91e6161..35a0726 100644 --- a/resources/utils/apps.ts +++ b/resources/utils/apps.ts @@ -1,4 +1,4 @@ export default { - TWITTER: "TWITTER", - MESSAGES: "MESSAGES", + TWITTER: 'TWITTER', + MESSAGES: 'MESSAGES', }; diff --git a/resources/utils/config.ts b/resources/utils/config.ts index e891df0..5011cc5 100644 --- a/resources/utils/config.ts +++ b/resources/utils/config.ts @@ -1,4 +1,4 @@ -import config from "../../config.json"; -import { ServerConfig } from "../../phone/src/common/typings/config"; +import config from '../../config.json'; +import { ServerConfig } from '../../phone/src/common/typings/config'; export default config; diff --git a/resources/utils/events.ts b/resources/utils/events.ts index 1dc1ba4..f5a0370 100644 --- a/resources/utils/events.ts +++ b/resources/utils/events.ts @@ -1,97 +1,97 @@ export default { // Twitter - TWITTER_FETCH_TWEETS: "phone:fetchTweets", - TWITTER_FETCH_TWEETS_SUCCESS: "fetchTweets", - TWITTER_FETCH_TWEETS_FAILURE: "fetchTweetsFailed", - TWITTER_FETCH_TWEETS_FILTERED: "phone:fetchTweetsFiltered", - TWITTER_FETCH_TWEETS_FILTERED_SUCCESS: "fetchTweetsFiltered", - TWITTER_FETCH_TWEETS_FILTERED_FAILURE: "fetchTweetsFilteredFailed", - TWITTER_GET_OR_CREATE_PROFILE: "phone:getOrCreateTwitterProfile", - TWITTER_GET_OR_CREATE_PROFILE_SUCCESS: "getOrCreateTwitterProfile", - TWITTER_GET_OR_CREATE_PROFILE_FAILURE: "getOrCreateTwitterProfileFailed", - TWITTER_UPDATE_PROFILE: "phone:updateTwitterProfile", - TWITTER_UPDATE_PROFILE_LOADING: "updateProfileLoading", - TWITTER_UPDATE_PROFILE_RESULT: "updateProfileResult", - TWITTER_CREATE_TWEET: "phone:createTweet", - TWITTER_CREATE_TWEET_LOADING: "createTweetLoading", - TWITTER_CREATE_TWEET_RESULT: "createTweetResult", - TWITTER_CREATE_TWEET_BROADCAST: "createTweetBroadcast", - TWITTER_CREATE_TWEET_FAILURE: "createTweetResultFailed", - TWITTER_DELETE_TWEET: "phone:deleteTweet", - TWITTER_DELETE_TWEET_SUCCESS: "deleteTweetSuccess", - TWITTER_DELETE_TWEET_FAILURE: "deleteTweetFailed", - TWITTER_TOGGLE_LIKE: "phone:toggleLike", - TWITTER_TOGGLE_LIKE_SUCCESS: "toggleLikeSuccess", - TWITTER_TOGGLE_LIKE_FAILURE: "toggleLikeFailed", - TWITTER_REPORT: "phone:reportTweet", - TWITTER_REPORT_SUCCESS: "reportTweetSuccess", - TWITTER_REPORT_FAILURE: "reportTweetFailed", + TWITTER_FETCH_TWEETS: 'phone:fetchTweets', + TWITTER_FETCH_TWEETS_SUCCESS: 'fetchTweets', + TWITTER_FETCH_TWEETS_FAILURE: 'fetchTweetsFailed', + TWITTER_FETCH_TWEETS_FILTERED: 'phone:fetchTweetsFiltered', + TWITTER_FETCH_TWEETS_FILTERED_SUCCESS: 'fetchTweetsFiltered', + TWITTER_FETCH_TWEETS_FILTERED_FAILURE: 'fetchTweetsFilteredFailed', + TWITTER_GET_OR_CREATE_PROFILE: 'phone:getOrCreateTwitterProfile', + TWITTER_GET_OR_CREATE_PROFILE_SUCCESS: 'getOrCreateTwitterProfile', + TWITTER_GET_OR_CREATE_PROFILE_FAILURE: 'getOrCreateTwitterProfileFailed', + TWITTER_UPDATE_PROFILE: 'phone:updateTwitterProfile', + TWITTER_UPDATE_PROFILE_LOADING: 'updateProfileLoading', + TWITTER_UPDATE_PROFILE_RESULT: 'updateProfileResult', + TWITTER_CREATE_TWEET: 'phone:createTweet', + TWITTER_CREATE_TWEET_LOADING: 'createTweetLoading', + TWITTER_CREATE_TWEET_RESULT: 'createTweetResult', + TWITTER_CREATE_TWEET_BROADCAST: 'createTweetBroadcast', + TWITTER_CREATE_TWEET_FAILURE: 'createTweetResultFailed', + TWITTER_DELETE_TWEET: 'phone:deleteTweet', + TWITTER_DELETE_TWEET_SUCCESS: 'deleteTweetSuccess', + TWITTER_DELETE_TWEET_FAILURE: 'deleteTweetFailed', + TWITTER_TOGGLE_LIKE: 'phone:toggleLike', + TWITTER_TOGGLE_LIKE_SUCCESS: 'toggleLikeSuccess', + TWITTER_TOGGLE_LIKE_FAILURE: 'toggleLikeFailed', + TWITTER_REPORT: 'phone:reportTweet', + TWITTER_REPORT_SUCCESS: 'reportTweetSuccess', + TWITTER_REPORT_FAILURE: 'reportTweetFailed', // Contacts - CONTACTS_SEND_CONTACTS: "phone:sendContacts", - CONTACTS_GET_CONTACTS: "phone:getContacts", - CONTACTS_ADD_CONTACT_NUI: "contacts:add", - CONTACTS_ADD_CONTACT: "contacts:add", - CONTACTS_ADD_CONTACT_SUCCESS: "contacts:addSuccess", - CONTACTS_UPDATE_CONTACT: "phone:updateContact", - CONTACTS_DELETE_CONTACT: "phone:deleteContact", - CONTACTS_DELETE_CONTACT_SUCCESS: "contacts:deleteSuccess", - CONTACTS_UPDATE_CONTACT_SUCCESS: "phone:updateContactSuccess", + CONTACTS_SEND_CONTACTS: 'phone:sendContacts', + CONTACTS_GET_CONTACTS: 'phone:getContacts', + CONTACTS_ADD_CONTACT_NUI: 'contacts:add', + CONTACTS_ADD_CONTACT: 'contacts:add', + CONTACTS_ADD_CONTACT_SUCCESS: 'contacts:addSuccess', + CONTACTS_UPDATE_CONTACT: 'phone:updateContact', + CONTACTS_DELETE_CONTACT: 'phone:deleteContact', + CONTACTS_DELETE_CONTACT_SUCCESS: 'contacts:deleteSuccess', + CONTACTS_UPDATE_CONTACT_SUCCESS: 'phone:updateContactSuccess', // Sellout - SELLOUT_ADD_LISTING: "phone:addListing", - SELLOUT_FETCH_LISTING: "phone:fetchAllListings", - SELLOUT_SEND_LISTING: "phone:sendAllListings", + SELLOUT_ADD_LISTING: 'phone:addListing', + SELLOUT_FETCH_LISTING: 'phone:fetchAllListings', + SELLOUT_SEND_LISTING: 'phone:sendAllListings', // - BANK_ADD_TRANSFER: "phone:addTransfer", - BANK_ADD_TRANSFER_SUCCESS: "phone:addTransferSuccess", - BANK_FETCH_TRANSACTIONS: "phone:fetchAllTransactions", - BANK_SEND_TRANSFERS: "phone:sendTransfers", - BANK_TRANSACTION_ALERT: "phone:bankTransactionAlert", - BANK_TRANSACTION_NOTIFICATION: "phone:bankTransactionNotification", - BANK_SEND_CREDENTIALS: "phone:sendBankCredentials", - BANK_GET_CREDENTIALS: "phone:getBankCredentials", + BANK_ADD_TRANSFER: 'phone:addTransfer', + BANK_ADD_TRANSFER_SUCCESS: 'phone:addTransferSuccess', + BANK_FETCH_TRANSACTIONS: 'phone:fetchAllTransactions', + BANK_SEND_TRANSFERS: 'phone:sendTransfers', + BANK_TRANSACTION_ALERT: 'phone:bankTransactionAlert', + BANK_TRANSACTION_NOTIFICATION: 'phone:bankTransactionNotification', + BANK_SEND_CREDENTIALS: 'phone:sendBankCredentials', + BANK_GET_CREDENTIALS: 'phone:getBankCredentials', //messages - MESSAGES_FETCH_MESSAGE_GROUPS: "phone:fetchMessageGroups", - MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS: "phone:fetchMessageGroupsSuccess", - MESSAGES_FETCH_MESSAGE_GROUPS_FAILED: "phone:fetchMessageGroupsFailed", - MESSAGES_CREATE_MESSAGE_GROUP: "phone:createMessageGroup", - MESSAGES_CREATE_MESSAGE_GROUP_SUCCESS: "phone:createMessageGroupSuccess", - MESSAGES_CREATE_MESSAGE_GROUP_FAILED: "phone:createMessageGroupFailed", - MESSAGES_SEND_MESSAGE: "phone:sendMessage", - MESSAGES_SEND_MESSAGE_SUCCESS: "phone:sendMessageSuccess", - MESSAGES_SEND_MESSAGE_FAILED: "phone:sendMessageFailed", - MESSAGES_FETCH_MESSAGES: "phone:fetchMessages", - MESSAGES_FETCH_MESSAGES_SUCCESS: "phone:fetchMessagesSuccess", - MESSAGES_FETCH_MESSAGES_FAILED: "phone:fetchMessagesFailed", + MESSAGES_FETCH_MESSAGE_GROUPS: 'phone:fetchMessageGroups', + MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS: 'phone:fetchMessageGroupsSuccess', + MESSAGES_FETCH_MESSAGE_GROUPS_FAILED: 'phone:fetchMessageGroupsFailed', + MESSAGES_CREATE_MESSAGE_GROUP: 'phone:createMessageGroup', + MESSAGES_CREATE_MESSAGE_GROUP_SUCCESS: 'phone:createMessageGroupSuccess', + MESSAGES_CREATE_MESSAGE_GROUP_FAILED: 'phone:createMessageGroupFailed', + MESSAGES_SEND_MESSAGE: 'phone:sendMessage', + MESSAGES_SEND_MESSAGE_SUCCESS: 'phone:sendMessageSuccess', + MESSAGES_SEND_MESSAGE_FAILED: 'phone:sendMessageFailed', + MESSAGES_FETCH_MESSAGES: 'phone:fetchMessages', + MESSAGES_FETCH_MESSAGES_SUCCESS: 'phone:fetchMessagesSuccess', + MESSAGES_FETCH_MESSAGES_FAILED: 'phone:fetchMessagesFailed', // Notes - NOTE_ADD_NOTE: "phone:addNote", - NOTE_FETCH_ALL_NOTES: "phone:fetchAllNotes", - NOTE_SEND_NOTE: "phone:sendNote", - NOTE_SEND_NOTE_SUCCESS: "phone:sendNoteSuccess", - NOTE_DELETE_NOTE: "phone:deleteNote", - NOTE_UPDATE_NOTE: "phone:updateNote", - NOTE_UPDATE_NOTE_SUCCESS: "phone:updateNoteSuccess", - NOTE_UPDATE_NOTE_FAILURE: "phone:updateNoteFailure", + NOTE_ADD_NOTE: 'phone:addNote', + NOTE_FETCH_ALL_NOTES: 'phone:fetchAllNotes', + NOTE_SEND_NOTE: 'phone:sendNote', + NOTE_SEND_NOTE_SUCCESS: 'phone:sendNoteSuccess', + NOTE_DELETE_NOTE: 'phone:deleteNote', + NOTE_UPDATE_NOTE: 'phone:updateNote', + NOTE_UPDATE_NOTE_SUCCESS: 'phone:updateNoteSuccess', + NOTE_UPDATE_NOTE_FAILURE: 'phone:updateNoteFailure', // DO NOT CHANGE WHATS BELOW, PLEASE - CHIP - OPEN_APP_CONTACTS: "phone:app:CONTACTS", - OPEN_APP_BANK: "phone:app:BANK", - OPEN_APP_NOTES: "phone:app:NOTES", - OPEN_APP_LISTINGS: "phone:app:SELLOUT", - OPEN_APP_CAMERA: "phone:app:CAMERA", + OPEN_APP_CONTACTS: 'phone:app:CONTACTS', + OPEN_APP_BANK: 'phone:app:BANK', + OPEN_APP_NOTES: 'phone:app:NOTES', + OPEN_APP_LISTINGS: 'phone:app:SELLOUT', + OPEN_APP_CAMERA: 'phone:app:CAMERA', // camera - CAMERA_TAKE_PHOTO: "phone:TakePhoto", - CAMERA_UPLOAD_PHOTO: "phone:UploadPhoto", - CAMERA_FETCH_PHOTOS: "phone:FetchPhotos", - CAMERA_SEND_PHOTOS: "phone:SendPhotos", - CAMERA_DELETE_PHOTO: "photo:deletePhoto", - CAMERA_DELETE_PHOTO_SUCCESS: "phone:deletePhotoSuccess", - CONTACTS_ACTION_RESULT: "phone:contactActionResult", + CAMERA_TAKE_PHOTO: 'phone:TakePhoto', + CAMERA_UPLOAD_PHOTO: 'phone:UploadPhoto', + CAMERA_FETCH_PHOTOS: 'phone:FetchPhotos', + CAMERA_SEND_PHOTOS: 'phone:SendPhotos', + CAMERA_DELETE_PHOTO: 'photo:deletePhoto', + CAMERA_DELETE_PHOTO_SUCCESS: 'phone:deletePhotoSuccess', + CONTACTS_ACTION_RESULT: 'phone:contactActionResult', // copy - PHONE_USE_CLIPBOARD: "phone:useClipboard", + PHONE_USE_CLIPBOARD: 'phone:useClipboard', }; diff --git a/resources/utils/messages.ts b/resources/utils/messages.ts index 987658b..088e771 100644 --- a/resources/utils/messages.ts +++ b/resources/utils/messages.ts @@ -1,4 +1,4 @@ -import apps from "./apps"; +import apps from './apps'; function sendMessage(app: string, method: string, data: any) { return SendNuiMessage(