mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Merge branch 'master' into feat/sellout-app
This commit is contained in:
46 files changed
+4495
-587
No files matched your search
@@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user