mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
tweak(server/calls): Tweaked structure and added enum constants
This commit is contained in:
1 parent
b051ae9fac
commit
d93bdd20d8
6 files changed
+19
-176
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { CallEvents } from '../../../typings/call';
|
||||
import { getSource } from '../utils/miscUtils';
|
||||
import CallService, { callLogger } from './calls.service';
|
||||
import CallService from './calls.service';
|
||||
import { callLogger } from './calls.utils';
|
||||
|
||||
onNet(CallEvents.INITIALIZE_CALL, (receivingNumber: string) => {
|
||||
const src = getSource();
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
import { CallHistoryItem } from '../../../typings/call';
|
||||
import { pool } from '../db';
|
||||
import { FetchDefaultLimits } from '../utils/ServerConstants';
|
||||
|
||||
export class CallsRepo {
|
||||
async saveCall(call: CallHistoryItem) {
|
||||
async saveCall(call: CallHistoryItem): Promise<void> {
|
||||
const query =
|
||||
'INSERT INTO npwd_calls (identifier, transmitter, receiver, start) VALUES (?, ?, ?, ?)';
|
||||
'INSERT INTO npwd_calls (identifier, transmitter, receiver, `start`) VALUES (?, ?, ?, ?)';
|
||||
await pool.query(query, [call.identifier, call.transmitter, call.receiver, call.start]);
|
||||
}
|
||||
|
||||
async updateCall(call: CallHistoryItem, isAccepted: boolean, end: number) {
|
||||
async updateCall(call: CallHistoryItem, isAccepted: boolean, end: number): Promise<void> {
|
||||
const query = 'UPDATE npwd_calls SET is_accepted=?, end=? WHERE identifier = ?';
|
||||
await pool.query(query, [isAccepted, end, call.identifier]);
|
||||
}
|
||||
|
||||
async fetchCalls(phoneNumber: string, limit = 50): Promise<CallHistoryItem[] | CallHistoryItem> {
|
||||
async fetchCalls(
|
||||
phoneNumber: string,
|
||||
limit = FetchDefaultLimits.CALLS_FETCH_LIMIT,
|
||||
): Promise<CallHistoryItem[] | CallHistoryItem> {
|
||||
const query =
|
||||
'SELECT * FROM npwd_calls WHERE receiver = ? OR transmitter = ? ORDER BY id DESC LIMIT ?';
|
||||
const [result] = await pool.query(query, [phoneNumber, phoneNumber, limit]);
|
||||
|
||||
return <CallHistoryItem[]>result;
|
||||
return <CallHistoryItem[] | CallHistoryItem>result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import Collection from '@discordjs/collection';
|
||||
import { CallEvents, CallHistoryItem } from '../../../typings/call';
|
||||
import { mainLogger } from '../sv_logger';
|
||||
import CallsDB, { CallsRepo } from './calls.db';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import PlayerService from '../players/player.service';
|
||||
|
||||
export const callLogger = mainLogger.child({ module: 'calls' });
|
||||
import { callLogger } from './calls.utils';
|
||||
|
||||
class CallsService {
|
||||
private callMap: Collection<string, CallHistoryItem>;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import { mainLogger } from '../sv_logger';
|
||||
|
||||
export const callLogger = mainLogger.child({ module: 'calls' });
|
||||
Reference in new issue
Block a user