Merge branch 'master' into feat/sellout-app

This commit is contained in:
Christopher Gjelten authored and GitHub committed 2020-10-18 22:08:56 +02:00
commit 771ad147d7
46 files changed
+4495 -587

No files matched your search

+17 -12
View File
@@ -1,21 +1,27 @@
import { ESX } from './server';
import { pool } from './db';
import events from '../utils/events';
import { ESX } from "./server";
import { pool } from "./db";
import events from "../utils/events";
interface Contacts {
display: string;
number: string;
}
async function fetchAllContacts(identifier: string) : Promise<Contacts[]> {
async function fetchAllContacts(identifier: string): Promise<Contacts[]> {
const query = "SELECT * FROM npwd_phone_contacts WHERE identifier = ?";
const [ results ] = await pool.query(query, [identifier]);
const [results] = await pool.query(query, [identifier]);
const contacts = <Contacts[]>results;
return contacts;
}
async function addContact(identifier: string, number: string, display: string, avatar: string):Promise<any> {
const query = "INSERT INTO npwd_phone_contacts (identifier, number, display, avatar) VALUES (?, ?, ?, ?)"
async function addContact(
identifier: string,
number: string,
display: string,
avatar: string
): Promise<any> {
const query =
"INSERT INTO npwd_phone_contacts (identifier, number, display, avatar) VALUES (?, ?, ?, ?)";
await pool.query(query, [identifier, number, display, avatar]);
}
@@ -27,9 +33,8 @@ onNet(events.CONTACTS_GET_CONTACTS, async () => {
const _identifier = xPlayer.getIdentifier();
const contacts = await fetchAllContacts(_identifier);
emitNet(events.CONTACTS_SEND_CONTACTS, _source, contacts)
} catch(error) {
emitNet(events.CONTACTS_SEND_CONTACTS, _source, contacts);
} catch (error) {
console.log("Failed to fetch contacts: ", error);
}
})
@@ -44,5 +49,5 @@ onNet(events.CONTACTS_ADD_CONTACT, (number: string, display: string, avatar: str
} catch(error) {
console.log("Failed to add contact: ", error);
}
});
});