ProjectController.mjs 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294
  1. import _ from 'lodash'
  2. import OError from '@overleaf/o-error'
  3. import crypto from 'node:crypto'
  4. import { setTimeout } from 'node:timers/promises'
  5. import pProps from 'p-props'
  6. import logger from '@overleaf/logger'
  7. import { expressify } from '@overleaf/promise-utils'
  8. import mongodb from 'mongodb-legacy'
  9. import ProjectDeleter from './ProjectDeleter.js'
  10. import ProjectDuplicator from './ProjectDuplicator.mjs'
  11. import ProjectCreationHandler from './ProjectCreationHandler.js'
  12. import EditorController from '../Editor/EditorController.js'
  13. import ProjectHelper from './ProjectHelper.js'
  14. import metrics from '@overleaf/metrics'
  15. import { User } from '../../models/User.js'
  16. import SubscriptionLocator from '../Subscription/SubscriptionLocator.js'
  17. import { isPaidSubscription } from '../Subscription/SubscriptionHelper.js'
  18. import LimitationsManager from '../Subscription/LimitationsManager.js'
  19. import Settings from '@overleaf/settings'
  20. import AuthorizationManager from '../Authorization/AuthorizationManager.js'
  21. import InactiveProjectManager from '../InactiveData/InactiveProjectManager.mjs'
  22. import ProjectUpdateHandler from './ProjectUpdateHandler.js'
  23. import ProjectGetter from './ProjectGetter.js'
  24. import PrivilegeLevels from '../Authorization/PrivilegeLevels.js'
  25. import SessionManager from '../Authentication/SessionManager.js'
  26. import Sources from '../Authorization/Sources.js'
  27. import TokenAccessHandler from '../TokenAccess/TokenAccessHandler.js'
  28. import CollaboratorsGetter from '../Collaborators/CollaboratorsGetter.js'
  29. import ProjectEntityHandler from './ProjectEntityHandler.js'
  30. import TpdsProjectFlusher from '../ThirdPartyDataStore/TpdsProjectFlusher.js'
  31. import Features from '../../infrastructure/Features.js'
  32. import BrandVariationsHandler from '../BrandVariations/BrandVariationsHandler.mjs'
  33. import UserController from '../User/UserController.mjs'
  34. import AnalyticsManager from '../Analytics/AnalyticsManager.js'
  35. import SplitTestHandler from '../SplitTests/SplitTestHandler.js'
  36. import SplitTestSessionHandler from '../SplitTests/SplitTestSessionHandler.js'
  37. import FeaturesUpdater from '../Subscription/FeaturesUpdater.js'
  38. import SpellingHandler from '../Spelling/SpellingHandler.mjs'
  39. import { hasAdminAccess } from '../Helpers/AdminAuthorizationHelper.js'
  40. import InstitutionsFeatures from '../Institutions/InstitutionsFeatures.js'
  41. import InstitutionsGetter from '../Institutions/InstitutionsGetter.js'
  42. import ProjectAuditLogHandler from './ProjectAuditLogHandler.mjs'
  43. import PublicAccessLevels from '../Authorization/PublicAccessLevels.js'
  44. import TagsHandler from '../Tags/TagsHandler.js'
  45. import TutorialHandler from '../Tutorial/TutorialHandler.mjs'
  46. import UserUpdater from '../User/UserUpdater.js'
  47. import Modules from '../../infrastructure/Modules.js'
  48. import { z, zz, validateReq } from '../../infrastructure/Validation.js'
  49. import UserGetter from '../User/UserGetter.js'
  50. import { isStandaloneAiAddOnPlanCode } from '../Subscription/AiHelper.js'
  51. import SubscriptionController from '../Subscription/SubscriptionController.mjs'
  52. import { formatCurrency } from '../../util/currency.js'
  53. const { ObjectId } = mongodb
  54. /**
  55. * @import { GetProjectsRequest, GetProjectsResponse, Project } from "./types"
  56. */
  57. const updateProjectAdminSettingsSchema = z.object({
  58. params: z.object({
  59. Project_id: zz.coercedObjectId(ObjectId),
  60. }),
  61. body: z.object({
  62. publicAccessLevel: z
  63. .enum(
  64. [PublicAccessLevels.PRIVATE, PublicAccessLevels.TOKEN_BASED],
  65. 'unexpected access level'
  66. )
  67. .optional(),
  68. }),
  69. })
  70. const updateProjectSettingsSchema = z.object({
  71. params: z.object({
  72. Project_id: zz.coercedObjectId(),
  73. }),
  74. body: z.object({
  75. compiler: z.string().optional(),
  76. imageName: z.string().optional(),
  77. mainBibliographyDocId: zz.objectId().optional(),
  78. name: z.string().optional(),
  79. rootDocId: zz.objectId().optional(),
  80. spellCheckLanguage: z.string().optional(),
  81. }),
  82. })
  83. const _ProjectController = {
  84. _isInPercentageRollout(rolloutName, objectId, percentage) {
  85. if (Settings.bypassPercentageRollouts === true) {
  86. return true
  87. }
  88. const data = `${rolloutName}:${objectId.toString()}`
  89. const md5hash = crypto.createHash('md5').update(data).digest('hex')
  90. const counter = parseInt(md5hash.slice(26, 32), 16)
  91. return counter % 100 < percentage
  92. },
  93. async updateProjectSettings(req, res) {
  94. const { params, body } = validateReq(req, updateProjectSettingsSchema)
  95. const projectId = params.Project_id
  96. if (body.compiler != null) {
  97. await EditorController.promises.setCompiler(projectId, body.compiler)
  98. }
  99. if (body.imageName != null) {
  100. await EditorController.promises.setImageName(projectId, body.imageName)
  101. }
  102. if (body.name != null) {
  103. await EditorController.promises.renameProject(projectId, body.name)
  104. }
  105. if (body.spellCheckLanguage != null) {
  106. await EditorController.promises.setSpellCheckLanguage(
  107. projectId,
  108. body.spellCheckLanguage
  109. )
  110. }
  111. if (body.rootDocId != null) {
  112. await EditorController.promises.setRootDoc(projectId, body.rootDocId)
  113. }
  114. if (body.mainBibliographyDocId != null) {
  115. await EditorController.promises.setMainBibliographyDoc(
  116. projectId,
  117. body.mainBibliographyDocId
  118. )
  119. }
  120. res.sendStatus(204)
  121. },
  122. async updateProjectAdminSettings(req, res) {
  123. const { params, body } = validateReq(req, updateProjectAdminSettingsSchema)
  124. const projectId = params.Project_id
  125. const user = SessionManager.getSessionUser(req.session)
  126. if (!Features.hasFeature('link-sharing')) {
  127. return res.sendStatus(403) // return Forbidden if link sharing is not enabled
  128. }
  129. if (body.publicAccessLevel != null) {
  130. await EditorController.promises.setPublicAccessLevel(
  131. projectId,
  132. body.publicAccessLevel
  133. )
  134. await ProjectAuditLogHandler.promises.addEntry(
  135. projectId,
  136. 'toggle-access-level',
  137. user._id,
  138. req.ip,
  139. { publicAccessLevel: body.publicAccessLevel, status: 'OK' }
  140. )
  141. res.sendStatus(204)
  142. } else {
  143. res.sendStatus(500)
  144. }
  145. },
  146. async deleteProject(req, res) {
  147. const projectId = req.params.Project_id
  148. const user = SessionManager.getSessionUser(req.session)
  149. await ProjectDeleter.promises.deleteProject(projectId, {
  150. deleterUser: user,
  151. ipAddress: req.ip,
  152. })
  153. res.sendStatus(200)
  154. },
  155. async archiveProject(req, res) {
  156. const projectId = req.params.Project_id
  157. const userId = SessionManager.getLoggedInUserId(req.session)
  158. await ProjectDeleter.promises.archiveProject(projectId, userId)
  159. res.sendStatus(200)
  160. },
  161. async unarchiveProject(req, res) {
  162. const projectId = req.params.Project_id
  163. const userId = SessionManager.getLoggedInUserId(req.session)
  164. await ProjectDeleter.promises.unarchiveProject(projectId, userId)
  165. res.sendStatus(200)
  166. },
  167. async trashProject(req, res) {
  168. const projectId = req.params.project_id
  169. const userId = SessionManager.getLoggedInUserId(req.session)
  170. await ProjectDeleter.promises.trashProject(projectId, userId)
  171. res.sendStatus(200)
  172. },
  173. async untrashProject(req, res) {
  174. const projectId = req.params.project_id
  175. const userId = SessionManager.getLoggedInUserId(req.session)
  176. await ProjectDeleter.promises.untrashProject(projectId, userId)
  177. res.sendStatus(200)
  178. },
  179. async expireDeletedProjectsAfterDuration(_req, res) {
  180. await ProjectDeleter.promises.expireDeletedProjectsAfterDuration()
  181. res.sendStatus(200)
  182. },
  183. async expireDeletedProject(req, res) {
  184. const { projectId } = req.params
  185. await ProjectDeleter.promises.expireDeletedProject(projectId)
  186. res.sendStatus(200)
  187. },
  188. async restoreProject(req, res) {
  189. const projectId = req.params.Project_id
  190. await ProjectDeleter.promises.restoreProject(projectId)
  191. res.sendStatus(200)
  192. },
  193. async cloneProject(req, res, next) {
  194. res.setTimeout(5 * 60 * 1000) // allow extra time for the copy to complete
  195. metrics.inc('cloned-project')
  196. const projectId = req.params.Project_id
  197. const { projectName, tags } = req.body
  198. logger.debug({ projectId, projectName }, 'cloning project')
  199. if (!SessionManager.isUserLoggedIn(req.session)) {
  200. return res.json({ redir: '/register' })
  201. }
  202. const currentUser = SessionManager.getSessionUser(req.session)
  203. const { first_name: firstName, last_name: lastName, email } = currentUser
  204. try {
  205. const project = await ProjectDuplicator.promises.duplicate(
  206. currentUser,
  207. projectId,
  208. projectName,
  209. tags
  210. )
  211. res.json({
  212. name: project.name,
  213. lastUpdated: project.lastUpdated,
  214. project_id: project._id,
  215. owner_ref: project.owner_ref,
  216. owner: {
  217. first_name: firstName,
  218. last_name: lastName,
  219. email,
  220. _id: currentUser._id,
  221. },
  222. })
  223. } catch (err) {
  224. OError.tag(err, 'error cloning project', {
  225. projectId,
  226. userId: currentUser._id,
  227. })
  228. return next(err)
  229. }
  230. },
  231. async newProject(req, res) {
  232. const currentUser = SessionManager.getSessionUser(req.session)
  233. const {
  234. first_name: firstName,
  235. last_name: lastName,
  236. email,
  237. _id: userId,
  238. } = currentUser
  239. const projectName =
  240. req.body.projectName != null ? req.body.projectName.trim() : undefined
  241. const { template } = req.body
  242. const project = await (template === 'example'
  243. ? ProjectCreationHandler.promises.createExampleProject(
  244. userId,
  245. projectName
  246. )
  247. : ProjectCreationHandler.promises.createBasicProject(userId, projectName))
  248. res.json({
  249. project_id: project._id,
  250. owner_ref: project.owner_ref,
  251. owner: {
  252. first_name: firstName,
  253. last_name: lastName,
  254. email,
  255. _id: userId,
  256. },
  257. })
  258. },
  259. async renameProject(req, res) {
  260. const projectId = req.params.Project_id
  261. const newName = req.body.newProjectName
  262. await EditorController.promises.renameProject(projectId, newName)
  263. res.sendStatus(200)
  264. },
  265. async userProjectsJson(req, res) {
  266. const userId = SessionManager.getLoggedInUserId(req.session)
  267. let projects = await ProjectGetter.promises.findAllUsersProjects(
  268. userId,
  269. 'name lastUpdated publicAccesLevel archived trashed owner_ref'
  270. )
  271. // _buildProjectList already converts archived/trashed to booleans so isArchivedOrTrashed should not be used here
  272. projects = ProjectController._buildProjectList(projects, userId)
  273. .filter(p => !(p.archived || p.trashed))
  274. .map(p => ({ _id: p.id, name: p.name, accessLevel: p.accessLevel }))
  275. res.json({ projects })
  276. },
  277. async projectEntitiesJson(req, res) {
  278. const projectId = req.params.Project_id
  279. const project = await ProjectGetter.promises.getProject(projectId)
  280. const { docs, files } =
  281. ProjectEntityHandler.getAllEntitiesFromProject(project)
  282. const entities = docs
  283. .concat(files)
  284. // Sort by path ascending
  285. .sort((a, b) => (a.path > b.path ? 1 : a.path < b.path ? -1 : 0))
  286. .map(e => ({
  287. path: e.path,
  288. type: e.doc != null ? 'doc' : 'file',
  289. }))
  290. res.json({ project_id: projectId, entities })
  291. },
  292. async loadEditor(req, res, next) {
  293. const timer = new metrics.Timer('load-editor')
  294. if (!Settings.editorIsOpen) {
  295. return res.render('general/closed', { title: 'updating_site' })
  296. }
  297. let anonymous, userId, sessionUser
  298. if (SessionManager.isUserLoggedIn(req.session)) {
  299. sessionUser = SessionManager.getSessionUser(req.session)
  300. userId = SessionManager.getLoggedInUserId(req.session)
  301. anonymous = false
  302. } else {
  303. sessionUser = null
  304. anonymous = true
  305. userId = null
  306. }
  307. if (Features.hasFeature('saas') && userId) {
  308. const { variant: domainCaptureRedirect } =
  309. await SplitTestHandler.promises.getAssignment(
  310. req,
  311. res,
  312. 'domain-capture-redirect'
  313. )
  314. if (domainCaptureRedirect === 'enabled') {
  315. const subscription = (
  316. await Modules.promises.hooks.fire(
  317. 'findDomainCaptureGroupUserCouldBePartOf',
  318. userId
  319. )
  320. )?.[0]
  321. if (subscription) {
  322. if (subscription.managedUsersEnabled) {
  323. return res.redirect('/domain-capture')
  324. } else {
  325. // TODO show notification or anything else
  326. }
  327. }
  328. }
  329. }
  330. const projectId = req.params.Project_id
  331. // should not be used in place of split tests query param overrides (?my-split-test-name=my-variant)
  332. function shouldDisplayFeature(name, variantFlag) {
  333. if (req.query && req.query[name]) {
  334. return req.query[name] === 'true'
  335. } else {
  336. return variantFlag === true
  337. }
  338. }
  339. const splitTests = [
  340. 'compile-log-events',
  341. 'visual-preview',
  342. 'external-socket-heartbeat',
  343. 'null-test-share-modal',
  344. 'populate-clsi-cache',
  345. 'pdf-caching-cached-url-lookup',
  346. 'pdf-caching-mode',
  347. 'pdf-caching-prefetch-large',
  348. 'pdf-caching-prefetching',
  349. 'revert-file',
  350. 'revert-project',
  351. !anonymous && 'ro-mirror-on-client',
  352. 'track-pdf-download',
  353. !anonymous && 'writefull-oauth-promotion',
  354. 'hotjar',
  355. 'editor-redesign',
  356. 'overleaf-assist-bundle',
  357. 'word-count-client',
  358. 'editor-popup-ux-survey',
  359. 'client-side-references',
  360. 'editor-redesign-new-users',
  361. 'writefull-frontend-migration',
  362. 'chat-edit-delete',
  363. ].filter(Boolean)
  364. const getUserValues = async userId =>
  365. pProps(
  366. _.mapValues({
  367. user: (async () => {
  368. const user = await User.findById(
  369. userId,
  370. 'email first_name last_name referal_id signUpDate featureSwitches features featuresEpoch refProviders alphaProgram betaProgram isAdmin ace labsProgram labsExperiments completedTutorials writefull aiErrorAssistant'
  371. ).exec()
  372. // Handle case of deleted user
  373. if (!user) {
  374. UserController.logout(req, res, next)
  375. return
  376. }
  377. logger.debug({ projectId, userId }, 'got user')
  378. return FeaturesUpdater.featuresEpochIsCurrent(user)
  379. ? user
  380. : await ProjectController._refreshFeatures(req, user)
  381. })(),
  382. learnedWords: SpellingHandler.promises.getUserDictionary(userId),
  383. projectTags: TagsHandler.promises.getTagsForProject(
  384. userId,
  385. projectId
  386. ),
  387. userHasInstitutionLicence: InstitutionsFeatures.promises
  388. .hasLicence(userId)
  389. .catch(err => {
  390. logger.error({ err, userId }, 'failed to get institution licence')
  391. return false
  392. }),
  393. affiliations: InstitutionsGetter.promises
  394. .getCurrentAffiliations(userId)
  395. .catch(err => {
  396. logger.error({ err, userId }, 'failed to get institution licence')
  397. return false
  398. }),
  399. subscription:
  400. SubscriptionLocator.promises.getUsersSubscription(userId),
  401. isTokenMember: CollaboratorsGetter.promises.userIsTokenMember(
  402. userId,
  403. projectId
  404. ),
  405. isInvitedMember:
  406. CollaboratorsGetter.promises.isUserInvitedMemberOfProject(
  407. userId,
  408. projectId
  409. ),
  410. })
  411. )
  412. const splitTestAssignments = {}
  413. try {
  414. const responses = await pProps({
  415. userValues: userId ? getUserValues(userId) : defaultUserValues(),
  416. splitTestAssignments: Promise.all(
  417. splitTests.map(async splitTest => {
  418. splitTestAssignments[splitTest] =
  419. await SplitTestHandler.promises.getAssignment(req, res, splitTest)
  420. })
  421. ),
  422. project: ProjectGetter.promises.getProject(projectId, {
  423. name: 1,
  424. lastUpdated: 1,
  425. track_changes: 1,
  426. owner_ref: 1,
  427. brandVariationId: 1,
  428. overleaf: 1,
  429. tokens: 1,
  430. tokenAccessReadAndWrite_refs: 1, // used for link sharing analytics
  431. collaberator_refs: 1, // used for link sharing analytics
  432. pendingEditor_refs: 1, // used for link sharing analytics
  433. reviewer_refs: 1,
  434. }),
  435. userIsMemberOfGroupSubscription: sessionUser
  436. ? (async () =>
  437. (
  438. await LimitationsManager.promises.userIsMemberOfGroupSubscription(
  439. sessionUser
  440. )
  441. ).isMember)()
  442. : false,
  443. _flushToTpds:
  444. TpdsProjectFlusher.promises.flushProjectToTpdsIfNeeded(projectId),
  445. _activate:
  446. InactiveProjectManager.promises.reactivateProjectIfRequired(
  447. projectId
  448. ),
  449. })
  450. const { project, userValues, userIsMemberOfGroupSubscription } = responses
  451. const {
  452. user,
  453. learnedWords,
  454. projectTags,
  455. userHasInstitutionLicence,
  456. subscription,
  457. isTokenMember,
  458. isInvitedMember,
  459. } = userValues
  460. const brandVariation = project?.brandVariationId
  461. ? await BrandVariationsHandler.promises.getBrandVariationById(
  462. project.brandVariationId
  463. )
  464. : undefined
  465. const anonRequestToken = TokenAccessHandler.getRequestToken(
  466. req,
  467. projectId
  468. )
  469. const imageNames = ProjectHelper.getAllowedImagesForUser(user)
  470. const privilegeLevel =
  471. await AuthorizationManager.promises.getPrivilegeLevelForProject(
  472. userId,
  473. projectId,
  474. anonRequestToken
  475. )
  476. await Modules.promises.hooks.fire('enforceCollaboratorLimit', projectId)
  477. if (isTokenMember) {
  478. // Check explicitly that the user is in read write token refs, while this could be inferred
  479. // from the privilege level, the privilege level of token members might later be restricted
  480. const isReadWriteTokenMember =
  481. await CollaboratorsGetter.promises.userIsReadWriteTokenMember(
  482. userId,
  483. projectId
  484. )
  485. if (isReadWriteTokenMember) {
  486. // Check for an edge case where a user is both in read write token access refs but also
  487. // an invited read write member. Ensure they are not redirected to the sharing updates page
  488. // We could also delete the token access ref if the user is already a member of the project
  489. const isInvitedReadWriteMember =
  490. await CollaboratorsGetter.promises.isUserInvitedReadWriteMemberOfProject(
  491. userId,
  492. projectId
  493. )
  494. if (!isInvitedReadWriteMember) {
  495. return res.redirect(`/project/${projectId}/sharing-updates`)
  496. }
  497. }
  498. }
  499. if (privilegeLevel == null || privilegeLevel === PrivilegeLevels.NONE) {
  500. return res.sendStatus(401)
  501. }
  502. const allowedFreeTrial =
  503. subscription == null ||
  504. isStandaloneAiAddOnPlanCode(subscription.planCode)
  505. let wsUrl = Settings.wsUrl
  506. let metricName = 'load-editor-ws'
  507. if (user.betaProgram && Settings.wsUrlBeta !== undefined) {
  508. wsUrl = Settings.wsUrlBeta
  509. metricName += '-beta'
  510. } else if (
  511. Settings.wsUrlV2 &&
  512. Settings.wsUrlV2Percentage > 0 &&
  513. (new ObjectId(projectId).getTimestamp() / 1000) % 100 <
  514. Settings.wsUrlV2Percentage
  515. ) {
  516. wsUrl = Settings.wsUrlV2
  517. metricName += '-v2'
  518. }
  519. if (req.query && req.query.ws === 'fallback') {
  520. // `?ws=fallback` will connect to the bare origin, and ignore
  521. // the custom wsUrl. Hence it must load the client side
  522. // javascript from there too.
  523. // Not resetting it here would possibly load a socket.io v2
  524. // client and connect to a v0 endpoint.
  525. wsUrl = undefined
  526. metricName += '-fallback'
  527. }
  528. metrics.inc(metricName)
  529. // don't need to wait for these to complete
  530. ProjectUpdateHandler.promises
  531. .markAsOpened(projectId)
  532. .catch(err =>
  533. logger.error({ err, projectId }, 'failed to mark project as opened')
  534. )
  535. SplitTestSessionHandler.promises
  536. .sessionMaintenance(req, userId ? user : null)
  537. .catch(err =>
  538. logger.error({ err }, 'failed to update split test info in session')
  539. )
  540. const ownerFeatures = await UserGetter.promises.getUserFeatures(
  541. project.owner_ref
  542. )
  543. if (userId) {
  544. const planLimit = ownerFeatures?.collaborators || 0
  545. const namedEditors = project.collaberator_refs?.length || 0
  546. const pendingEditors = project.pendingEditor_refs?.length || 0
  547. const exceedAtLimit = planLimit > -1 && namedEditors >= planLimit
  548. let mode = 'edit'
  549. if (privilegeLevel === PrivilegeLevels.READ_ONLY) {
  550. mode = 'view'
  551. } else if (
  552. project.track_changes === true ||
  553. project.track_changes?.[userId] === true
  554. ) {
  555. mode = 'review'
  556. }
  557. const projectOpenedSegmentation = {
  558. role: privilegeLevel,
  559. mode,
  560. ownerId: project.owner_ref,
  561. projectId: project._id,
  562. namedEditors,
  563. pendingEditors,
  564. tokenEditors: project.tokenAccessReadAndWrite_refs?.length || 0,
  565. planLimit,
  566. exceedAtLimit,
  567. }
  568. AnalyticsManager.recordEventForUserInBackground(
  569. userId,
  570. 'project-opened',
  571. projectOpenedSegmentation
  572. )
  573. User.updateOne(
  574. { _id: new ObjectId(userId) },
  575. { $set: { lastActive: new Date() } }
  576. )
  577. .exec()
  578. .catch(err =>
  579. logger.error(
  580. { err, userId },
  581. 'failed to update lastActive for user'
  582. )
  583. )
  584. }
  585. const isAdminOrTemplateOwner =
  586. hasAdminAccess(user) || Settings.templates?.user_id === userId
  587. const showTemplatesServerPro =
  588. Features.hasFeature('templates-server-pro') && isAdminOrTemplateOwner
  589. const debugPdfDetach = shouldDisplayFeature('debug_pdf_detach')
  590. const detachRole = req.params.detachRole
  591. const showSymbolPalette =
  592. !Features.hasFeature('saas') ||
  593. (user.features && user.features.symbolPalette)
  594. const userInNonIndividualSub =
  595. userIsMemberOfGroupSubscription || userHasInstitutionLicence
  596. const userHasPremiumSub =
  597. subscription && !isStandaloneAiAddOnPlanCode(subscription.planCode)
  598. // Persistent upgrade prompts
  599. // in header & in share project modal
  600. const showUpgradePrompt =
  601. Features.hasFeature('saas') &&
  602. userId &&
  603. !userHasPremiumSub &&
  604. !userInNonIndividualSub
  605. let aiFeaturesAllowed = false
  606. if (userId && Features.hasFeature('saas')) {
  607. try {
  608. // exit early if the user couldnt use ai anyways, since permissions checks are expensive
  609. const canUserWriteOrReviewProjectContent =
  610. privilegeLevel === PrivilegeLevels.READ_AND_WRITE ||
  611. privilegeLevel === PrivilegeLevels.OWNER ||
  612. privilegeLevel === PrivilegeLevels.REVIEW
  613. if (canUserWriteOrReviewProjectContent) {
  614. // check permissions for user and project owner, to see if they allow AI on the project
  615. const permissionsResults = await Modules.promises.hooks.fire(
  616. 'projectAllowsCapability',
  617. project,
  618. userId,
  619. ['use-ai']
  620. )
  621. const aiAllowed = permissionsResults.every(
  622. result => result === true
  623. )
  624. aiFeaturesAllowed = aiAllowed
  625. }
  626. } catch (err) {
  627. // still allow users to access project if we cant get their permissions, but disable AI feature
  628. aiFeaturesAllowed = false
  629. }
  630. }
  631. let featureUsage = {}
  632. if (Features.hasFeature('saas')) {
  633. const usagesLeft = await Modules.promises.hooks.fire(
  634. 'remainingFeatureAllocation',
  635. userId
  636. )
  637. usagesLeft?.forEach(usage => {
  638. featureUsage = { ...featureUsage, ...usage }
  639. })
  640. }
  641. await ProjectController._setWritefullTrialState(
  642. user,
  643. userValues,
  644. userId,
  645. aiFeaturesAllowed,
  646. userIsMemberOfGroupSubscription
  647. )
  648. const template =
  649. detachRole === 'detached'
  650. ? 'project/ide-react-detached'
  651. : 'project/ide-react'
  652. const capabilities = [...req.capabilitySet]
  653. // make sure the capability is added to CE/SP when the feature is enabled
  654. if (!Features.hasFeature('saas') && Features.hasFeature('chat')) {
  655. capabilities.push('chat')
  656. }
  657. // Note: this is not part of the default capabilities in the backend.
  658. // See services/web/modules/group-settings/app/src/DefaultGroupPolicy.mjs.
  659. // We are only using it on the frontend at the moment.
  660. // Add !Features.hasFeature('saas') to the conditional, as for chat above
  661. // if you define the capability in the backend.
  662. if (Features.hasFeature('link-sharing')) {
  663. capabilities.push('link-sharing')
  664. }
  665. const isOverleafAssistBundleEnabled =
  666. splitTestAssignments['overleaf-assist-bundle']?.variant === 'enabled'
  667. let fullFeatureSet = user?.features
  668. if (!anonymous) {
  669. fullFeatureSet = await UserGetter.promises.getUserFeatures(userId)
  670. }
  671. const hasPaidSubscription = isPaidSubscription(subscription)
  672. const hasManuallyCollectedSubscription =
  673. subscription?.collectionMethod === 'manual'
  674. const assistantDisabled = user.aiErrorAssistant?.enabled === false // the assistant has been manually disabled by the user
  675. const canUseErrorAssistant =
  676. (!hasManuallyCollectedSubscription ||
  677. fullFeatureSet?.aiErrorAssistant) &&
  678. !assistantDisabled
  679. const customerIoEnabled =
  680. await SplitTestHandler.promises.hasUserBeenAssignedToVariant(
  681. req,
  682. userId,
  683. 'customer-io-trial-conversion',
  684. 'enabled',
  685. true
  686. )
  687. const addonPrices =
  688. isOverleafAssistBundleEnabled &&
  689. (await ProjectController._getAddonPrices(req, res))
  690. let planCode = subscription?.planCode
  691. if (!planCode && !userInNonIndividualSub) {
  692. planCode = 'personal'
  693. }
  694. const planDetails = Settings.plans.find(p => p.planCode === planCode)
  695. res.render(template, {
  696. title: project.name,
  697. priority_title: true,
  698. bodyClasses: ['editor'],
  699. project_id: project._id,
  700. projectName: project.name,
  701. projectOwnerHasPremiumOnPageLoad:
  702. ownerFeatures?.compileGroup === 'priority',
  703. user: {
  704. id: userId,
  705. email: user.email,
  706. first_name: user.first_name,
  707. last_name: user.last_name,
  708. referal_id: user.referal_id,
  709. signUpDate: user.signUpDate,
  710. allowedFreeTrial,
  711. hasPaidSubscription,
  712. featureSwitches: user.featureSwitches,
  713. features: fullFeatureSet,
  714. featureUsage,
  715. refProviders: _.mapValues(user.refProviders, Boolean),
  716. writefull: {
  717. enabled: Boolean(user.writefull?.enabled && aiFeaturesAllowed),
  718. autoCreatedAccount: Boolean(user.writefull?.autoCreatedAccount),
  719. firstAutoLoad: Boolean(user.writefull?.firstAutoLoad),
  720. },
  721. alphaProgram: user.alphaProgram,
  722. betaProgram: user.betaProgram,
  723. labsProgram: user.labsProgram,
  724. inactiveTutorials: TutorialHandler.getInactiveTutorials(user),
  725. isAdmin: hasAdminAccess(user),
  726. planCode,
  727. planName: planDetails?.name,
  728. isAnnualPlan: planCode && planDetails?.annual,
  729. isMemberOfGroupSubscription: userIsMemberOfGroupSubscription,
  730. hasInstitutionLicence: userHasInstitutionLicence,
  731. },
  732. userSettings: {
  733. mode: user.ace.mode,
  734. editorTheme: user.ace.theme,
  735. fontSize: user.ace.fontSize,
  736. autoComplete: user.ace.autoComplete,
  737. autoPairDelimiters: user.ace.autoPairDelimiters,
  738. pdfViewer: user.ace.pdfViewer,
  739. syntaxValidation: user.ace.syntaxValidation,
  740. fontFamily: user.ace.fontFamily || 'lucida',
  741. lineHeight: user.ace.lineHeight || 'normal',
  742. overallTheme: user.ace.overallTheme,
  743. mathPreview: user.ace.mathPreview,
  744. breadcrumbs: user.ace.breadcrumbs,
  745. referencesSearchMode: user.ace.referencesSearchMode,
  746. enableNewEditor: user.ace.enableNewEditor ?? true,
  747. },
  748. labsExperiments: user.labsExperiments ?? [],
  749. privilegeLevel,
  750. anonymous,
  751. isTokenMember,
  752. isRestrictedTokenMember: AuthorizationManager.isRestrictedUser(
  753. userId,
  754. privilegeLevel,
  755. isTokenMember,
  756. isInvitedMember
  757. ),
  758. capabilities,
  759. roMirrorOnClientNoLocalStorage:
  760. Settings.adminOnlyLogin || project.name.startsWith('Debug: '),
  761. languages: Settings.languages,
  762. learnedWords,
  763. editorThemes: THEME_LIST,
  764. legacyEditorThemes: LEGACY_THEME_LIST,
  765. maxDocLength: Settings.max_doc_length,
  766. maxReconnectGracefullyIntervalMs:
  767. Settings.maxReconnectGracefullyIntervalMs,
  768. brandVariation,
  769. imageNames,
  770. gitBridgePublicBaseUrl: Settings.gitBridgePublicBaseUrl,
  771. gitBridgeEnabled: Features.hasFeature('git-bridge'),
  772. wsUrl,
  773. showSupport: Features.hasFeature('support'),
  774. showTemplatesServerPro,
  775. debugPdfDetach,
  776. showSymbolPalette,
  777. symbolPaletteAvailable: Features.hasFeature('symbol-palette'),
  778. userRestrictions: Array.from(req.userRestrictions || []),
  779. showAiErrorAssistant: aiFeaturesAllowed && canUseErrorAssistant,
  780. detachRole,
  781. metadata: { viewport: false },
  782. showUpgradePrompt,
  783. fixedSizeDocument: true,
  784. hasTrackChangesFeature: Features.hasFeature('track-changes'),
  785. otMigrationStage: project.overleaf?.history?.otMigrationStage ?? 0,
  786. projectTags,
  787. isSaas: Features.hasFeature('saas'),
  788. shouldLoadHotjar: splitTestAssignments.hotjar?.variant === 'enabled',
  789. isOverleafAssistBundleEnabled,
  790. customerIoEnabled,
  791. addonPrices,
  792. compileSettings: {
  793. compileTimeout: ownerFeatures?.compileTimeout,
  794. },
  795. })
  796. timer.done()
  797. } catch (err) {
  798. OError.tag(err, 'error getting details for project page')
  799. return next(err)
  800. }
  801. },
  802. async _getPaywallPlansPrices(
  803. req,
  804. res,
  805. paywallPlans = ['collaborator', 'student']
  806. ) {
  807. const plansData = {}
  808. const locale = req.i18n.language
  809. const { currency } = await SubscriptionController.getRecommendedCurrency(
  810. req,
  811. res
  812. )
  813. paywallPlans.forEach(plan => {
  814. const planPrice = Settings.localizedPlanPricing[currency][plan].monthly
  815. const formattedPlanPrice = formatCurrency(
  816. planPrice,
  817. currency,
  818. locale,
  819. true
  820. )
  821. plansData[plan] = formattedPlanPrice
  822. })
  823. return plansData
  824. },
  825. async _getAddonPrices(req, res, addonPlans = ['assistant']) {
  826. const plansData = {}
  827. const locale = req.i18n.language
  828. const { currency } = await SubscriptionController.getRecommendedCurrency(
  829. req,
  830. res
  831. )
  832. addonPlans.forEach(plan => {
  833. const annualPrice = Settings.localizedAddOnsPricing[currency][plan].annual
  834. const monthlyPrice =
  835. Settings.localizedAddOnsPricing[currency][plan].monthly
  836. const annualDividedByTwelve =
  837. Settings.localizedAddOnsPricing[currency][plan].annualDividedByTwelve
  838. plansData[plan] = {
  839. annual: formatCurrency(annualPrice, currency, locale, true),
  840. annualDividedByTwelve: formatCurrency(
  841. annualDividedByTwelve,
  842. currency,
  843. locale,
  844. true
  845. ),
  846. monthly: formatCurrency(monthlyPrice, currency, locale, true),
  847. }
  848. })
  849. return plansData
  850. },
  851. async _refreshFeatures(req, user) {
  852. // If the feature refresh has failed in this session, don't retry
  853. // it - require the user to log in again.
  854. if (req.session.feature_refresh_failed) {
  855. metrics.inc('features-refresh', 1, {
  856. path: 'load-editor',
  857. status: 'skipped',
  858. })
  859. return user
  860. }
  861. // If the refresh takes too long then return the current
  862. // features. Note that the user.features property may still be
  863. // updated in the background after the promise is resolved.
  864. const abortController = new AbortController()
  865. const refreshTimeoutHandler = async () => {
  866. await setTimeout(5000, { signal: abortController.signal })
  867. req.session.feature_refresh_failed = {
  868. reason: 'timeout',
  869. at: new Date(),
  870. }
  871. metrics.inc('features-refresh', 1, {
  872. path: 'load-editor',
  873. status: 'timeout',
  874. })
  875. return user
  876. }
  877. // try to refresh user features now
  878. const timer = new metrics.Timer('features-refresh-on-load-editor')
  879. return Promise.race([
  880. refreshTimeoutHandler(),
  881. (async () => {
  882. try {
  883. user.features = await FeaturesUpdater.promises.refreshFeatures(
  884. user._id,
  885. 'load-editor'
  886. )
  887. metrics.inc('features-refresh', 1, {
  888. path: 'load-editor',
  889. status: 'success',
  890. })
  891. } catch (err) {
  892. // keep a record to prevent unneceary retries and leave
  893. // the original features unmodified if the refresh failed
  894. req.session.feature_refresh_failed = {
  895. reason: 'error',
  896. at: new Date(),
  897. }
  898. metrics.inc('features-refresh', 1, {
  899. path: 'load-editor',
  900. status: 'error',
  901. })
  902. }
  903. abortController.abort()
  904. timer.done()
  905. return user
  906. })(),
  907. ])
  908. },
  909. _buildProjectList(allProjects, userId) {
  910. let project
  911. const {
  912. owned,
  913. review,
  914. readAndWrite,
  915. readOnly,
  916. tokenReadAndWrite,
  917. tokenReadOnly,
  918. } = allProjects
  919. const projects = []
  920. for (project of owned) {
  921. projects.push(
  922. ProjectController._buildProjectViewModel(
  923. project,
  924. 'owner',
  925. Sources.OWNER,
  926. userId
  927. )
  928. )
  929. }
  930. // Invite-access
  931. for (project of readAndWrite) {
  932. projects.push(
  933. ProjectController._buildProjectViewModel(
  934. project,
  935. 'readWrite',
  936. Sources.INVITE,
  937. userId
  938. )
  939. )
  940. }
  941. for (project of review) {
  942. projects.push(
  943. ProjectController._buildProjectViewModel(
  944. project,
  945. 'review',
  946. Sources.INVITE,
  947. userId
  948. )
  949. )
  950. }
  951. for (project of readOnly) {
  952. projects.push(
  953. ProjectController._buildProjectViewModel(
  954. project,
  955. 'readOnly',
  956. Sources.INVITE,
  957. userId
  958. )
  959. )
  960. }
  961. // Token-access
  962. // Only add these projects if they're not already present, this gives us cascading access
  963. // from 'owner' => 'token-read-only'
  964. for (project of tokenReadAndWrite) {
  965. if (
  966. projects.filter(p => p.id.toString() === project._id.toString())
  967. .length === 0
  968. ) {
  969. projects.push(
  970. ProjectController._buildProjectViewModel(
  971. project,
  972. 'readAndWrite',
  973. Sources.TOKEN,
  974. userId
  975. )
  976. )
  977. }
  978. }
  979. for (project of tokenReadOnly) {
  980. if (
  981. projects.filter(p => p.id.toString() === project._id.toString())
  982. .length === 0
  983. ) {
  984. projects.push(
  985. ProjectController._buildProjectViewModel(
  986. project,
  987. 'readOnly',
  988. Sources.TOKEN,
  989. userId
  990. )
  991. )
  992. }
  993. }
  994. return projects
  995. },
  996. _buildProjectViewModel(project, accessLevel, source, userId) {
  997. const archived = ProjectHelper.isArchived(project, userId)
  998. // If a project is simultaneously trashed and archived, we will consider it archived but not trashed.
  999. const trashed = ProjectHelper.isTrashed(project, userId) && !archived
  1000. const model = {
  1001. id: project._id,
  1002. name: project.name,
  1003. lastUpdated: project.lastUpdated,
  1004. lastUpdatedBy: project.lastUpdatedBy,
  1005. publicAccessLevel: project.publicAccesLevel,
  1006. accessLevel,
  1007. source,
  1008. archived,
  1009. trashed,
  1010. owner_ref: project.owner_ref,
  1011. isV1Project: false,
  1012. }
  1013. if (accessLevel === PrivilegeLevels.READ_ONLY && source === Sources.TOKEN) {
  1014. model.owner_ref = null
  1015. model.lastUpdatedBy = null
  1016. }
  1017. return model
  1018. },
  1019. _buildPortalTemplatesList(affiliations) {
  1020. if (affiliations == null) {
  1021. affiliations = []
  1022. }
  1023. const portalTemplates = []
  1024. for (const aff of affiliations) {
  1025. if (
  1026. aff.portal &&
  1027. aff.portal.slug &&
  1028. aff.portal.templates_count &&
  1029. aff.portal.templates_count > 0
  1030. ) {
  1031. const portalPath = aff.institution.isUniversity ? '/edu/' : '/org/'
  1032. portalTemplates.push({
  1033. name: aff.institution.name,
  1034. url: Settings.siteUrl + portalPath + aff.portal.slug,
  1035. })
  1036. }
  1037. }
  1038. return portalTemplates
  1039. },
  1040. async _setWritefullTrialState(
  1041. user,
  1042. userValues,
  1043. userId,
  1044. aiFeaturesAllowed,
  1045. userIsMemberOfGroupSubscription
  1046. ) {
  1047. let inEnterpriseCommons = false
  1048. const affiliations = userValues.affiliations || []
  1049. for (const affiliation of affiliations) {
  1050. inEnterpriseCommons =
  1051. inEnterpriseCommons || affiliation.institution?.enterpriseCommons
  1052. }
  1053. // check if a user has never tried writefull before (writefull.enabled will be null)
  1054. // if they previously accepted writefull, or are have been already assigned to a trial, user.writefull will be true,
  1055. // if they explicitly disabled it, user.writefull will be false
  1056. const shouldPushWritefull =
  1057. aiFeaturesAllowed &&
  1058. user.writefull?.enabled === null &&
  1059. !userIsMemberOfGroupSubscription
  1060. // we dont have legal approval to push enterprise commons into WF auto-account-create, but we are able to auto-load it into the toolbar
  1061. const shouldAutoCreateAccount = shouldPushWritefull && !inEnterpriseCommons
  1062. const shouldAutoLoad = shouldPushWritefull && inEnterpriseCommons
  1063. if (shouldAutoCreateAccount) {
  1064. await UserUpdater.promises.updateUser(userId, {
  1065. $set: {
  1066. writefull: { enabled: true, autoCreatedAccount: true },
  1067. },
  1068. })
  1069. user.writefull.enabled = true
  1070. user.writefull.autoCreatedAccount = true
  1071. } else if (shouldAutoLoad) {
  1072. await UserUpdater.promises.updateUser(userId, {
  1073. $set: {
  1074. writefull: { enabled: true, autoCreatedAccount: false },
  1075. },
  1076. })
  1077. user.writefull.enabled = true
  1078. user.writefull.autoCreatedAccount = false
  1079. }
  1080. },
  1081. }
  1082. const defaultSettingsForAnonymousUser = userId => ({
  1083. id: userId,
  1084. ace: {
  1085. mode: 'none',
  1086. theme: 'textmate',
  1087. fontSize: '12',
  1088. autoComplete: true,
  1089. spellCheckLanguage: '',
  1090. pdfViewer: '',
  1091. syntaxValidation: true,
  1092. },
  1093. subscription: {
  1094. freeTrial: {
  1095. allowed: true,
  1096. },
  1097. },
  1098. featureSwitches: {
  1099. github: false,
  1100. },
  1101. alphaProgram: false,
  1102. betaProgram: false,
  1103. writefull: {
  1104. enabled: false,
  1105. },
  1106. })
  1107. const defaultUserValues = () => ({
  1108. user: defaultSettingsForAnonymousUser(null),
  1109. learnedWords: [],
  1110. projectTags: [],
  1111. userHasInstitutionLicence: false,
  1112. subscription: undefined,
  1113. isTokenMember: false,
  1114. isInvitedMember: false,
  1115. })
  1116. const THEME_LIST = [
  1117. 'cobalt',
  1118. 'dracula',
  1119. 'eclipse',
  1120. 'monokai',
  1121. 'overleaf',
  1122. 'overleaf_dark',
  1123. 'textmate',
  1124. ]
  1125. const LEGACY_THEME_LIST = [
  1126. 'ambiance',
  1127. 'chaos',
  1128. 'chrome',
  1129. 'clouds',
  1130. 'clouds_midnight',
  1131. 'crimson_editor',
  1132. 'dawn',
  1133. 'dreamweaver',
  1134. 'github',
  1135. 'gob',
  1136. 'gruvbox',
  1137. 'idle_fingers',
  1138. 'iplastic',
  1139. 'katzenmilch',
  1140. 'kr_theme',
  1141. 'kuroir',
  1142. 'merbivore',
  1143. 'merbivore_soft',
  1144. 'mono_industrial',
  1145. 'nord_dark',
  1146. 'pastel_on_dark',
  1147. 'solarized_dark',
  1148. 'solarized_light',
  1149. 'sqlserver',
  1150. 'terminal',
  1151. 'tomorrow',
  1152. 'tomorrow_night',
  1153. 'tomorrow_night_blue',
  1154. 'tomorrow_night_bright',
  1155. 'tomorrow_night_eighties',
  1156. 'twilight',
  1157. 'vibrant_ink',
  1158. 'xcode',
  1159. ]
  1160. const ProjectController = {
  1161. archiveProject: expressify(_ProjectController.archiveProject),
  1162. cloneProject: expressify(_ProjectController.cloneProject),
  1163. deleteProject: expressify(_ProjectController.deleteProject),
  1164. expireDeletedProject: expressify(_ProjectController.expireDeletedProject),
  1165. expireDeletedProjectsAfterDuration: expressify(
  1166. _ProjectController.expireDeletedProjectsAfterDuration
  1167. ),
  1168. loadEditor: expressify(_ProjectController.loadEditor),
  1169. newProject: expressify(_ProjectController.newProject),
  1170. projectEntitiesJson: expressify(_ProjectController.projectEntitiesJson),
  1171. renameProject: expressify(_ProjectController.renameProject),
  1172. restoreProject: expressify(_ProjectController.restoreProject),
  1173. trashProject: expressify(_ProjectController.trashProject),
  1174. unarchiveProject: expressify(_ProjectController.unarchiveProject),
  1175. untrashProject: expressify(_ProjectController.untrashProject),
  1176. updateProjectAdminSettings: expressify(
  1177. _ProjectController.updateProjectAdminSettings
  1178. ),
  1179. updateProjectSettings: expressify(_ProjectController.updateProjectSettings),
  1180. userProjectsJson: expressify(_ProjectController.userProjectsJson),
  1181. _buildProjectList: _ProjectController._buildProjectList,
  1182. _buildProjectViewModel: _ProjectController._buildProjectViewModel,
  1183. _injectProjectUsers: _ProjectController._injectProjectUsers,
  1184. _isInPercentageRollout: _ProjectController._isInPercentageRollout,
  1185. _refreshFeatures: _ProjectController._refreshFeatures,
  1186. _getPaywallPlansPrices: _ProjectController._getPaywallPlansPrices,
  1187. _getAddonPrices: _ProjectController._getAddonPrices,
  1188. _setWritefullTrialState: _ProjectController._setWritefullTrialState,
  1189. }
  1190. export default ProjectController