A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: send event if system clock is out of sync
thecodrr0bfc195e5f9e
diff --git a/packages/core/api/index.js b/packages/core/api/index.jsindex 7c3c026c6..2bbe89b29 100644--- a/packages/core/api/index.js+++ b/packages/core/api/index.js@@ -156,13 +156,21 @@ class Database {try {var { type, data } = JSON.parse(event.data);data = JSON.parse(data);- // console.log(type, data);} catch (e) {console.log("SSE: Unsupported message. Message = ", event.data);return;}switch (type) {+ case "heartbeat":+ const { t } = data;+ const serverTime = new Date(t).getTime();+ const localTime = Date.now();+ const diff = localTime - serverTime;+ const DIFFERENCE_THRESHOLD = 10 * 1000;+ if (Math.abs(diff) > DIFFERENCE_THRESHOLD)+ EV.publish(EVENTS.systemTimeInvalid, { serverTime, localTime });+ break;case "upgrade":const user = await this.user.getUser();user.subscription = data;diff --git a/packages/core/common.js b/packages/core/common.jsindex 612e036f8..d16dd5aa5 100644--- a/packages/core/common.js+++ b/packages/core/common.js@@ -52,6 +52,7 @@ export const EVENTS = {attachmentDeleted: "attachment:deleted",mediaAttachmentDownloaded: "attachments:mediaDownloaded",vaultLocked: "vault:locked",+ systemTimeInvalid: "system:invalidTime",};export const CURRENT_DATABASE_VERSION = 5.4;