48c2f81d00
Each QR code gets a /qr/<slug> redirect that logs scans (IP, user agent, timestamp) to disk. The admin QR Codes view lets you add, edit, enable/disable, and delete codes, with per-code scan history inline. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
86 lines
2.6 KiB
JavaScript
86 lines
2.6 KiB
JavaScript
import {
|
|
EMPTY_HIT_STATS,
|
|
EMPTY_VISITOR_STATS,
|
|
DEFAULT_PUBLISH_STATE,
|
|
DEFAULT_REPLY_TEMPLATES,
|
|
buildDefaultPodcastChecklist,
|
|
} from './config.js'
|
|
|
|
export const state = {
|
|
cachedSiteContent: null,
|
|
cachedDraftSiteContent: null,
|
|
publishState: { ...DEFAULT_PUBLISH_STATE },
|
|
|
|
hitStats: { ...EMPTY_HIT_STATS },
|
|
hitStatsWritePromise: Promise.resolve(),
|
|
lastHitStatsWrite: { ok: true, at: null, error: null },
|
|
|
|
visitorStats: { ...EMPTY_VISITOR_STATS },
|
|
visitorStatsWritePromise: Promise.resolve(),
|
|
lastVisitorStatsWrite: { ok: true, at: null, error: null },
|
|
|
|
contactSubmissions: [],
|
|
contactSubmissionsWritePromise: Promise.resolve(),
|
|
|
|
questions: [],
|
|
questionsWritePromise: Promise.resolve(),
|
|
|
|
draftQuestions: null,
|
|
draftQuestionsWritePromise: Promise.resolve(),
|
|
|
|
replyTemplates: [...DEFAULT_REPLY_TEMPLATES],
|
|
replyTemplatesWritePromise: Promise.resolve(),
|
|
|
|
replyHistory: [],
|
|
replyHistoryWritePromise: Promise.resolve(),
|
|
|
|
podcastChecklist: buildDefaultPodcastChecklist(),
|
|
podcastChecklistWritePromise: Promise.resolve(),
|
|
|
|
studyUsers: [],
|
|
studyUsersWritePromise: Promise.resolve(),
|
|
|
|
studyCommunityPosts: [],
|
|
studyCommunityWritePromise: Promise.resolve(),
|
|
|
|
studyReminders: { users: {}, updatedAt: new Date().toISOString() },
|
|
studyRemindersWritePromise: Promise.resolve(),
|
|
|
|
studyComments: [],
|
|
studyCommentsWritePromise: Promise.resolve(),
|
|
|
|
studyCertificates: [],
|
|
studyCertificatesWritePromise: Promise.resolve(),
|
|
|
|
// episodeScripts: { [episodeNumber]: { text, title, filename, uploadedAt } }
|
|
episodeScripts: {},
|
|
episodeScriptsWritePromise: Promise.resolve(),
|
|
|
|
downloadCounts: {},
|
|
downloadCountsWritePromise: Promise.resolve(),
|
|
|
|
// qrCodes: Array<{ id, slug, label, destination, createdAt }>
|
|
// qrScans: Array<{ id, qrId, slug, scannedAt, ip, userAgent }>
|
|
qrCodes: [],
|
|
qrScans: [],
|
|
qrCodesWritePromise: Promise.resolve(),
|
|
|
|
lastBackupStatus: { ok: true, at: null, error: null, file: null },
|
|
lastCachePurgeStatus: { ok: true, at: null, error: null },
|
|
lastDeployHookStatus: { ok: true, at: null, error: null },
|
|
|
|
// In-memory caches (not persisted between restarts)
|
|
studyNotesCache: new Map(), // userId -> { [sectionId]: string }
|
|
studyNotesWriteQueues: new Map(), // userId -> Promise
|
|
studyProgressCache: new Map(), // userId -> { byStudy: ... }
|
|
studyProgressWriteQueues: new Map(), // userId -> Promise
|
|
|
|
studySessions: new Map(),
|
|
studyTotpPendingTokens: new Map(),
|
|
emailOtpStore: new Map(),
|
|
|
|
titusDownloadTokens: new Map(),
|
|
contactSubmitCooldownByEmail: new Map(),
|
|
resendEmailSubmissionIndex: new Map(),
|
|
}
|