Skip to content

Commit

Permalink
feat(apps/game): map default contacts and return contact with id
Browse files Browse the repository at this point in the history
Signed-off-by: Nullified <[email protected]>
  • Loading branch information
Gittified committed Jan 13, 2024
1 parent 96a7150 commit b8c1743
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/game/server/contacts/contacts.database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ import { DbInterface } from '@npwd/database';
import { config } from '@npwd/config/server';

export class _ContactsDB {
private readonly defaultContacts: Contact[] = config.defaultContacts.map((contact) => ({
id: `${contact.display}:${contact.number}`,
...contact,
}));

async fetchAllContacts(identifier: string): Promise<Contact[]> {
const query = 'SELECT * FROM npwd_phone_contacts WHERE identifier = ? ORDER BY display ASC';
const [results] = await DbInterface._rawExec(query, [identifier]);

return config.defaultContacts.concat(<Contact[]>results);
return this.defaultContacts.concat(<Contact[]>results);
}

async addContact(
Expand Down

0 comments on commit b8c1743

Please sign in to comment.