Migrating reference settings to mongo and exposing them through code … (#31726)

* Migrating reference settings to mongo and exposing them through code mirror context

* removing undefined optional for reference manager type settings

* allowing partial updates to user settings objects, and remove repeated cypress intercepts

* Zod schema parsing for user reference manager settings

* Splitting ref provider mongoose schema into const

* Persisting local storage reference settings to mongo and deleting from local

* Enforcing ref provider group id to always be type string

* Fixing test and format errors

* Migrated flag for settings to only migrate once

* fixing cypress tests adding migrated flag

* persisting local storage to allow for easy rollback

GitOrigin-RevId: f59522bdee6f0e56efb7d98b9d9373a743619ec8
This commit is contained in:
l-obrien-overleaf
2026-03-26 09:07:40 +00:00
committed by Copybot
parent 03c30a9d1b
commit 27e5044d30
9 changed files with 368 additions and 0 deletions
@@ -329,11 +329,23 @@ async function unsubscribe(req, res, next) {
})
}
const refProviderSettingsSchema = z
.object({
enabled: z.boolean().optional(),
groups: z.array(z.object({ id: z.string() })).optional(),
disablePersonalLibrary: z.boolean().optional(),
migrated: z.boolean().optional(),
})
.optional()
const updateUserSettingsSchema = z.object({
body: z
.object({
first_name: z.string().max(255).nullish(),
last_name: z.string().max(255).nullish(),
zotero: refProviderSettingsSchema,
mendeley: refProviderSettingsSchema,
papers: refProviderSettingsSchema,
})
.passthrough(),
// TODO: complete the schema and remove the passthrough
@@ -413,6 +425,15 @@ async function updateUserSettings(req, res, next) {
if (body.darkModePdf != null) {
user.ace.darkModePdf = Boolean(body.darkModePdf)
}
if (body.zotero != null) {
user.ace.zotero = { ...user.ace.zotero, ...body.zotero }
}
if (body.mendeley != null) {
user.ace.mendeley = { ...user.ace.mendeley, ...body.mendeley }
}
if (body.papers != null) {
user.ace.papers = { ...user.ace.papers, ...body.papers }
}
await user.save()
const newEmail = body.email?.trim().toLowerCase()