mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
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:
committed by
Copybot
parent
03c30a9d1b
commit
27e5044d30
@@ -45,6 +45,9 @@ async function buildUserSettings(req, res, user) {
|
||||
breadcrumbs: user.ace.breadcrumbs,
|
||||
referencesSearchMode: user.ace.referencesSearchMode,
|
||||
darkModePdf: user.ace.darkModePdf ?? false,
|
||||
zotero: user.ace.zotero,
|
||||
mendeley: user.ace.mendeley,
|
||||
papers: user.ace.papers,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -7,6 +7,19 @@ const { ObjectId } = Schema
|
||||
// See https://stackoverflow.com/questions/386294/what-is-the-maximum-length-of-a-valid-email-address/574698#574698
|
||||
const MAX_EMAIL_LENGTH = 254
|
||||
const MAX_NAME_LENGTH = 255
|
||||
const refProviderSettingsSchema = {
|
||||
enabled: { type: Boolean, default: true },
|
||||
groups: {
|
||||
type: [
|
||||
{
|
||||
id: { type: String },
|
||||
},
|
||||
],
|
||||
default: [],
|
||||
},
|
||||
disablePersonalLibrary: { type: Boolean, default: false },
|
||||
migrated: { type: Boolean, default: false },
|
||||
}
|
||||
|
||||
export const UserSchema = new Schema(
|
||||
{
|
||||
@@ -94,6 +107,9 @@ export const UserSchema = new Schema(
|
||||
breadcrumbs: { type: Boolean, default: true },
|
||||
referencesSearchMode: { type: String, default: 'advanced' }, // 'advanced' or 'simple'
|
||||
darkModePdf: { type: Boolean, default: false },
|
||||
zotero: refProviderSettingsSchema,
|
||||
mendeley: refProviderSettingsSchema,
|
||||
papers: refProviderSettingsSchema,
|
||||
},
|
||||
features: {
|
||||
collaborators: {
|
||||
|
||||
Reference in New Issue
Block a user