mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-02 14:38:46 +00:00
* feat(resouces/messages): broadcast messagse to participants * feat(phone/messages): notifications for messages * remove weird empty onNet * reformat? * last reformat! This pr will be squashed * tweak(phone/messages): send groupName to notification alert * fix identifer * fixing notification groupName * resbasee...i think * feat(messages): check for unread messages * send nui event is count > 0 * remove usless test * import.sql update * Refactor NotificationsProvider and fix messages notifications * Send groupId on message broadcast * Update phone/src/apps/messages/components/modal/Conversation.tsx * Update phone/src/apps/messages/hooks/useMessageNotifications.ts * Update phone/src/os/notifications/providers/NotificationsProvider.tsx * Update phone/src/common/typings/messages.ts * Update phone/src/apps/messages/hooks/useMessageNotifications.ts * clean sql file * Update resources/server/sv_messages.ts * Fetch message groups when other person created for you * fix sql * Select unreadCount from messageGroups * whatever husky again * Add members menu and add contact in messages * Add from group bubbles * Fix messages scroll with new msg * Message image menu flicker + justify bottom messages * Improve debugging * Add container to Slider * Improve logger * Fix create message * add creator identifier to group hash * Fix dafuq i broke * group_id bigger varchar in column * group_id bigger varchar in column * Phone visibility default browser * Add debugging Co-authored-by: J Francisco Rader <[email protected]> Co-authored-by: J Francisco Rader <[email protected]>
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import { pool } from './db';
|
|
import { ESX } from './server';
|
|
import { XPlayer } from 'esx.js/@types/server';
|
|
|
|
interface IPhoneNumber {
|
|
phone_number: string;
|
|
}
|
|
|
|
interface Identifier {
|
|
identifier: string;
|
|
}
|
|
|
|
export async function usePhoneNumber(identifier: string): Promise<string> {
|
|
const query = 'SELECT phone_number FROM users WHERE identifier = ?';
|
|
const [results] = await pool.query(query, [identifier]);
|
|
const phoneNumber = <IPhoneNumber[]>results;
|
|
return phoneNumber[0].phone_number;
|
|
}
|
|
|
|
export const getSource = () => (global as any).source;
|
|
|
|
// we might need to run a db query on this.
|
|
// to make it more standalone
|
|
export function getIdentifier(source: number): string {
|
|
return ESX.GetPlayerFromId(source).getIdentifier();
|
|
}
|
|
|
|
export async function getIdentifierByPhoneNumber(phoneNumber: string): Promise<string> {
|
|
const query = 'SELECT identifier FROM users WHERE phone_number = ?';
|
|
const [results] = await pool.query(query, [phoneNumber]);
|
|
const identifier = <Identifier[]>results;
|
|
return identifier[0].identifier;
|
|
}
|
|
|
|
/**
|
|
* Returns the player phoneNumber for a passed identifier
|
|
* @param identifier The players phone number
|
|
*/
|
|
export async function getPlayerFromIdentifier(
|
|
identifier: string
|
|
): Promise<XPlayer> {
|
|
return new Promise((res, rej) => {
|
|
const xPlayers = ESX.GetPlayers();
|
|
|
|
for (const player of xPlayers) {
|
|
const xPlayer = ESX.GetPlayerFromId(player);
|
|
if (
|
|
xPlayer.getIdentifier() != null &&
|
|
xPlayer.getIdentifier() == identifier
|
|
) {
|
|
res(xPlayer);
|
|
}
|
|
}
|
|
|
|
rej(new Error('Call Target Identifier was not found in xPlayers array'));
|
|
});
|
|
}
|