Files
twenty/packages/twenty-server/src/modules/messaging/message-import-manager/utils/is-sync-stale.util.ts
2024-06-25 11:57:02 +02:00

14 lines
485 B
TypeScript

import { MESSAGING_IMPORT_ONGOING_SYNC_TIMEOUT } from 'src/modules/messaging/message-import-manager/constants/messaging-import-ongoing-sync-timeout.constant';
export const isSyncStale = (syncStageStartedAt: string): boolean => {
const syncStageStartedTime = new Date(syncStageStartedAt).getTime();
if (isNaN(syncStageStartedTime)) {
throw new Error('Invalid date format');
}
return (
Date.now() - syncStageStartedTime > MESSAGING_IMPORT_ONGOING_SYNC_TIMEOUT
);
};