Bernt Christian Egeland 2 minggu lalu
induk
melakukan
c6474e2569

+ 0 - 1
prisma/seed_dummy_data.ts

@@ -1427,7 +1427,6 @@ async function seed() {
         data: {
           organizationId: ORG_ID,
           vehicleId: hist.vehicleId,
-          organizationId: ORG_ID,
           title: entry.title,
           description: entry.desc,
           type: entry.type,

+ 4 - 0
src/__tests__/lib/demo-guard-coverage.test.ts

@@ -50,6 +50,10 @@ const EGRESS_PATHS: Array<{ file: string; stoppedBy: RegExp }> = [
     file: 'src/features/notifications/Lib/pushToTechnician.ts',
     stoppedBy: /if \(isDemoMode\) return/,
   },
+  // The licence check against torqvoice.com, shared by the Validate button,
+  // the daily cron and the self-heal in getFeatures. The demo's plan is fixed
+  // in getFeatures, so the fetch itself returns "unreachable" instead.
+  { file: 'src/lib/license/revalidate.ts', stoppedBy: /if \(isDemoMode\)/ },
   // The integrations catalog. Every connector call goes out through one HTTP
   // client, every token exchange or refresh through the OAuth module, and
   // every context a connector runs with (jobs, webhooks, tests, lookups,

+ 6 - 0
src/lib/license/revalidate.ts

@@ -1,4 +1,5 @@
 import type { Prisma } from '@/generated/prisma/client'
+import { isDemoMode } from '@/lib/demo'
 import { db } from '@/lib/db'
 import { SETTING_KEYS } from '@/features/settings/Schema/settingsSchema'
 import { verifyLicenseToken, type LicenseTokenVerification } from './token'
@@ -27,6 +28,11 @@ export async function fetchRemoteLicense(
   licenseKey: string,
   organizationId: string
 ): Promise<RemoteLicenseResult> {
+  // The demo's entitlements are fixed in getFeatures, so there is nothing to
+  // ask torqvoice.com about, and no key of anyone's to send it.
+  if (isDemoMode) {
+    return { reachable: false, valid: false, plan: 'free', expiresAt: '', token: null }
+  }
   try {
     const response = await fetch(`${TORQVOICE_COM_URL}/api/license/validate`, {
       method: 'POST',