Skip to content

Commit

Permalink
πŸ› fix: update existing active contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
rezk2ll committed Jul 9, 2024
1 parent 3af3865 commit c2c7e4f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/tom-server/src/active-contacts-api/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ class ActiveContactsService implements IActiveContactsService {
*/
save = async (userId: string, contacts: string): Promise<void> => {
try {
const existing = await this.db.get(
'activeContacts' as Collections,
['contacts'],
{ userId }
)

if (existing.length > 0) {
await this.db.update(
'activeContacts' as Collections,
{ contacts },
'userId',
userId
)
this.logger.info('active contacts updated successfully')
return
}

await this.db.insert('activeContacts' as Collections, {
userId,
contacts
Expand Down

0 comments on commit c2c7e4f

Please sign in to comment.