Skip to content

Commit

Permalink
refactor: call model directly
Browse files Browse the repository at this point in the history
  • Loading branch information
tapiarafael authored and ggazzo committed Sep 12, 2024
1 parent cb5e7d0 commit 81d6c87
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 3 additions & 3 deletions apps/meteor/app/livechat/server/api/v1/contact.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LivechatCustomField, LivechatVisitors } from '@rocket.chat/models';
import { LivechatContacts, LivechatCustomField, LivechatVisitors } from '@rocket.chat/models';
import {
isPOSTOmnichannelContactsProps,
isPOSTUpdateOmnichannelContactsProps,
Expand All @@ -9,7 +9,7 @@ import { Match, check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';

import { API } from '../../../../api/server';
import { Contacts, createContact, updateContact, getContactById } from '../../lib/Contacts';
import { Contacts, createContact, updateContact } from '../../lib/Contacts';

API.v1.addRoute(
'omnichannel/contact',
Expand Down Expand Up @@ -130,7 +130,7 @@ API.v1.addRoute(
if (process.env.TEST_MODE?.toUpperCase() !== 'TRUE') {
throw new Meteor.Error('error-not-allowed', 'This endpoint is only allowed in test mode');
}
const contact = await getContactById(this.queryParams.contactId);
const contact = await LivechatContacts.findOneById(this.queryParams.contactId);

return API.v1.success({ contact });
},
Expand Down
4 changes: 0 additions & 4 deletions apps/meteor/app/livechat/server/lib/Contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,6 @@ export async function updateContact(params: UpdateContactParams): Promise<ILivec
return updatedContact;
}

export async function getContactById(contactId: string): Promise<ILivechatContact | null> {
return LivechatContacts.findOneById(contactId);
}

async function getAllowedCustomFields(): Promise<ILivechatCustomField[]> {
return LivechatCustomField.findByScope(
'visitor',
Expand Down

0 comments on commit 81d6c87

Please sign in to comment.