diff --git a/packages/api/src/routers/svc/integrations.ts b/packages/api/src/routers/svc/integrations.ts index 0193af729..f8dda9d40 100644 --- a/packages/api/src/routers/svc/integrations.ts +++ b/packages/api/src/routers/svc/integrations.ts @@ -127,10 +127,9 @@ export function integrationsServiceRouter() { return } } - // update integration syncedAt if successful + // delete task name if completed await getRepository(Integration).update(integration.id, { taskName: null, - syncedAt: new Date(), }) } else { logger.info('unknown action', { action }) diff --git a/packages/api/src/services/integrations.ts b/packages/api/src/services/integrations.ts index 221bb4022..f13b68d3e 100644 --- a/packages/api/src/services/integrations.ts +++ b/packages/api/src/services/integrations.ts @@ -5,6 +5,7 @@ import { wait } from '../utils/helpers' import { Page } from '../elastic/types' import { getHighlightLocation, getHighlightUrl } from './highlights' import { Integration } from '../entity/integration' +import { getRepository } from '../entity/utils' interface ReadwiseHighlight { // The highlight text, (technically the only field required in a highlight object) @@ -98,6 +99,13 @@ export const syncWithIntegration = async ( default: return false } + // update integration syncedAt if successful + if (result) { + console.log('updating integration syncedAt') + await getRepository(Integration).update(integration.id, { + syncedAt: new Date(), + }) + } return result } diff --git a/packages/api/test/routers/integrations.test.ts b/packages/api/test/routers/integrations.test.ts index bc292ea79..99892f724 100644 --- a/packages/api/test/routers/integrations.test.ts +++ b/packages/api/test/routers/integrations.test.ts @@ -285,7 +285,7 @@ describe('Integrations routers', () => { }) context('when action is sync_all', () => { - before(() => { + before(async () => { action = 'sync_all' data = { message: { @@ -306,6 +306,10 @@ describe('Integrations routers', () => { }) .post('/highlights', highlightsData) .reply(200) + await getRepository(Integration).update(integration.id, { + syncedAt: null, + taskName: 'some task name', + }) }) it('returns 200 with OK', async () => {